CI: scratch directories per run, not per commit
Test and publish the site / test (push) Successful in 18s
Test and publish the site / publish (push) Successful in 8s
Test and publish the site / deploy (push) Successful in 1s

The build runner takes two jobs at once, so the same commit pushed to
two branches (main and a feature branch) ran its test job twice in
parallel against one src-<sha> directory, and each run's clean-up
deleted the other's source mid-test. Suffix the scratch directories
(and activity-tracker's throwaway Postgres and network) with the run id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:14:45 +00:00
co-authored by Claude Opus 5.5
parent 1ec6fb4f5a
commit 7157c6649e
+5 -3
View File
@@ -54,7 +54,9 @@ jobs:
REMOTE: http://git.adam-french.co.uk:3000/adamf/usaco.git
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
CACHE: /home/adamf/.cache/usaco-ci/repo.git
SRC: /home/adamf/.cache/usaco-ci/src-${{ github.sha }}
# Per run, not just per commit: the build runner takes two jobs at
# once, and the same commit pushed to two branches runs twice.
SRC: /home/adamf/.cache/usaco-ci/src-${{ github.sha }}-${{ github.run_id }}
steps:
- name: Export the pushed commit's site/ to a scratch directory
shell: bash
@@ -117,7 +119,7 @@ jobs:
env:
SHA: ${{ github.sha }}
CACHE: /home/adamf/.cache/usaco-ci/repo.git
SRC: /home/adamf/.cache/usaco-ci/publish-${{ github.sha }}
SRC: /home/adamf/.cache/usaco-ci/publish-${{ github.sha }}-${{ github.run_id }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
# The Dockerfile's `RUN --mount=type=cache` lines need BuildKit.
@@ -148,7 +150,7 @@ jobs:
shell: bash
run: |
set -eu
name="usaco-runner-ci-$SHA"
name="usaco-runner-ci-$SHA-${{ github.run_id }}"
docker run -d --name "$name" --read-only --tmpfs /tmp:size=256m,exec \
--memory 1g --pids-limit 128 --cap-drop ALL --security-opt no-new-privileges \
"$RUNNER_IMAGE:$SHA" >/dev/null