From 7157c6649eb0b2f4535078cc9b2d3985d201e810 Mon Sep 17 00:00:00 2001 From: Adam French Date: Thu, 26 Nov 2026 16:14:45 +0000 Subject: [PATCH] CI: scratch directories per run, not per commit 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- 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 --- .gitea/workflows/ci.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 9bfd043..17c6fb9 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -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