Add Playwright coverage-delta CI gate - #422
Merged
Merged
Conversation
Closes #415. Incident #389 skipped ~190 Playwright tests in one commit with green CI - nothing checked test inventory across a diff, only whether tests that still ran still passed. coverage_delta.py statically parses frontend/tests/**/*.spec.ts titles + skip state at head vs. the PR's merge-base and fails on a removed or newly-skipped title unless .github/coverage-acks.txt carries a matching ack line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #415. Incident: #389 (the
/editorroute swap) skipped ~190 Playwright tests in one commit and CI stayed green — nothing checked test inventory across a diff, only whether the tests that still ran still passed..github/scripts/coverage_delta.pyis a pure static-source parser (no browser, nonpm ci) overfrontend/tests/**/*.spec.ts(mirroringfrontend/tests/perf/being excluded, same asplaywright.config.ts's owntestIgnore):test()title (fulltest.describe(...)-chain-qualified) and its skip state —test.skip,test.describe.skip, or atestInfo.skip(...)call reachable from abeforeEachor the test body itself (the actual pattern Swap Proposal H's unified page onto /editor, redirect /display #389 used file-wide).git show— nogit checkoutof the base ref, the working tree is never touched..github/coverage-acks.txtcarries a matchingcoverage-ack: <test id or glob> — <reason>line — same tether-discipline shape asdocs_lint.py's in-fileALLOWLIST. New tests and un-skipping are always fine.Wired as
coverage-delta.yml, a standalone workflow (two jobs: parser/diff unit tests, then the real gate) on everypull_request— deliberately no path filter, so the trigger itself can't reintroduce the blind spot this gate exists to close. It's pure stdlib Python with no install step, so the always-run cost is low.docs/infrastructure.md's CI/CD state list gets a new bullet for this workflow in the same change.Verification
Parser accuracy vs. the real Playwright test suite (
npx playwright test --list): 315 real (runtime-expanded) tests vs. 307 static manifest entries — the entire 8-test delta is exactly the 4 template-literal-titled loop call sites this parser deliberately collapses to one static entry each (documented as a known limitation in the script's own docstring); zero unexplained mismatches. Skip-state cross-check: the parser found exactly the 8 files / 36 tests using the realtestInfo.skip(true, "...")beforeEachpattern in the repo today (CardImageStates,DeckbuilderConfirmAffordance,PDFGenerator,PagePreview,PostExportContributionPrompt,ProjectEditorMobileScroll,SelectedImagesRibbon,CommonCardback.visual) — matched by hand viagrepfirst.Two synthetic proof cases, run locally against this repo (temporary edits to
frontend/tests/AddCardToFavorites.spec.ts, reverted before commit — not part of this diff):Case 1 — renamed (= removed) a test title, Case 2 — added
test.skip(...)to another test in the same file:Exit code 2. Adding a matching
coverage-ack:line for that file then re-running: both violations flip toACKED, exit code 0.Unit tests:
python3 .github/scripts/tests/test_coverage_delta.py— 25 tests (parser fixtures for nesting/describe.skip/test.skip/inlinetestInfo.skip/dynamic titles, ack loading + glob matching, diff-logic cases, and a real scratch-git-repo end-to-end integration suite that includes the two synthetic cases above as permanent regression coverage) — all pass.Real repo, unchanged: gate run against
origin/masterwith no edits — clean, exit 0.docs_lint.py --strictclean.pre-commit runon all new/changed files (ruff, isort, black, mypy, prettier, yaml-check) — all pass.Not run: no full
npx playwright testexecution (not needed — this is a static source-inventory check with no dependency on actually running the suite).Checklist
pre-commitand installed the hooks withpre-commit installbefore creating any commits.