Skip to content

Report test coverage in the CI run summary - #46

Merged
jstayton merged 1 commit into
developmentfrom
coverage-report
Aug 27, 2026
Merged

Report test coverage in the CI run summary#46
jstayton merged 1 commit into
developmentfrom
coverage-report

Conversation

@jstayton

Copy link
Copy Markdown
Collaborator

npm test runs node --test with no coverage flags, so seeing coverage meant passing --experimental-test-coverage by hand. This adds a separate Test coverage job that posts the report to the run summary and uploads coverage/lcov.info as a coverage artifact — the same shape as the job in vision-download: https://github.com/TRUEPIC/vision-download/actions/runs/33080309557

No thresholds. Coverage is reported, not enforced.

It uses Node's built-in --experimental-test-coverage with the lcov reporter rather than nyc or c8, so nothing new is added to the dependency tree. The job runs once on 26.x instead of across the 22/24/26 matrix, so the run gets one summary rather than three; the existing Lint & test job is untouched.

Two things in the diff that look incidental but aren't:

set -o pipefail in the reporting step — npm run test:coverage | tee returns tee's exit status, not npm's. I checked with a deliberately failing test: exit 0 without it, exit 1 with it. Without that line the coverage job reports green on a broken suite.

pretest:coverage — the lcov reporter won't create its destination directory, it exits 7 on a missing coverage/. The pre-hook does the mkdirSync rather than a shell mkdir -p, so it stays portable.

Rendered summary looks like this:

----------------------------------------------------------
file      | line % | branch % | funcs % | uncovered lines
----------------------------------------------------------
src       |        |          |         |
 error.js | 100.00 |   100.00 |  100.00 |
 main.js  | 100.00 |   100.00 |  100.00 |
----------------------------------------------------------
all files | 100.00 |   100.00 |  100.00 |
----------------------------------------------------------

🤖 Generated with Claude Code

`npm test` runs `node --test` with no coverage flags, so seeing coverage
meant passing `--experimental-test-coverage` by hand.

A separate `Test coverage` job now posts the report to the run summary
and uploads `coverage/lcov.info` as an artifact, following the same shape
as vision-download. There's no threshold — coverage is reported, not
enforced. Node's built-in coverage plus the `lcov` reporter keep this
dependency-free.

`set -o pipefail` is load-bearing in that step: `npm run test:coverage |
tee` otherwise returns tee's exit status, so the job would pass on a
failing suite. `pretest:coverage` creates `coverage/` because the lcov
reporter exits rather than creating it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jstayton
jstayton merged commit 27175c9 into development Aug 27, 2026
5 checks passed
@jstayton
jstayton deleted the coverage-report branch August 27, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant