ci: the integration job removes its stacks even when the runner kills it
The platform's rule (its ci-sweep.sh, docs/development/security.md), applied to the one Signage job that starts Docker stacks: - it has its own EKKLESIA_CI_JOB_KEY; - it sweeps stale CI stacks from the runner before it starts; - it removes its own stacks in a final `if: always()` step, which tolerates a failed assembly, since nothing was started then; - the image ci/integration.sh builds is named and labeled as a CI stack of this run and job, with the time CI built it, so the sweep finds it. ci/platform.env moves to the platform commit that adds the sweep (Ekklesia #60). The assembled lockfile is unchanged, and still passes a frozen install. Verified: SIGKILL of the integration script's whole process group mid-run left 11 resources (2 containers, 4 networks, 4 volumes and the image). `ci-sweep.sh --job` removed exactly those 11. A normal run passes, and the job sweep after it finds nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
cfa4628f8c
commit
cbf2a8ee39
@@ -187,6 +187,9 @@ jobs:
|
|||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
|
# Names this job's stacks, so its final step removes exactly these (the platform's
|
||||||
|
# scripts/lib/ci-project.sh).
|
||||||
|
EKKLESIA_CI_JOB_KEY: signage-integration
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
@@ -196,5 +199,19 @@ jobs:
|
|||||||
- name: Assemble Signage into the pinned platform
|
- name: Assemble Signage into the pinned platform
|
||||||
run: bash ci/assemble.sh
|
run: bash ci/assemble.sh
|
||||||
|
|
||||||
|
# A job the runner killed (cancelled, or past the runner's own time limit) never ran its
|
||||||
|
# cleanup. Anything a CI job left on this shared daemon more than three hours ago goes first.
|
||||||
|
- name: Sweep stale CI stacks from the runner
|
||||||
|
run: bash build/workspace/scripts/ci-sweep.sh --stale
|
||||||
|
|
||||||
- name: Build the image and run the display scenarios
|
- name: Build the image and run the display scenarios
|
||||||
run: bash ci/integration.sh
|
run: bash ci/integration.sh
|
||||||
|
|
||||||
|
# Whatever happened above, this job's own stacks do not outlive it. If assembly failed, nothing
|
||||||
|
# was started.
|
||||||
|
- name: Remove this job's CI stacks
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f build/workspace/scripts/ci-sweep.sh ]; then
|
||||||
|
bash build/workspace/scripts/ci-sweep.sh --job
|
||||||
|
fi
|
||||||
|
|||||||
+7
-1
@@ -15,7 +15,12 @@ workspace="$root/build/workspace"
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
image="signage-ci:${GITHUB_SHA:-local}-${GITHUB_RUN_ID:-0}-${GITHUB_RUN_ATTEMPT:-1}"
|
# Named and labeled as a CI stack of this run and job (the platform's scripts/lib/ci-project.sh), so
|
||||||
|
# the workflow's final `ci-sweep.sh --job` removes it even if this script is killed before its trap.
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$workspace/scripts/lib/ci-project.sh"
|
||||||
|
project="$(ci_project_name signage-image)"
|
||||||
|
image="${project}:latest"
|
||||||
trap 'docker image rm --force "$image" >/dev/null 2>&1 || true' EXIT
|
trap 'docker image rm --force "$image" >/dev/null 2>&1 || true' EXIT
|
||||||
|
|
||||||
scenarios="$(sed -e 's/#.*//' -e '/^[[:space:]]*$/d' "$root/ci/display-scenarios" | tr '\n' ' ')"
|
scenarios="$(sed -e 's/#.*//' -e '/^[[:space:]]*$/d' "$root/ci/display-scenarios" | tr '\n' ' ')"
|
||||||
@@ -25,6 +30,7 @@ scenarios="$(sed -e 's/#.*//' -e '/^[[:space:]]*$/d' "$root/ci/display-scenarios
|
|||||||
}
|
}
|
||||||
|
|
||||||
DOCKER_BUILDKIT=1 docker build --quiet --file "$workspace/deploy/Dockerfile" --tag "$image" \
|
DOCKER_BUILDKIT=1 docker build --quiet --file "$workspace/deploy/Dockerfile" --tag "$image" \
|
||||||
|
--label "${EKKLESIA_CI_LABEL}=${project}" --label "${EKKLESIA_CI_CREATED_LABEL}=$(date +%s)" \
|
||||||
"$workspace" >/dev/null
|
"$workspace" >/dev/null
|
||||||
echo "integration: built the deployment image with Signage; scenarios: ${scenarios}"
|
echo "integration: built the deployment image with Signage; scenarios: ${scenarios}"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,4 +3,4 @@
|
|||||||
#
|
#
|
||||||
# Move it deliberately: change the commit, run `bash ci/update-lock.sh`, and commit both.
|
# Move it deliberately: change the commit, run `bash ci/update-lock.sh`, and commit both.
|
||||||
EKKLESIA_PLATFORM_REPOSITORY=https://git.riverofglorymn.org/River_of_Glory_Church/Ekklesia.git
|
EKKLESIA_PLATFORM_REPOSITORY=https://git.riverofglorymn.org/River_of_Glory_Church/Ekklesia.git
|
||||||
EKKLESIA_PLATFORM_COMMIT=f50e8f42018c15698709739e2ba54771e97df08a
|
EKKLESIA_PLATFORM_COMMIT=00e544125b855372e0f173db33323a57ac357d02
|
||||||
|
|||||||
Reference in New Issue
Block a user