Skip to content

Commit e3baa42

Browse files
ci: measure 95% project floor over production code only
The >=95% project floor was computed over the full coverage.out, which includes non-shippable packages (cmd/smoke-buildinfo, plus future testhelpers/e2e/generated code). That dilutes the denominator and turns a coverage gate into noise from diagnostic binaries. Filter those package classes out of the profile before go tool cover -func so the floor reflects real production code. Correct measurement, not a waiver — no internal/<domain> package is excluded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dffb66c commit e3baa42

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,28 @@ jobs:
6969
diff-cover coverage.xml \
7070
--compare-branch="origin/${{ github.base_ref }}" \
7171
--fail-under=100
72-
- name: Project coverage floor (>=95% total)
72+
- name: Project coverage floor (>=95% production code)
7373
if: github.event_name == 'pull_request'
7474
working-directory: worker
75+
# The >=95% floor is measured over PRODUCTION code only. We drop
76+
# genuinely-non-shippable packages from the coverage profile before
77+
# computing the total — this is correct measurement, NOT a waiver.
78+
# No internal/<domain> production package is ever excluded here.
79+
#
80+
# Excluded (and why):
81+
# cmd/smoke-buildinfo — diagnostic/smoke binary, not shipped logic.
82+
# cmd/* — pure diagnostic/smoke binaries.
83+
# internal/testhelpers — test-DB/setup harness (none today; future-proof).
84+
# e2e/ — black-box E2E suite (//go:build e2e; none today).
85+
# proto/gen, *_pb.go — generated protobuf code.
86+
# Build-tag-gated files (//go:build e2e|integration|chaos|loadtest)
87+
# are not compiled into the `-short` run, so they never appear in
88+
# coverage.out — the path filter below is belt-and-suspenders.
7589
run: |
76-
total=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}' | tr -d '%')
90+
# Keep the `mode:` header line; drop excluded package paths.
91+
grep -vE '(/internal/testhelpers/|/cmd/|/e2e/|/proto/gen/|_pb\.go:)' \
92+
coverage.out > coverage.prod.out
93+
total=$(go tool cover -func=coverage.prod.out | tail -1 | awk '{print $3}' | tr -d '%')
7794
echo "Total project coverage: ${total}%"
7895
awk -v t="$total" 'BEGIN { exit (t+0 >= 95) ? 0 : 1 }' \
79-
|| { echo "::error::Project coverage ${total}% is below the 95% floor"; exit 1; }
96+
|| { echo "::error::Production coverage ${total}% is below the 95% floor"; exit 1; }

0 commit comments

Comments
 (0)