Skip to content

ci: report Rust and web test coverage on pull requests - #49

Merged
AshDevFr merged 1 commit into
mainfrom
ci/coverage-report
Oct 2, 2026
Merged

AshDevFr merged 1 commit into
mainfrom
ci/coverage-report

Conversation

@AshDevFr

@AshDevFr AshDevFr commented Oct 2, 2026

Copy link
Copy Markdown
Owner

What this adds

  • Rust coverage job (Coverage (Rust)): cargo llvm-cov nextest --workspace --features rar on its own runner, writing an lcov file and a JSON summary. Test code (tests/) is excluded so the figures describe the code under test.
  • Web coverage: the frontend job now runs npm run test:coverage (Vitest's v8 provider, now actually installed). coverage.include covers all of src, so a module no test imports counts against the total instead of being invisible.
  • Coverage Report job: collates both into the job summary and one pull-request comment, edited in place (same pattern as the API contract report). Per-crate line, function and region coverage for Rust; lines, statements, functions and branches for web.
  • Artifacts: coverage-rust and coverage-web (lcov plus summaries), kept for 14 days.

Design choices

  • Reports only, never fails the run. A failing test does not fail the coverage job (the test partitions already report it); the numbers are still written. A missing report renders as "no report" instead of a second red check.
  • Separate runner. Instrumented binaries are slower, so coverage runs in parallel and the partitioned test jobs are untouched.
  • @vitest/coverage-v8 pinned to the locked Vitest (4.0.18) so adding it does not move the test runner. The lockfile otherwise only adds the provider's dependencies and patch-bumps a few @babel/* parser packages it needs.
  • No external service. Nothing leaves GitHub, which also means no history across commits and no diff coverage against main. Codecov or similar can be added later if trends become worth the third-party upload.

Cost

One extra instrumented run of the backend suite per PR, in parallel with the existing jobs.

Verified locally

  • npm run test:coverage: all tests pass; coverage-summary.json and lcov.info produced (web totals: lines 64.0%, statements 63.4%, functions 52.0%, branches 58.2%). npm run lint clean, npm run build succeeds.
  • cargo llvm-cov on codex-utils with the same report flags as CI, then .github/scripts/coverage-summary.sh on the real Rust and web outputs: renders the per-crate and web tables. The script was also checked with missing inputs.
  • The full workspace under coverage has not been run locally; this PR's own CI run is the first end-to-end check, and its comment will show the real numbers.

Nothing in CI showed how much of the code the tests exercise, so a PR
could drop coverage without anyone noticing.

Rust coverage runs in its own job with cargo-llvm-cov and nextest. The
instrumented build is slower, and a separate runner keeps the
partitioned test jobs unchanged. Test code is excluded from the figures
so they describe the code under test. A failing test does not fail this
job, because the partitions already report that; the numbers are still
written.

Web coverage comes from Vitest's v8 provider, which the frontend job now
runs in place of the plain test command. The provider is pinned to the
locked Vitest version so adding it does not move the test runner.
Coverage `include` covers all of src, so a module no test imports counts
against the total instead of being invisible.

A report job collates both into the job summary and a single pull
request comment that is edited in place, the same way the API contract
report is. It only reports and never fails the run. The summary is
rendered by a small script that tolerates a missing input, so a broken
test job shows up as "no report" rather than a second red check. The
lcov files are kept as artifacts for 14 days.

There is no external coverage service, so no history is kept across
commits.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying codex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 78daf0c
Status: ✅  Deploy successful!
Preview URL: https://60f5f2a4.codex-asm.pages.dev
Branch Preview URL: https://ci-coverage-report.codex-asm.pages.dev

View logs

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

API contract changes

Compared against main. These are changes a client generated from the
previous document would notice. Not a failure: breaking changes are a
release-time decision, and make release-prepare checks the bump against
them when the version is chosen.

Report
No breaking changes

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Coverage

Backend (Rust)

Crate Lines Functions Regions
codex 47.6% 56.1% 47.5%
Total 47.6% 56.1% 47.5%

Frontend (web)

Lines Statements Functions Branches
64.0% 63.4% 52.0% 58.2%

Line-level reports (lcov) are attached to the workflow run as the coverage-rust and coverage-web artifacts.

@AshDevFr
AshDevFr merged commit fe18224 into main Oct 2, 2026
26 checks passed
@AshDevFr
AshDevFr deleted the ci/coverage-report branch October 2, 2026 22:16
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