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:
parent
7a6eb29013
commit
0342d90657
17 changed files with 244 additions and 109 deletions
49
.github/workflows/auto-release.yml
vendored
49
.github/workflows/auto-release.yml
vendored
|
|
@ -20,18 +20,19 @@ concurrency:
|
|||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
outputs:
|
||||
skip: ${{ steps.v.outputs.skip }}
|
||||
ver: ${{ steps.v.outputs.ver }}
|
||||
tag: ${{ steps.v.outputs.tag }}
|
||||
pre: ${{ steps.v.outputs.pre }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
|
||||
- name: Work out the version and whether it is new
|
||||
id: v
|
||||
|
|
@ -57,34 +58,40 @@ jobs:
|
|||
case "$ver" in *-*) echo "pre=true" >> "$GITHUB_OUTPUT";; *) echo "pre=false" >> "$GITHUB_OUTPUT";; esac
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Test before releasing
|
||||
if: steps.v.outputs.skip == 'false'
|
||||
run: npm ci && npm test
|
||||
# The same tests as every push, split over several runners (ci.yml), before anything is tagged.
|
||||
tests:
|
||||
needs: check
|
||||
if: needs.check.outputs.skip == 'false'
|
||||
uses: ./.github/workflows/ci.yml
|
||||
|
||||
release:
|
||||
needs: [check, tests]
|
||||
if: needs.check.outputs.skip == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.check.outputs.tag }}
|
||||
VER: ${{ needs.check.outputs.ver }}
|
||||
PRE: ${{ needs.check.outputs.pre }}
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Publish the release
|
||||
if: steps.v.outputs.skip == 'false'
|
||||
env:
|
||||
TAG: ${{ steps.v.outputs.tag }}
|
||||
VER: ${{ steps.v.outputs.ver }}
|
||||
PRE: ${{ steps.v.outputs.pre }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
awk -v v="$VER" 'index($0,"## ["v"]")==1{f=1;next} /^## \[/{f=0} f' CHANGELOG.md | sed -e '/./,$!d' > notes.md
|
||||
pre=(); [ "$PRE" = "true" ] && pre=(--prerelease)
|
||||
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" \
|
||||
--target "$GITHUB_SHA" --title "$VER" --notes-file notes.md "${pre[@]}"
|
||||
|
||||
- name: Deploy it
|
||||
# Pre-releases are for testing and never go live.
|
||||
if: steps.v.outputs.skip == 'false' && steps.v.outputs.pre == 'false'
|
||||
env:
|
||||
TAG: ${{ steps.v.outputs.tag }}
|
||||
run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG"
|
||||
# Pre-releases are for testing and never go live. The tag was just tested above, so the deploy does not
|
||||
# test it again (tested=true).
|
||||
if: env.PRE == 'false'
|
||||
run: gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG" -f tested=true
|
||||
|
||||
- name: Publish the Docker image
|
||||
# Same pattern as the deploy above: the image is built and pushed from the
|
||||
# release tag by docker.yml. Pre-releases get one too: an image tag is
|
||||
# pulled on purpose, so a test image costs nothing.
|
||||
if: steps.v.outputs.skip == 'false'
|
||||
env:
|
||||
TAG: ${{ steps.v.outputs.tag }}
|
||||
run: gh workflow run docker.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG" -f tag="$TAG"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue