fix: exclude examples directory from code coverage reports#43
Merged
miclle merged 3 commits intofox-gonic:mainfrom Dec 8, 2025
Merged
fix: exclude examples directory from code coverage reports#43miclle merged 3 commits intofox-gonic:mainfrom
miclle merged 3 commits intofox-gonic:mainfrom
Conversation
- Add .codecov.yml configuration file - Set coverage precision and range (70-100%) - Configure project and patch coverage thresholds - Enable coverage comments on PRs - Ignore test files and examples - Update GitHub Actions workflow - Add codecov/codecov-action@v5 step - Upload coverage.txt after tests - Only upload from ubuntu-latest to avoid duplicates - Use CODECOV_TOKEN secret for authentication This enables automatic coverage reporting on PRs and commits, making it easier to track test coverage changes.
This commit addresses the discrepancy between local coverage (57.3%) and actual code coverage (90.6%) by properly excluding the examples directory from coverage reports. Changes: - Makefile: Add post-test filtering to remove examples/ from coverage.txt - GitHub Workflow: Add dedicated filtering step before Codecov upload - .gitignore: Add patterns to ignore temporary coverage files (coverage*.txt, coverage*.html, coverage*.out) Impact: - Coverage reports now accurately reflect actual code coverage (~90%) instead of including untested example code - Aligns with existing .codecov.yml ignore configuration - Temporary coverage files no longer tracked in git
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #43 +/- ##
===========================================
+ Coverage 49.30% 87.87% +38.57%
===========================================
Files 23 16 -7
Lines 1294 726 -568
===========================================
Hits 638 638
+ Misses 638 70 -568
Partials 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Summary
This PR fixes the code coverage reporting by properly excluding the
examples/directory from coverage calculations. Previously, the coverage badge showed 49% (Codecov) and 57.3% (local) due to including untested example code. After this fix, coverage accurately reflects ~90.6%.Problem
go test -coverprofile=coverage.txt ./...was including all files in theexamples/directory (191 lines of untested code).codecov.ymlconfigured to ignore examples, the coverage file already contained the dataChanges
1. Makefile (
Makefile:47-48)Added post-test filtering to remove examples from coverage.txt:
```bash
@echo "Filtering coverage to exclude examples..."
@grep -v "examples/" coverage.txt > coverage_filtered.txt && mv coverage_filtered.txt coverage.txt || true
```
2. GitHub Workflow (
.github/workflows/go.yml:71-79)Added dedicated filtering step before Codecov upload:
```yaml
if: matrix.os == 'ubuntu-latest'
run: |
if [ -f coverage.txt ]; then
grep -v "examples/" coverage.txt > coverage_filtered.txt || true
if [ -s coverage_filtered.txt ]; then
mv coverage_filtered.txt coverage.txt
fi
fi
```
3. Gitignore (
.gitignore:24-26)Added patterns to ignore temporary coverage files:
```gitignore
coverage*.txt
coverage*.html
coverage*.out
```
Impact
Test Plan
make test→ Coverage shows 90.6%grep -c "examples/" coverage.txt→ 0Verification
After merge, the Codecov badge should update from 49% to approximately 90%.