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