Skip to content

Commit

Permalink
wip: Refactor CI to use GitHub actions and generic bash scripts #2
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Apr 22, 2024
1 parent 5c68e7c commit e8555b1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Main CI
on: [ push ]
name: ci
on: [ push, workflow_dispatch ]

jobs:
run_tests:
Expand All @@ -14,7 +14,7 @@ jobs:
run: bash ./scripts/init_runner.sh ${{ github.job }}
- name: Setup workspace
env:
GITHUB_DEVELOPMENT_PAT: ${{ secrets.GH_DEVELOPMENT_PAT }}
GITHUB_DEVELOPMENT_TOKEN: ${{ secrets.GH_DEVELOPMENT_TOKEN }}
run: bash ./scripts/setup_workspace.sh
- name: Run tests
env:
Expand All @@ -38,7 +38,7 @@ jobs:
run: bash ./scripts/init_runner.sh ${{ github.job }}
- name: Setup workspace
env:
GITHUB_DEVELOPMENT_PAT: ${{ secrets.GH_DEVELOPMENT_PAT }}
GITHUB_DEVELOPMENT_TOKEN: ${{ secrets.GH_DEVELOPMENT_TOKEN }}
run: bash ./scripts/setup_workspace.sh
- name: Run tests
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# feathers-webpush

[![Latest Release](https://img.shields.io/github/v/tag/kalisio/feathers-webpush?sort=semver&label=latest)](https://github.com/kalisio/feathers-webpush/releases)
[![Main CI](https://github.com/kalisio/feathers-webpush/actions/workflows/main.yaml/badge.svg)](https://github.com/kalisio/feathers-webpush/actions/workflows/main.yaml)
[![ci](https://github.com/kalisio/feathers-webpush/actions/workflows/main.yaml/badge.svg)](https://github.com/kalisio/feathers-webpush/actions/workflows/main.yaml)
[![Code Climate](https://codeclimate.com/github/kalisio/feathers-webpush/badges/gpa.svg)](https://codeclimate.com/github/kalisio/feathers-webpush)
[![Test Coverage](https://codeclimate.com/github/kalisio/feathers-webpush/badges/coverage.svg)](https://codeclimate.com/github/kalisio/feathers-webpush/coverage)
[![Download Status](https://img.shields.io/npm/dm/@kalisio/feathers-webpush.svg?style=flat-square)](https://www.npmjs.com/package/@kalisio/feathers-webpush)
Expand Down
2 changes: 1 addition & 1 deletion scripts/kash
Submodule kash updated 2 files
+438 −130 kash.sh
+38 −9 scripts/run_tests.sh
2 changes: 1 addition & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ while getopts "n:cr:" option; do
CODE_COVERAGE=true
;;
r) # report outcome to slack
CI_STEP_NAME=$OPTARG
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_LIBS.enc.env"
CI_STEP_NAME=$OPTARG
trap 'slack_ci_report "$ROOT_DIR" "$CI_STEP_NAME" "$?" "$SLACK_WEBHOOK_LIBS"' EXIT
;;
*)
Expand Down
25 changes: 6 additions & 19 deletions scripts/setup_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ ROOT_DIR=$(dirname "$THIS_DIR")

. "$THIS_DIR/kash/kash.sh"

## Parse options
##

WORKSPACE_BRANCH=
WORKSPACE_TAG=

begin_group "Setting up workspace ..."

if [ "$CI" = true ]; then
WORKSPACE_DIR="$(dirname "$ROOT_DIR")"
DEVELOPMENT_REPO_URL="https://$GITHUB_DEVELOPMENT_PAT@github.com/kalisio/development.git"
DEVELOPMENT_REPO_URL="https://$GITHUB_DEVELOPMENT_TOKEN@github.com/kalisio/development.git"
else
while getopts "b:t" option; do
case $option in
Expand All @@ -30,25 +27,15 @@ else
;;
esac
done

shift $((OPTIND-1))
WORKSPACE_DIR="$1"

# NOTE: cloning feathers-webpush could be avoided if we could parse app_version from tag/branch name instead
# In this case, the kli would clone feathers-webpush
GIT_OPS="--recurse-submodules"
if [ -n "$WORKSPACE_TAG" ] || [ -n "$WORKSPACE_BRANCH" ]; then
GIT_OPS="$GIT_OPS --branch ${WORKSPACE_TAG:-$WORKSPACE_BRANCH}"
fi
git clone --depth 1 $GIT_OPS "$GITHUB_URL/kalisio/feathers-webpush.git" "$WORKSPACE_DIR/feathers-webpush"

DEVELOPMENT_REPO_URL="$GITHUB_URL/kalisio/development.git"

# unset KALISIO_DEVELOPMENT_DIR because we want kli to clone everyhting in $WORKSPACE_DIR
unset KALISIO_DEVELOPMENT_DIR
# Clone project in the workspace
git_shallow_clone "$GITHUB_URL/kalisio/feathers-webpush.git" "$WORKSPACE_DIR/feathers-webpush" "${WORKSPACE_TAG:-${WORKSPACE_BRANCH:-}}"
fi

# clone development in $WORKSPACE_DIR
DEVELOPMENT_DIR="$WORKSPACE_DIR/development"
git clone --depth 1 "$DEVELOPMENT_REPO_URL" "$DEVELOPMENT_DIR"
setup_lib_workspace "$WORKSPACE_DIR" "$DEVELOPMENT_REPO_URL" "https://github.com/kalisio/feathers-s3"

end_group "Setting up workspace ..."
end_group "Setting up workspace ..."

0 comments on commit e8555b1

Please sign in to comment.