diff options
author | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-11 15:36:49 -0700 |
---|---|---|
committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2025-05-11 16:17:23 -0700 |
commit | b241180aa85ad81f4ee0dca9bf3c0429916a6a18 (patch) | |
tree | 91bac564261b210517297daf3e4937e11e4001aa /worker/jobs | |
parent | aff695a1ff160d9e3045fbdf832c95db732c0f89 (diff) | |
download | ci-b241180aa85ad81f4ee0dca9bf3c0429916a6a18.tar.gz ci-b241180aa85ad81f4ee0dca9bf3c0429916a6a18.zip |
Significantly improve traceability and minor fixes.
Diffstat (limited to 'worker/jobs')
-rwxr-xr-x | worker/jobs/checkout_ci.run | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/worker/jobs/checkout_ci.run b/worker/jobs/checkout_ci.run index 278a5b3..0945444 100755 --- a/worker/jobs/checkout_ci.run +++ b/worker/jobs/checkout_ci.run @@ -1,40 +1,42 @@ #!/bin/bash -# usage: laminarc run ci remote="ssh://src.liz.coffee:2222/cgit" rev="<sha>" \ -# refname="refs/..." - -set -e +# usage: laminarc run checkout_ci remote="ssh://src.liz.coffee:2222/cgit" rev="<sha>" \ +# refname="refs/..." RUN=`date +%s` -CWD=`$PWD` -WORKING_DIR=`$PWD/$RUN` +RETURN="$PWD" +WORKING_DIR="$PWD/$RUN" + +export LOG_PREFIX="[checkout_ci.$RUN]" +log "starting checkout_ci job $remote @ $refname - $rev in $WORKING_DIR" mkdir -p "$WORKING_DIR" && cd "$WORKING_DIR" -checkout="$rev" path="tmpsrc" fetch_code.sh +CODE="$WORKING_DIR/src" +checkout="$rev" path="$CODE" fetch_code -if [[ ! -e "$WORKING_DIR/tmpsrc/.ci/ci.json" ]]; then - echo "No Continuous Integration configured for $remote." +CI_WORKFLOW="$CODE/.ci/ci.json" +if [[ ! -e "$CI_WORKFLOW" ]]; then + log "no CI configuration found" exit 0 fi -PIPELINE_GENERATOR_PATH=$(jq -r '.pipeline' "$WORKING_DIR/tmpsrc/.ci/ci.json") +PIPELINE_GENERATOR_PATH=$(jq -r '.pipeline' "$CI_WORKFLOW") if [[ "$PIPELINE_GENERATOR_PATH" == *".."* ]]; then - echo "Error: Path contains '..'" + log "no '..'" exit 1 fi -docker run --rm \ - --network none \ - --cap-drop ALL \ - --security-opt no-new-privileges \ - -v "$WORKING_DIR/tmpsrc/$PIPELINE_GENERATOR:/pipeline" \ - -e refname="$refname" \ - -e rev="$rev" \ - -e remote="$remote" \ - oci.liz.coffee/img/liz-ci:release \ - /pipeline \ - > "$WORKING_DIR/pipeline.json" - -pipeline="$WORKING_DIR/pipeline.json" run_pipeline - -cd "$CWD" && rm -rf "$WORKING_DIR" +log "building the pipeline..." +PIPELINE="$WORKING_DIR/pipeline.json" +docker run --rm --network none --cap-drop ALL --security-opt no-new-privileges \ + -e refname="$refname" -e rev="$rev" -e remote="$remote" \ + -v "$CODE/$PIPELINE_GENERATOR_PATH:/pipeline_generator" \ + oci.liz.coffee/img/liz-ci:release /pipeline_generator \ + > "$PIPELINE" + +pipeline="$PIPELINE" run_pipeline + +log "cleaning up working directory" +cd "$RETURN" && rm -rf "$WORKING_DIR" + +log "checkout_ci run done" |