Repository navigation
test: make the e2e coverage artifact renderable without its build - #1040
Conversation
Rendering the published e2e-coverage artifact required the exact build/ that produced it, and that build does not reproduce outside the runner, so the number behind --check-source-regions could not be audited anywhere else. Seal now copies each referenced script and its source map into the run directory, and the reporter prefers those copies over build/. The artifact travels with its own inputs; no workflow change is needed because ci.yml already uploads coverage/e2e/ and already runs the seal step. A script is only captured together with the map it names, so a partial copy can never shadow a usable build/ copy. The sourceLength/sourceSha256 checks still apply to the captured copy, and a script resolvable from no root still fails the report closed rather than rendering on partial data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <quality@hive.kubestellar.io>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
…self-contained-artifact Signed-off-by: quality <quality@hive.kubestellar.io> # Conflicts: # tests/e2e-coverage-report.test.mjs
|
…self-contained-artifact # Conflicts: # tests/e2e-coverage-report.test.mjs
Test Improvement
Rendering the published
e2e-coverageartifact required a byte-identicalbuild/, and that build does not reproduce outside the runner — so the numberbehind
--check-source-regions 80could only be audited by pushing to CI.Confirmed before changing anything. At
main900592b, with the realartifact's chunk and a real
npm run build:e2e:coverage, the reporter abortson the first unresolvable script:
What this changes
tests/tools/e2e-coverage-scripts.mjs(new) — ownsisEligibleScript/scriptPathname(moved out of the reporter so captureand report can never disagree about which scripts matter), plus
resolveScriptInRootandcaptureRunScripts.tests/tools/e2e-coverage-run.mjs—sealCoverageRuncopies everyreferenced script and its source map into
<run>/scripts/before themanifest flips to a sealed status, and records
capturedScripts/uncapturedScriptsas provenance. Capture is opt-in at the library level anddefaults to
buildin the CLI (new optional--build-dir).tests/tools/e2e-coverage-report.mjs—convertScriptresolves eachscript against an ordered root list,
<run>/scriptsfirst andbuild/second, and loads the source map from whichever root matched.
No workflow edit is needed:
ci.ymlalready runs the seal step and alreadyuploads
path: coverage/e2e/, so the copies ship with the existing artifact.Design points
alone would shadow a usable
build/copy with one the reporter cannot map,so a script with no map is left out and listed in
uncapturedScripts.root still aborts the whole report; nothing is skipped to make a number
appear.
sourceLength/sourceSha256still apply to the captured copy, which iswhat makes a self-contained artifact trustworthy rather than merely
convenient. Files are copied via a temporary name and renamed, so a crashed
seal cannot leave a half-written script.
reporter the single place that rejects one — the seal step runs with
if: always()and must not fail on a hostile URL.Verification
TZ=UTC node --test— 1921 passed, 0 failed (1912 before; 9 new tests).npm run test:unit:coverage:check— exit 0.all filesregions94.79% → 94.89%, lines 99.39% → 99.41%;
src filesunchanged at 100.00%lines / 99.84% regions. The new module is 100.00% lines / 94.67% regions.
npx prettier --checkon all five changed files — clean.npm run build:e2e:coveragechunk, deletedbuild/outright, then rendered.The real chunk and its real source map resolved, passed the length and
sha256 checks, and converted through
v8-to-istanbulwith no build present— reaching attribution, which a hand-written single whole-file range cannot
satisfy. Deleting
<run>/scriptsas well restores the originalcoverage script not foundabort, so the fail-closed path is intact.Playwright cannot launch in the environment this was written in
(
libglib-2.0.so.0missing, no root), so no browser capture was executedhere; the
End-to-end coveragejob on this PR exercises the real capture path.This unblocks #1035, which could not be diagnosed locally for exactly this
reason.
Related Issue
Closes #1036
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88