Skip to content

ci(wpt): fail-fast on missing corpus + dedicated CI fetcher with shared cache#2

Merged
chad-loder merged 1 commit into
mainfrom
chore/wpt-corpus-fetcher
May 12, 2026
Merged

ci(wpt): fail-fast on missing corpus + dedicated CI fetcher with shared cache#2
chad-loder merged 1 commit into
mainfrom
chore/wpt-corpus-fetcher

Conversation

@chad-loder
Copy link
Copy Markdown
Owner

Summary

CI's matrix-with-wheel-install reported 82.1% coverage vs 96.7% locally on the same 580-test suite. Root cause: reference/wpt/ is gitignored and not packed into the sdist, so all 469 WPT-corpus tests silently no-op'd in matrix jobs (pytest.skip in conftest, return [] in the data-driven test_wpt_*.py files).

Three changes:

  1. Fail-fast tests. conftest.py, test_wpt_compare.py, test_wpt_generate.py now raise FileNotFoundError instead of silently producing an empty parametrize. A missing corpus is now a loud CI / dev-env error.

  2. New scripts/fetch_wpt_corpus.sh — security-hardened, dedicated to CI. Pinned SHA, HTTPS sparse-clone of just urlpattern/ + resources/, post-fetch SHA verify against the pin, 10 MiB cap on every JSON fixture before json.loads, top-level shape check, --verify mode for re-checking restored caches. umask 022 and hardcoded PATH.

  3. wpt-corpus job in ci.yml. actions/cache keyed on the fetch script's content (bumping WPT_REF rotates the key automatically), uploads as an artifact, test-stable + test-prospective download once per workflow run. Listed in ci-ok's needs so the merge gate fails closed on fetch breakage.

Expected result

If the path-mapping theory is correct, CI's combined coverage should jump from 82.1% to ~96.7% (matching local). The ratchet at 82% stays — separate PR to bump after we confirm the number on green main.

Test plan

  • scripts/fetch_wpt_corpus.sh --verify passes against the local symlinked corpus
  • just test-cov reports 96.7% (1300 stmts, 580 passed, 19 skipped)
  • actionlint .github/workflows/ci.yml clean
  • shellcheck scripts/fetch_wpt_corpus.sh clean
  • CI's wpt-corpus job populates the cache + uploads the artifact
  • test-stable matrix jobs collect all 580 tests (vs ~190 currently)
  • coverage aggregate clears the 82% floor (target: ~96%)
  • CI green aggregate goes green so the ruleset allows merge

…hared cache

The matrix-with-wheel-install run combined to 82.1% coverage (vs 96.7%
locally on the same suite) because ~470 conformance tests were silently
no-op-ing: ``reference/wpt/`` is gitignored and not in the sdist, so
matrix jobs never saw the corpus and ``pytest.skip()`` / ``return []``
swallowed all the test_wpt*.py parametrize. The CI was effectively only
running the 110 non-conformance tests.

Fix has three parts:

* **Tests fail-fast** when the corpus is absent. ``conftest.py``,
  ``test_wpt_compare.py``, and ``test_wpt_generate.py`` now raise
  ``FileNotFoundError`` with an actionable message instead of silently
  collecting zero cases. A missing fixture is a CI / dev-env error,
  not a runtime condition the tests should tolerate.

* **New ``scripts/fetch_wpt_corpus.sh``** — security-hardened, dedicated
  to the CI use case. Pinned ``WPT_REF`` SHA; HTTPS-only sparse-checkout
  of just ``urlpattern/`` + ``resources/``; ``--filter=blob:none`` so
  unrelated blobs never land on the runner; post-fetch
  ``git rev-parse HEAD`` verify against the pin; 10 MiB cap on every
  JSON fixture before ``json.loads`` (defense against a parser-DoS
  surface); top-level shape check (must be a list of objects/strings);
  ``--verify`` mode for re-checking a restored cache. ``umask 022`` and
  a hardcoded ``PATH`` defend against environment manipulation.

* **``ci.yml`` ``wpt-corpus`` job**. Caches by content of the fetch
  script (bumping ``WPT_REF`` rotates the key), uploads the corpus as
  an artifact, and matrix jobs download it once per workflow run. Both
  ``test-stable`` (9 shards) and ``test-prospective`` consume the
  artifact. ``ci-ok`` (the aggregate ``CI green`` status check) lists
  the new job in ``needs`` so the merge gate fails closed if the fetch
  job breaks.

The dev-side ``scripts/fetch_references.sh`` retains its own ``WPT_REF``
duplicate — a comment in the new script flags the lockstep requirement.
@github-actions github-actions Bot added the ci label May 12, 2026
@chad-loder chad-loder merged commit 5ff6761 into main May 12, 2026
19 checks passed
@chad-loder chad-loder deleted the chore/wpt-corpus-fetcher branch May 12, 2026 20:22
chad-loder added a commit that referenced this pull request May 12, 2026
#3)

PR #2 fixed the silent-skip of ~470 conformance tests in the matrix-with-
wheel-install path; CI's combined coverage climbed from 82.1% to 96.7%.
With the matrix now exercising the full suite, the 82 ratchet has no
signal value. Move it to 95 — ~1.7-point headroom below the current run
absorbs cross-OS / cross-Python variation without permitting silent
regressions.

The target stated in the previous ratchet comment was 90% sustained;
we're now well above that, so the ratchet itself becomes the contract.
Future tests should keep coverage at or above 95.

Co-authored-by: chad-loder <26261238+chad-loder@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant