-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Refactor CI to use GitHub actions and generic bash scripts #846
- Loading branch information
Showing
7 changed files
with
165 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: ci | ||
on: [ push, workflow_dispatch ] | ||
|
||
jobs: | ||
run_tests: | ||
name: Run tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Init runner | ||
run: bash ./scripts/init_runner.sh ${{ github.job }} | ||
- name: Setup workspace | ||
env: | ||
GITHUB_DEVELOPMENT_TOKEN: ${{ secrets.GH_DEVELOPMENT_TOKEN }} | ||
run: bash ./scripts/setup_workspace.sh | ||
- name: Run tests | ||
env: | ||
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }} | ||
run: bash ./scripts/run_tests.sh -c -r ${{ github.job }} | ||
|
||
additional_tests: | ||
strategy: | ||
max-parallel: 1 | ||
fail-fast: false | ||
matrix: | ||
node: [ 18, 20 ] | ||
mongo: [ 5, 6 ] | ||
name: Additional tests (node ${{ matrix.node }}) | ||
if: ${{ contains(github.event.head_commit.message, 'additional tests') }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Init runner | ||
run: bash ./scripts/init_runner.sh ${{ github.job }} | ||
- name: Setup workspace | ||
env: | ||
GITHUB_DEVELOPMENT_TOKEN: ${{ secrets.GH_DEVELOPMENT_TOKEN }} | ||
run: bash ./scripts/setup_workspace.sh | ||
- name: Run tests | ||
env: | ||
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }} | ||
run: bash ./scripts/run_tests.sh -n ${{ matrix.node }} -m ${{ matrix.mongo }} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# set -x | ||
|
||
JOB_ID=$1 | ||
|
||
THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}") | ||
THIS_DIR=$(dirname "$THIS_FILE") | ||
|
||
. "$THIS_DIR/kash/kash.sh" | ||
|
||
### Github Actions | ||
|
||
init_github_run_tests() { | ||
install_reqs age sops nvm node16 cc_test_reporter | ||
} | ||
|
||
init_github_additional_tests() { | ||
install_reqs age sops nvm node18 node20 mongo5 mongo6 #mongo7 | ||
} | ||
|
||
begin_group "Init $CI_ID for $JOB_ID" | ||
|
||
init_"${CI_ID}_${JOB_ID}" | ||
|
||
end_group "Init $CI_ID for $JOB_ID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# set -x | ||
|
||
THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}") | ||
THIS_DIR=$(dirname "$THIS_FILE") | ||
ROOT_DIR=$(dirname "$THIS_DIR") | ||
WORKSPACE_DIR="$(dirname "$ROOT_DIR")" | ||
|
||
. "$THIS_DIR/kash/kash.sh" | ||
|
||
## Parse options | ||
## | ||
|
||
NODE_VER=16 | ||
MONGO_VER="" | ||
CI_STEP_NAME="Run tests" | ||
CODE_COVERAGE=false | ||
while getopts "n:cr:" option; do | ||
case $option in | ||
n) # defines node version | ||
NODE_VER=$OPTARG | ||
;; | ||
c) # publish code coverage | ||
CODE_COVERAGE=true | ||
;; | ||
r) # report outcome to slack | ||
CI_STEP_NAME=$OPTARG | ||
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_LIBS.enc.env" | ||
trap 'slack_ci_report "$ROOT_DIR" "$CI_STEP_NAME" "$?" "$SLACK_WEBHOOK_LIBS"' EXIT | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
## Init workspace | ||
## | ||
|
||
. "$WORKSPACE_DIR/development/workspaces/libs/libs.sh" kdk | ||
|
||
## Run tests | ||
## | ||
|
||
run_lib_tests "$ROOT_DIR" "$CODE_COVERAGE" "$NODE_VER" "$MONGO_VER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# set -x | ||
|
||
THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}") | ||
THIS_DIR=$(dirname "$THIS_FILE") | ||
ROOT_DIR=$(dirname "$THIS_DIR") | ||
|
||
. "$THIS_DIR/kash/kash.sh" | ||
|
||
## Parse options | ||
## | ||
|
||
begin_group "Setting up workspace ..." | ||
|
||
if [ "$CI" = true ]; then | ||
WORKSPACE_DIR="$(dirname "$ROOT_DIR")" | ||
DEVELOPMENT_REPO_URL="https://$GITHUB_DEVELOPMENT_TOKEN@github.com/kalisio/development.git" | ||
else | ||
while getopts "b:t" option; do | ||
case $option in | ||
b) # defines branch | ||
WORKSPACE_BRANCH=$OPTARG;; | ||
t) # defines tag | ||
WORKSPACE_TAG=$OPTARG;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
shift $((OPTIND-1)) | ||
WORKSPACE_DIR="$1" | ||
DEVELOPMENT_REPO_URL="$GITHUB_URL/kalisio/development.git" | ||
|
||
# Clone project in the workspace | ||
git_shallow_clone "$GITHUB_URL/kalisio/kdk.git" "$WORKSPACE_DIR/kdk" "${WORKSPACE_TAG:-${WORKSPACE_BRANCH:-}}" | ||
fi | ||
|
||
setup_lib_workspace "$WORKSPACE_DIR" "$DEVELOPMENT_REPO_URL" \ | ||
"https://github.com/kalisio/feathers-distributed.git" \ | ||
"https://github.com/kalisio/feathers-webpush.git" \ | ||
"https://github.com/kalisio/feathers-s3.git" \ | ||
"https://github.com/kalisio/feathers-import-export.git" | ||
|
||
end_group "Setting up workspace ..." |