From 4e6f780c8162b2e2415f8c505c91cb0f15d1ad15 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sat, 7 Nov 2026 10:28:57 +0100 Subject: [PATCH] No double runs in a release: container test and weekly tests once A version bump's push started docker.yml's test, then auto-release started docker.yml again for the tag, which tests the same code before it publishes: the push skips its test while the version is not tagged. The deploy re-ran the weekly-puzzle tests even when main's weekly files are the tag's own, which CI had just tested: it now runs them only for files that differ (a newer or refitted week) or an untested tag. --- .github/workflows/docker.yml | 23 +++++++++++++++++++++++ .github/workflows/release.yml | 13 +++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9bcb23a..434307e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -38,7 +38,30 @@ concurrency: cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }} jobs: + # A push that bumps the version is a release on its way: once CI passes, auto-release.yml starts this workflow for + # the tag, which tests the same code before it publishes. Testing the push too would be the same run twice. + gate: + runs-on: ubuntu-latest + outputs: + run: ${{ steps.g.outputs.run }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.tag || '' }} + persist-credentials: false + - id: g + run: | + tag="v$(jq -r .version package.json)" + if [ "$GITHUB_EVENT_NAME" = push ] && ! git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null; then + echo "$tag is not tagged yet: the release will test this commit when it publishes." + echo "run=false" >> "$GITHUB_OUTPUT" + else + echo "run=true" >> "$GITHUB_OUTPUT" + fi + test: + needs: gate + if: needs.gate.outputs.run == 'true' runs-on: ubuntu-latest timeout-minutes: 20 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d2acf5..9c2defa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,9 +106,18 @@ jobs: node scripts/weekly-puzzle.js --check if [ -f scripts/weekly-scenario.js ]; then node scripts/weekly-scenario.js --check; fi if [ -f scripts/weekly-architect.js ]; then node scripts/weekly-architect.js --check; fi - # The weekly files come from main, not the tag: whatever tested the tag, they are tested against it here. + # The weekly files come from main, not the tag. When they (after fitting) are the tag's own, CI already tested + # them with it; otherwise (a newer week, a refitted one) they are tested against this release here. + - name: Are the weekly files the tag's own? + id: weekly + run: | + if [ -z "$(git status --porcelain -- site/puzzles/weekly site/scenarios/weekly site/architect/weekly)" ]; then + echo "Same weekly files as the tag: tested with it already."; echo "same=true" >> "$GITHUB_OUTPUT" + else + git status --short -- site/puzzles/weekly site/scenarios/weekly site/architect/weekly; echo "same=false" >> "$GITHUB_OUTPUT" + fi - name: Test the weekly puzzles against this release - if: ${{ hashFiles('scripts/weekly-puzzle.js') != '' }} + if: ${{ hashFiles('scripts/weekly-puzzle.js') != '' && (steps.weekly.outputs.same != 'true' || !(inputs.tested || needs.tests.result == 'success')) }} run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js $(ls tests/weekly-scenario.test.js tests/weekly-architect.test.js 2>/dev/null) - name: Build site run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build