fix(ci): confine the sweep self-test to its own run
CI / verify (pull_request) Successful in 1m10s
CI / infrastructure-smoke (pull_request) Successful in 42s
CI / package-release (pull_request) Successful in 49s
CI / migration-smoke (pull_request) Successful in 2m21s
CI / image-build (pull_request) Successful in 59s
CI / deploy-smoke (same-origin) (pull_request) Successful in 52s
CI / deploy-smoke (split) (pull_request) Successful in 2m35s
CI / package-publication (pull_request) Successful in 1m3s
CI / verify (pull_request) Successful in 1m10s
CI / infrastructure-smoke (pull_request) Successful in 42s
CI / package-release (pull_request) Successful in 49s
CI / migration-smoke (pull_request) Successful in 2m21s
CI / image-build (pull_request) Successful in 59s
CI / deploy-smoke (same-origin) (pull_request) Successful in 52s
CI / deploy-smoke (split) (pull_request) Successful in 2m35s
CI / package-publication (pull_request) Successful in 1m3s
scripts/test-ci-sweep.sh proves the stale sweep by running `ci-sweep.sh --stale --max-age-seconds 0` on the runner's shared Docker daemon. With a zero threshold that removes every `ekklesia-ci-` stack on the daemon, not just the test's own: any job running at that moment loses its containers, networks, and volumes. It reported "CI sweep checks passed" while doing it. Core's infrastructure-smoke job runs the self-test on every run, and twice tore down Signage's integration stack mid-scenario (Zayin/Signage run 288: its first attempt, and the second one during connectivity-blip). `ci-sweep.sh --stale` now takes `--prefix P`, which narrows the sweep to stacks whose names begin with P and must itself begin with the CI prefix, so it can only narrow a sweep, never widen one. The self-test confines every stale sweep to its own fake run and proves that another run's stack survives even the zero threshold. The workflow's own sweeps are unchanged. Regression: a bystander stack from another run in the self-test, and a Docker-free guard that every stale sweep in the self-test is confined and the workflow's keep the default threshold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
437720f228
commit
94fa7a17a8
@@ -4,8 +4,10 @@
|
||||
#
|
||||
# bash scripts/test-ci-sweep.sh
|
||||
#
|
||||
# Every resource it creates is named and labeled for this run alone, under fake run identifiers, so
|
||||
# it can never touch a real stack; and it removes all of them on exit, whatever happens.
|
||||
# Every resource it creates is named and labeled for this run alone, under fake run identifiers, and
|
||||
# every sweep it runs is confined to those identifiers, so it can never touch a real stack: the
|
||||
# runner's daemon is shared, and another job's live stack may be on it right now. It removes all of
|
||||
# its own resources on exit, whatever happens.
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
@@ -91,10 +93,14 @@ source "$repository_root/scripts/lib/ci-project.sh"
|
||||
# Fake run identifiers: nothing here can match a real run's stacks.
|
||||
export GITHUB_RUN_ID="sweeptest${nonce}"
|
||||
export GITHUB_RUN_ATTEMPT="1"
|
||||
# Every stack this test sweeps begins with this; nothing it sweeps reaches past it.
|
||||
own_run="$(ci_name_safe "ekklesia-ci-${GITHUB_RUN_ID}-")"
|
||||
mine="$(EKKLESIA_CI_JOB_KEY=alpha ci_project_name mine)"
|
||||
sibling="$(EKKLESIA_CI_JOB_KEY=beta ci_project_name sibling)"
|
||||
foreign="ekklesia-sweep-control-${nonce}"
|
||||
for project in "$mine" "$sibling" "$foreign"; do
|
||||
# Stands in for another run's live stack on the shared daemon — a module's integration job, say.
|
||||
bystander="$(GITHUB_RUN_ID="bystander${nonce}" EKKLESIA_CI_JOB_KEY=gamma ci_project_name live)"
|
||||
for project in "$mine" "$sibling" "$foreign" "$bystander"; do
|
||||
make_stack "$project"
|
||||
done
|
||||
# A job container connected to this job's stack network, exactly as compose-job-network.sh does.
|
||||
@@ -115,12 +121,19 @@ check '! env -u GITHUB_RUN_ID bash scripts/ci-sweep.sh --job >/dev/null 2>&1' \
|
||||
"--job without GITHUB_RUN_ID fails"
|
||||
|
||||
echo "--- --stale removes only CI stacks older than its threshold"
|
||||
bash scripts/ci-sweep.sh --stale
|
||||
bash scripts/ci-sweep.sh --stale --prefix "$own_run"
|
||||
check 'project_exists "$sibling"' "a young CI stack survives the default threshold"
|
||||
bash scripts/ci-sweep.sh --stale --max-age-seconds 0
|
||||
bash scripts/ci-sweep.sh --stale --max-age-seconds 0 --prefix "$own_run"
|
||||
check '! project_exists "$sibling"' "a CI stack older than the threshold is removed"
|
||||
check '! staging_exists "$sibling"' "its staging directory too"
|
||||
check 'project_exists "$foreign"' "a stack outside the CI prefix is never removed, at any age"
|
||||
check 'project_exists "$bystander"' \
|
||||
"another run's stack is never removed by a narrowed sweep, even past the threshold"
|
||||
echo "--- --prefix only ever narrows the sweep"
|
||||
check '! bash scripts/ci-sweep.sh --stale --prefix "ekklesia-" >/dev/null 2>&1' \
|
||||
"a prefix outside the CI prefix is refused"
|
||||
check '! bash scripts/ci-sweep.sh --job --prefix "$own_run" >/dev/null 2>&1' \
|
||||
"--prefix with --job is refused"
|
||||
|
||||
if ((failures > 0)); then
|
||||
echo "test-ci-sweep: ${failures} check(s) failed." >&2
|
||||
|
||||
Reference in New Issue
Block a user