Regenerate published weekly puzzles when a release's prices break them
--check now re-solves every week not over yet and, when its budget no longer verifies, regenerates it deterministically: the same puzzle with a new budget if that works, else a fresh one for the key. A regenerated file carries rev 2, 3...; the game keeps stars per revision, so only that week's stars reset. Past weeks are left alone unless the game rejects them. release.yml runs it before the tests on every deploy, weekly-puzzle.yml before making the new week; either fails only if a week cannot be regenerated.
This commit is contained in:
parent
77ec31d1a0
commit
7cbe0ec09b
10 changed files with 135 additions and 23 deletions
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
|
|
@ -80,16 +80,20 @@ jobs:
|
|||
echo "Weekly puzzles: $(ls site/puzzles/weekly | grep -c '^[0-9].*\.json$')"
|
||||
fi
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
if: ${{ !inputs.weekly }}
|
||||
- name: Check the weekly puzzles against this release
|
||||
if: ${{ inputs.weekly }}
|
||||
# This release's prices may no longer fit a week already published: --check regenerates every week not over
|
||||
# yet whose budget no longer verifies (deterministically, so main's next weekly run commits the same files),
|
||||
# and fails the deploy only if that fails. Before the tests, which check the weeks too.
|
||||
- name: Fit the weekly puzzles to this release
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# A release from before the weekly puzzles ships the files without reading them: nothing to check.
|
||||
if [ ! -f scripts/weekly-puzzle.js ]; then echo "This release does not read weekly puzzles yet."; exit 0; fi
|
||||
node scripts/weekly-puzzle.js --check
|
||||
npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js
|
||||
- run: npm test
|
||||
if: ${{ !inputs.weekly }}
|
||||
- name: Test the weekly puzzles against this release
|
||||
if: ${{ inputs.weekly && hashFiles('scripts/weekly-puzzle.js') != '' }}
|
||||
run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js
|
||||
- name: Build site
|
||||
run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue