Faster tests, split everywhere: one sharded CI for pushes and releases

- The harness builds the DOM without the page's 2 MB of script text and
  runs the scripts straight in the window: a page load in tests takes
  about half the time (jsdom's parser was slow on the script text).
- That also took the game's source out of the DOM, which showed three
  tests that matched a phrase in the page source rather than the screen;
  they now check the panel, the routing window and the dictionary.
- CI plans its split once and runs the tests on 6 runners; every run on
  main records each file's time and caches it, so the parts stay even
  without anyone refreshing tests/durations.json.
- auto-release.yml and release.yml call the same sharded tests instead
  of running all 170 files on one runner each (11 and 15 min); a release
  is tested once, before it is tagged.
- Audit: five tests that duplicated a gameplay rule or checked nothing
  are gone; the two slowest checks sample a third of the cities, and a
  year of play to reach one due date became a moved due date.
This commit is contained in:
Frederic Jung 2026-11-07 07:24:09 +01:00
parent 7a6eb29013
commit 0342d90657
No known key found for this signature in database
17 changed files with 244 additions and 109 deletions

View file

@ -23,6 +23,10 @@ on:
description: Only the weekly puzzles changed (weekly-puzzle.yml); the release itself was tested when it shipped
type: boolean
default: false
tested:
description: The tag's tests already passed (auto-release.yml tests it before tagging)
type: boolean
default: false
# Least privilege: only the deploy job can write to Pages.
permissions:
@ -33,9 +37,18 @@ concurrency:
cancel-in-progress: false
jobs:
# The release's tests, split over several runners like every push (ci.yml). Skipped when auto-release.yml has just
# run them on this tag, and for a weekly redeploy (the build step below tests the weekly files against the tag).
tests:
if: ${{ (github.event_name == 'workflow_dispatch' || !github.event.release.prerelease) && !inputs.weekly && !inputs.tested }}
uses: ./.github/workflows/ci.yml
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
build:
needs: tests
# Pre-releases are for testing and never go live.
if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.prerelease }}
if: ${{ always() && (github.event_name == 'workflow_dispatch' || !github.event.release.prerelease) && (needs.tests.result == 'success' || needs.tests.result == 'skipped') }}
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
@ -93,10 +106,9 @@ 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
- run: npm test
if: ${{ !inputs.weekly }}
# The weekly files come from main, not the tag: whatever tested the tag, they are tested against it here.
- name: Test the weekly puzzles against this release
if: ${{ inputs.weekly && hashFiles('scripts/weekly-puzzle.js') != '' }}
if: ${{ hashFiles('scripts/weekly-puzzle.js') != '' }}
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