Skip to content

Commit

Permalink
wip: Refactor CI to use GitHub actions and generic bash scripts (#273)…
Browse files Browse the repository at this point in the history
… [build doc] [additional tests]
  • Loading branch information
claustres committed Apr 5, 2024
1 parent 8727a01 commit 7026c3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 54 deletions.
26 changes: 3 additions & 23 deletions scripts/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail
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"

Expand All @@ -19,6 +20,7 @@ while getopts "pr:" OPT; do
PUBLISH=true
;;
r) # report outcome to slack
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_JOBS.enc.env"
CI_STEP_NAME=$OPTARG
trap 'slack_ci_report "$ROOT_DIR" "$CI_STEP_NAME" "$?" "$SLACK_WEBHOOK_JOBS"' EXIT
;;
Expand All @@ -27,31 +29,9 @@ while getopts "pr:" OPT; do
esac
done

## Init workspace
##

WORKSPACE_DIR="$(dirname "$ROOT_DIR")"

load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_JOBS.enc.env"

## Build docs
##

# Build process requires node 18
use_node 18

rm -f .postcssrc.js && cd docs && yarn install && yarn build

if [ "$PUBLISH" = true ]; then
load_env_files "$WORKSPACE_DIR/development/common/GH_PAGES_PUSH_TOKEN.enc.env"
build_docs "$ROOT_DIR" "kalisio/krawler" "$PUBLISH"

COMMIT_SHA=$(get_git_commit_sha "$ROOT_DIR")
COMMIT_AUTHOR_NAME=$(get_git_commit_author_name "$ROOT_DIR")
COMMIT_AUTHOR_EMAIL=$(get_git_commit_author_email "$ROOT_DIR")
deploy_gh_pages \
"https://oauth2:$GH_PAGES_PUSH_TOKEN@github.com/kalisio/krawler.git" \
"$ROOT_DIR/docs/.vitepress/dist" \
"$COMMIT_AUTHOR_NAME" \
"$COMMIT_AUTHOR_EMAIL" \
"Docs built from $COMMIT_SHA"
fi
2 changes: 1 addition & 1 deletion scripts/kash
Submodule kash updated 1 files
+182 −5 kash.sh
34 changes: 4 additions & 30 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail
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"

Expand All @@ -27,6 +28,7 @@ while getopts "m:n:cr:" option; do
CODE_COVERAGE=true
;;
r) # report outcome to slack
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_JOBS.enc.env"
CI_STEP_NAME=$OPTARG
trap 'slack_ci_report "$ROOT_DIR" "$CI_STEP_NAME" "$?" "$SLACK_WEBHOOK_JOBS"' EXIT
;;
Expand All @@ -38,40 +40,12 @@ done
## Init workspace
##

WORKSPACE_DIR="$(dirname "$ROOT_DIR")"
init_lib_infos "$ROOT_DIR" "$WORKSPACE_DIR/development/workspaces/jobs"

APP=$(get_lib_name)
VERSION=$(get_lib_version)
GIT_TAG=$(get_lib_tag)

echo "About to run tests for ${APP} v${VERSION}..."

. "$WORKSPACE_DIR/development/workspaces/jobs/jobs.sh" krawler
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_JOBS.enc.env"

# Required by tests
# Required by krawler tests
docker pull v4tech/imagemagick

## Start mongo
##

begin_group "Starting mongo $MONGO_VER ..."

use_mongo "$MONGO_VER"
k-mongo

end_group "Starting mongo $MONGO_VER ..."

## Run tests
##

use_node "$NODE_VER"
yarn && yarn test

## Publish code coverage
##

if [ "$CODE_COVERAGE" = true ]; then
send_coverage_to_cc "$CC_TEST_REPORTER_ID"
fi
run_lib_tests "$ROOT_DIR" "$CODE_COVERAGE"

0 comments on commit 7026c3a

Please sign in to comment.