Skip to content

fix: deduplicate coverage blocks in CI workflow#76

Merged
fank merged 1 commit intomainfrom
fix/coverage-dedup-workflow
Feb 3, 2026
Merged

fix: deduplicate coverage blocks in CI workflow#76
fank merged 1 commit intomainfrom
fix/coverage-dedup-workflow

Conversation

@fank
Copy link
Member

@fank fank commented Feb 3, 2026

Summary

Fix incorrect coverage percentages in PR comments caused by a known bug in fgrosse/go-coverage-report (#61).

Problem

When using -coverpkg=./internal/..., Go creates duplicate coverage entries for each code block (one per test package). The action counts these duplicates multiple times instead of merging them, resulting in grossly incorrect percentages.

Example from PR #75:

File Actual Coverage Reported Coverage
v1/builder.go 100% (100/100 statements) 20.96% (267/1274 statements)

The "1274 statements" was actually 100 unique statements × ~13 test packages.

Fix

Add an awk step to merge duplicate coverage blocks before uploading the artifact. For each code block, we keep only the maximum execution count across all duplicates.

Test plan

  • Tested locally: go tool cover -func shows correct 100% coverage after deduplication
  • CI should now report accurate coverage percentages

Fix incorrect coverage percentages in PR comments caused by
fgrosse/go-coverage-report#61. The action counts duplicate coverage
blocks multiple times instead of merging them.

When using -coverpkg=./internal/..., Go creates coverage entries for
each code block for each test package (13 entries per block). The
action was summing these duplicates, showing ~20% coverage for files
that actually have 100% coverage.

The fix adds an awk step to merge duplicate blocks before uploading
the coverage artifact, keeping only the maximum count for each block.
@fank fank merged commit 9027256 into main Feb 3, 2026
3 checks passed
@fank fank deleted the fix/coverage-dedup-workflow branch February 3, 2026 21:03
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