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.
This commit is contained in:
parent
03523cb16b
commit
4e6f780c81
2 changed files with 34 additions and 2 deletions
23
.github/workflows/docker.yml
vendored
23
.github/workflows/docker.yml
vendored
|
|
@ -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:
|
||||
|
|
|
|||
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue