Skip to content

fix(coverage): emit coverage report when tests fail#84

Merged
topcoder1 merged 1 commit into
mainfrom
ci/coverage-floor-reportonfailure
May 24, 2026
Merged

fix(coverage): emit coverage report when tests fail#84
topcoder1 merged 1 commit into
mainfrom
ci/coverage-floor-reportonfailure

Conversation

@topcoder1

Copy link
Copy Markdown
Owner

Summary

  • Add reportOnFailure: true to vitest's coverage config so coverage/coverage-summary.json gets written even when tests fail.
  • Without this, the Coverage Floor reusable fails with no coverage/coverage-summary.json produced on every PR that has even one flaky test (the workflow's || true on vitest --coverage swallows the exit code, but vitest never wrote the file in the first place).

Why now

Coverage Floor has been failing on every nanoclaw PR since 2026-05-24 (one test in src/brain/__tests__/wiki-projection.test.ts started failing intermittently — fixing it is a separate task). PR #83 was admin-bypass-merged for this same reason. With this fix, Coverage Floor will produce a real measurement regardless of test failures, and the main-protection required check can gate PRs cleanly.

Repro / verification

Locally with the prior config (no reportOnFailure):

$ npx vitest run --coverage  # 3 test files fail
$ ls coverage/
ls: coverage: No such file or directory

With the fix:

$ npx vitest run --coverage  # same 3 test files fail
$ jq '.total.lines' coverage/coverage-summary.json
{ "total": 14258, "covered": 10277, "skipped": 0, "pct": 72.07 }

Above the current floor of 70.8 — no recalibration needed.

Auto-merge rationale

Trivial test-config tweak (1 option in vitest.config.ts). Not in any high-risk surface (no auth/secrets/migrations/billing/destructive ops/prod infra/customer-facing copy).

Codex pre-review

Skipped — 1-line config change (5 LOC including comment), far below the threshold.

Test plan

  • CI confirms Coverage Floor reports a measured coverage: value (not the no coverage-summary.json error)
  • Coverage Floor check passes (measured ≥ 70.8 floor)

🤖 Generated with Claude Code

Add `reportOnFailure: true` to vitest's coverage config. Without it,
vitest skips writing `coverage/coverage-summary.json` when any test
fails — which makes the Coverage Floor workflow fail with "no
coverage-summary.json produced" on every PR with even one flaky test.

The Coverage Floor reusable uses `npm test -- --coverage || true` to
tolerate vitest's non-zero exit, but the `|| true` can't recover a file
that vitest never wrote. The fix is on the caller side.

Reproduced locally: with this flag set, `vitest run --coverage` writes
`coverage/coverage-summary.json` (lines: 72.07%) even when 3 tests fail.

This unblocks the main-protection ruleset's `coverage-floor` required
check so PRs can land without admin bypass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@topcoder1 topcoder1 enabled auto-merge (squash) May 24, 2026 05:45
@github-actions github-actions Bot added risk:standard Risk class: standard labels May 24, 2026
@claude

claude Bot commented May 24, 2026

Copy link
Copy Markdown

No issues found. Single config-option change with no logic, auth, or safety surface — the coverage/CI interaction is intentional and correctly described.

@github-actions

Copy link
Copy Markdown

Coverage Floor — mode: enforce

metric value
measured 71.3%
floor (current) 70.8%
target 80.0%
last bumped 2026-05-22

@topcoder1 topcoder1 merged commit 9b1217e into main May 24, 2026
14 of 15 checks passed
@topcoder1 topcoder1 deleted the ci/coverage-floor-reportonfailure branch May 24, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:standard Risk class: standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant