fix(coverage): make the patch gate visible and correct under a --dir subdirectory#24
Merged
Merged
Conversation
…subdirectory Two fixes to how the patch gate lines up with what Codecov reports for the same diff (wardnet/wardnet#957 shipped a green bulwark summary next to a red codecov/patch computed from the very same lcov export): - ChangedLines now passes --relative: run from a --dir subdirectory it emitted repo-root-relative paths, which matched no crate/package prefix, so every changed line silently vanished from the patch denominator and the gate measured nothing. --relative also scopes the diff to --dir, which is the gate's remit anyway. - A detected language whose files the diff touches but whose per-line source is unresolved is now reported as an [UNMEASURED] patch line (plus a stderr hint naming the missing wiring) instead of being skipped in silence — a gate that didn't run must be distinguishable from a gate that passed. Scoped to detected ecosystems so a stray changed file of a language the repo doesn't use stays silent, and never a failure on its own, mirroring the aggregate gate's [UNMEASURED] handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivated by wardnet/wardnet#957: bulwark posted a green summary (rust aggregate flat at 86.4%) while codecov/patch failed the very same diff at 83.21% — computed from the very same lcov export our pipeline produced. Two defects let that happen, both fixed here.
ChangedLineswas repo-root-relative; everything else is--dir-relative. Thegit diffruns inside--dir, but git emits paths relative to the repository root, so with--dir sourceevery changed file came back assource/daemon/...while the crate/package prefixes (and lcov normalization, and the Go module) all work in--dir-relative terms. Nothing matched, the patch denominator was empty, and the gate silently measured nothing.--relativefixes the paths and also scopes the diff to--dir, which is the gate's remit anyway — changes outside--diraren't measured, so they can't be gated. Regression test drives a real repo from a subdirectory and asserts the dir-relative key plus exclusion of an outside-dir change.A skipped patch gate now says so. When a detected language's patch gate is enabled and the diff touches that language's files but no per-line source was resolved (no lcov for the crate, no
lcovreporter in a TS package),patchReportused tocontinue— indistinguishable in the PR comment from "patch coverage passed". It now prints an[UNMEASURED] <lang> patch: ...line (which the action's generic bracketed-tag grep already picks up, noaction.ymlchange needed) plus a stderr warning naming the missing wiring per language. Never a failure on its own, mirroring the aggregate gate's[UNMEASURED]handling. Scoped to detected ecosystems so the default-enabled gates don't produce lines for a stray changed file of a language the repo doesn't use.Verified end-to-end against a wardnet-shaped fixture (subdirectory
--dir, seededbulwark-statebaseline,--tests=skip): with the lcov present the gate now computes and fails an uncovered new line (rust patch: 0.0% (0/1 new lines; baseline 86.4%)); with it missing, the run stays green but reports[UNMEASURED]with the hint.go test -race ./...green; docs updated in AGENTS.md.The companion wiring on the consumer side is wardnet/wardnet's coverage workflow (restoring the lcov exports and passing
rust-lcov-report); a release needs to be cut here for consumers to pick this up, since the action installs the latest release binary.Generated by Claude Code