Your Coverage. Your Infrastructure. Pure Go.
CI / CD Β Β
|
|
Β Β Β Β Quality Β Β
|
|
Security Β Β
|
|
Β Β Β Β Community Β Β
|
|
β‘Β Installation
|
π§ͺΒ ExamplesΒ &Β Tests
|
πΒ Documentation
|
π€Β Contributing
|
π οΈΒ CodeΒ Standards
|
β‘Β Performance
|
π€Β AIΒ Usage
|
πΒ License
|
π₯Β Maintainers
|
Go Coverage is a complete replacement for Codecov that runs entirely in your CI/CD pipeline with zero external dependencies. Get coverage reports, badges, and dashboards deployed to GitHub Pages automatically.
Go Coverage requires a supported release of Go.
Install CLI Tool (recommended):
go install github.com/mrz1836/go-coverage/cmd/go-coverage@latestOr install go-coverage as a Library:
go get -u github.com/mrz1836/go-coverageVerify Installation:
go-coverage --version
# go-coverage version v1.0...Upgrade to Latest Version:
# Check for available updates
go-coverage upgrade --check
# Upgrade to the latest version
go-coverage upgrade
# Force reinstall even if already on latest
go-coverage upgrade --forceInstall MAGE-X build tool for development:
# Install MAGE-X for development and building
go install github.com/mrz1836/mage-x/cmd/magex@latest
magex update:installOption 1: Internal Coverage System (GitHub Pages) - Recommended
Set up GitHub Pages environment for coverage deployment:
go-coverage setup-pagesOption 2: External Coverage System (Codecov)
Create .github/.env.custom with:
GO_COVERAGE_PROVIDER=codecov
CODECOV_TOKEN_REQUIRED=trueNext, deploy to your main branch and generate coverage reports!
- π·οΈ SVG Badge Generation β Custom badges with themes and logos
- π HTML Reports & Dashboards β Beautiful, responsive coverage visualizations
- π History & Trends β Track coverage changes over time
- π€ GitHub Integration β PR comments, commit statuses, automated deployments
- π GitHub Pages β Automated deployment with zero configuration
- π§ Highly Configurable β Thresholds, exclusions, templates, and more
- β¬οΈ Auto-Upgrade β Built-in upgrade command for easy updates
Automatic Deployment: Go Coverage automatically deploys coverage reports, badges, and dashboards to GitHub Pages with zero configuration.
Set up GitHub Pages environment using the integrated CLI command:
# Auto-detect repository from git remote
go-coverage setup-pages
# Or specify repository explicitly
go-coverage setup-pages owner/repo
# Preview changes without making them
go-coverage setup-pages --dry-run
# Use a custom domain for GitHub Pages
go-coverage setup-pages --custom-domain mysite.comThis configures:
- β GitHub Pages Environment with proper branch policies
- β
Deployment Permissions for
master,gh-pages, and any*/*/*/*/*/*branches - β Environment Protection rules for secure deployments
Your coverage system automatically creates:
https://yourname.github.io/yourrepo/
βββ coverage.svg # Live coverage badge
βββ index.html # Coverage dashboard
βββ coverage.html # Detailed coverage report
βββ reports/branch/master/ # Branch-specific reports
Manual GitHub Pages Configuration
If the setup command fails, manually configure:
- Go to Settings β Environments β github-pages
- Under Deployment branches, select "Selected branches and tags"
- Add these deployment branch rules:
master(main deployments)gh-pages(GitHub Pages default)*,*/*,*/*/*,*/*/*/*,*/*/*/*/*,*/*/*/*/*/*(all branches for PR-specific reports)
- Save changes and verify in workflow runs
The coverage system integrates with your existing GitHub Actions:
# In your .github/workflows/ci.yml
- name: Generate Coverage Report
run: |
go test -coverprofile=coverage.txt ./...
go-coverage complete -i coverage.txtgo install github.com/mrz1836/go-coverage/cmd/go-coverage@latest# Use the integrated command (requires gh CLI)
go-coverage setup-pagesAdd coverage generation to your workflow:
name: Coverage
on: [push, pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Run Tests with Coverage
run: go test -coverprofile=coverage.txt ./...
- name: Generate Coverage Reports
run: go-coverage complete -i coverage.txt -o coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverageCommit and push - your coverage reports will be available at:
- Reports:
https://yourname.github.io/yourrepo/ - Badge:
https://yourname.github.io/yourrepo/coverage.svg
Advanced Configuration
Create a .go-coverage.json config file:
{
"coverage": {
"threshold": 80.0,
"exclude_paths": ["vendor/", "test/"],
"exclude_files": ["*.pb.go", "*_gen.go"]
},
"badge": {
"style": "flat",
"logo": "go"
},
"report": {
"title": "My Project Coverage",
"theme": "dark"
},
"history": {
"enabled": true,
"retention_days": 90
}
}- β‘ Quickstart β Get started in 5 minutes with installation and basic setup
- π User Guide β Complete usage guide with examples and workflows
- π οΈ CLI Reference β Detailed command-line reference and options
- βοΈ Configuration β Environment variables and configuration options
- CLI Reference β Complete command documentation at pkg.go.dev/github.com/mrz1836/go-coverage
- π€ Contributing β How to contribute code, tests, and documentation
- ποΈ Architecture β Technical architecture and design decisions
- Coverage Analysis β Parse Go coverage profiles with exclusions and thresholds
- Badge Generation β Create SVG badges with custom styling and themes
- Report Generation β Build HTML dashboards and detailed coverage reports
- History Tracking β Monitor coverage trends over time with retention policies
- GitHub Integration β PR comments, commit statuses, and automated deployments
Go Coverage Features
- Zero External Dependencies β Complete coverage system that runs entirely in your CI/CD pipeline with no third-party services required.
- GitHub Pages Integration β Automatic deployment of coverage reports, badges, and dashboards with branch-specific and PR-specific deployments.
- Advanced Coverage Analysis β Parse Go coverage profiles with support for path exclusions, file pattern exclusions, and threshold enforcement.
- Professional Badge Generation β SVG coverage badges with customizable styles, colors, logos, and themes that update automatically.
- Rich HTML Reports β Beautiful, responsive coverage dashboards with detailed file-level analysis and interactive visualizations.
- Coverage History & Trends β Track coverage changes over time with retention policies, trend analysis, and historical comparisons.
- Smart GitHub Integration β Automated PR comments with coverage analysis, commit status checks, and diff-based coverage reporting.
- Multi-Branch Support β Separate coverage tracking for different branches with automatic main branch detection and PR context handling.
- Comprehensive CLI Tool β Six powerful commands (
complete,comment,parse,history,setup-pages,upgrade) for all coverage operations. - Highly Configurable β JSON-based configuration for thresholds, exclusions, badge styling, report themes, and integration settings.
- Enterprise Ready β Built with security, performance, and scalability in mind for production environments.
- Self-Contained Deployment β Everything runs in your repository's
.githubfolder with no external service dependencies or accounts required.
Library Deployment
This project uses goreleaser for streamlined binary and library deployment to GitHub. To get started, install it via:
brew install goreleaserThe release process is defined in the .goreleaser.yml configuration file.
Then create and push a new Git tag using:
magex version:bump push=true bump=patchThis process ensures consistent, repeatable releases with properly versioned artifacts and citation metadata.
Build Commands
View all build commands
magex helpGitHub Workflows
All GitHub Actions workflows in this repository are powered by a flexible two-file configuration system β your one-stop shop for tweaking CI/CD behavior without touching a single YAML file! π―
Configuration Files:
- .env.base β Default configuration that works for most Go projects
- .env.custom β Optional project-specific overrides
This powerful system controls everything from:
- π Go version matrix (test on multiple versions or just one)
- π Runner selection (Ubuntu or macOS, your wallet decides)
- π¬ Feature toggles (coverage, fuzzing, linting, race detection, benchmarks)
- π‘οΈ Security tool versions (gitleaks, nancy, govulncheck)
- π€ Auto-merge behaviors (how aggressive should the bots be?)
- π·οΈ PR management rules (size labels, auto-assignment, welcome messages)
Pro tip: Want to disable code coverage? Create
.env.customwithENABLE_CODE_COVERAGE=falseand push. No YAML archaeology required!
| Workflow Name | Description |
|---|---|
| auto-merge-on-approval.yml | Automatically merges PRs after approval and all required checks, following strict rules. |
| codeql-analysis.yml | Analyzes code for security vulnerabilities using GitHub CodeQL. |
| dependabot-auto-merge.yml | Automatically merges Dependabot PRs that meet all requirements. |
| fortress.yml | Runs the Go Coverage security and testing workflow, including linting, testing, releasing, and vulnerability checks. |
| pull-request-management.yml | Labels PRs by branch prefix, assigns a default user if none is assigned, and welcomes new contributors with a comment. |
| scorecard.yml | Runs OpenSSF Scorecard to assess supply chain security. |
| stale.yml | Warns about (and optionally closes) inactive issues and PRs on a schedule or manual trigger. |
| sync-labels.yml | Keeps GitHub labels in sync with the declarative manifest at .github/labels.yml. |
Updating Dependencies
To update all dependencies (Go modules, linters, and related tools), run:
magex deps:updateThis command ensures all dependencies are brought up to date in a single step, including Go modules and any tools managed by MAGE-X. It is the recommended way to keep your development environment and CI in sync with the latest versions.
π§ Pre-commit Hooks
Set up the Go-Pre-commit System to run the same formatting, linting, and tests defined in AGENTS.md before every commit:
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
go-pre-commit installThe system is configured via .env.base and can be customized using also using .env.custom and provides 17x faster execution than traditional Python-based pre-commit hooks. See the complete documentation for details.
The Go Coverage system is thoroughly tested via GitHub Actions and uses Go version 1.24.x. View the configuration file.
# Complete coverage pipeline (parse + badge + report + history + GitHub)
go-coverage complete -i coverage.txt -o coverage-reports
# Generate PR comment with coverage analysis
go-coverage comment --pr 123 --coverage coverage.txt --base-coverage base-coverage.txt
# Parse coverage data with exclusions
go-coverage parse -i coverage.txt --exclude-paths "vendor/,test/" --threshold 80
# View coverage history and trends
go-coverage history --branch master --days 30 --format json
# Set up GitHub Pages environment for coverage deployment
go-coverage setup-pages --verbose --dry-run
go-coverage setup-pages owner/repo --custom-domain example.com
# Upgrade to the latest version
go-coverage upgrade --check
go-coverage upgrade --force --verboseRun all tests (fast):
magex testRun all tests with race detector (slower):
magex test:race㪠Fuzz Testing
The coverage system includes comprehensive fuzz tests for critical functions to ensure robustness and security:
| Package | Functions Tested | Coverage | Security Focus |
|---|---|---|---|
| urlutil | URL building, path cleaning | 100% | Path traversal, XSS prevention |
| badge | Badge generation, color selection | 97.7% | SVG injection, encoding |
| parser | Coverage parsing, file exclusion | 84.1% | Malformed input handling |
# Run specific fuzz tests
go test -fuzz=FuzzBuildGitHubCommitURL -fuzztime=10s ./internal/urlutil/
go test -fuzz=FuzzGetColorForPercentage -fuzztime=10s ./internal/badge/
go test -fuzz=FuzzParseStatementSimple -fuzztime=10s ./internal/parser/
# Run all fuzz tests (via MAGE-X)
magex test-fuzz- β Comprehensive Input Coverage: Valid inputs, edge cases, malformed data
- β Security Testing: Path traversal, XSS, injection attempts, null bytes
- β Panic Prevention: Never panics on any input
- β Unicode Support: Proper UTF-8 handling and validation
- β Performance Testing: Long inputs, memory efficiency
The system generates comprehensive coverage reports:
π Coverage Dashboard: https://yourname.github.io/yourrepo/
π·οΈ Coverage Badge: https://yourname.github.io/yourrepo/coverage.svg
π Coverage: 87.4% (1,247/1,426 lines)
π¦ Packages: 15 analyzed
π Trend: UP (+2.3% from last run)
The Go Coverage system is optimized for speed and efficiency in CI/CD environments.
magex benchβ‘ Benchmark Results & Performance Metrics
| Component | Operation | Time/op | Memory/op | Allocs/op | Description |
|---|---|---|---|---|---|
| Parser | Parse (100 files) | 105.9ns | 8B | 0 | Parse coverage data with 100 files |
| Parser | Parse (1000 files) | 14.4ms | 8.0MB | 106,870 | Large coverage files |
| Badge | Generate SVG | 1.76Β΅s | 2.5KB | 14 | Badge generation |
| Badge | Generate with Logo | 1.82Β΅s | 2.7KB | 15 | Badge with custom logo |
| Dashboard | Generate HTML | 12.3ms | 1.4MB | 10,645 | Full dashboard generation |
| Report | Generate Report | 8.17ms | 1.1MB | 7,890 | Coverage report generation |
| History | Record Entry | 240Β΅s | 9.2KB | 68 | Store coverage entry |
| History | Get Trend (30 days) | 1.7ms | 255KB | 1,254 | Trend analysis |
| Analysis | Compare Coverage | 20.4Β΅s | 42KB | 146 | Coverage comparison |
| Templates | Render PR Comment | 38.9Β΅s | 11KB | 377 | Comment generation |
| URL | Build GitHub URL | 50.1ns | 48B | 1 | URL construction |
- Concurrent Operations: All critical paths support concurrent execution
- Memory Efficiency: Streaming parsers for large files
- Caching: Template compilation and static asset caching
- Optimization: Profile-guided optimizations for hot paths
# Run all benchmarks
magex bench
# Run specific component benchmarks
go test -bench=. ./internal/parser/...
go test -bench=. ./internal/badge/...
go test -bench=. ./internal/analytics/...
go test -bench=. ./internal/history/...
go test -bench=. ./internal/analysis/...
# Run with memory profiling
go test -bench=. -benchmem ./...
# Generate benchmark comparison
go test -bench=. -count=5 ./... | tee new.txt
benchstat old.txt new.txt- β‘ CI/CD Integration: Adds < 2 seconds to your workflow
- π Memory Efficient: Peak usage under 10MB for large repositories
- π GitHub Pages: Deploy coverage reports in under 30 seconds
- π Scalable: Tested with repositories containing 100,000+ lines of code
Performance benchmarks measured on GitHub Actions runners (10-core CPU) with production Go projects.
Read more about this Go project's code standards.
Read the AI Usage & Assistant Guidelines for details on how AI is used in this project and how to interact with the AI assistants.
π€ Claude Code Sub-Agents & Commands
This project leverages a comprehensive team of specialized Claude Code sub-agents to manage development, testing, and deployment workflows. Each agent has specific expertise and can work independently or collaboratively to maintain the go-coverage system.
| Agent | Specialization | Primary Tools | Proactive Triggers |
|---|---|---|---|
| go-test-runner | Test execution, coverage analysis, failure resolution | Bash, Read, Edit, Task | After code changes, before PRs |
| go-linter | Code formatting, linting, standards enforcement | Bash, Edit, Glob | After any Go file modification |
| coverage-analyzer | Coverage reports, badges, GitHub Pages deployment | Bash, Write, WebFetch | After successful test runs |
| github-integration | PR management, status checks, API operations | Bash, WebFetch | PR events, deployments |
| dependency-manager | Module updates, vulnerability scanning | Bash, Edit, WebFetch | go.mod changes, weekly scans |
| ci-workflow | GitHub Actions, pipeline optimization | Read, Edit, Bash | Workflow failures, CI updates |
| code-reviewer | Code quality, security review, best practices | Read, Grep, Glob | After code writing/modification |
| documentation-manager | README, API docs, changelog maintenance | Read, Edit, WebFetch | API changes, new features |
| performance-optimizer | Benchmarking, profiling, optimization | Bash, Edit, Grep | Performance issues, benchmarks |
| security-scanner | Vulnerability detection, compliance checks | Bash, Grep, WebFetch | Security advisories, scans |
| debugger | Error analysis, test debugging, issue resolution | Read, Edit, Bash | Test failures, errors, panics |
Sub-agents can be invoked in two ways:
- Automatic Delegation: Claude Code automatically delegates tasks based on context and the agent's specialization
- Explicit Invocation: Request a specific agent by name:
> Use the code-reviewer agent to review my recent changes > Have the debugger investigate this test failure > Ask the coverage-analyzer to generate a new report
Sub-agents work together cohesively:
- go-test-runner β triggers coverage-analyzer after successful tests
- code-reviewer β invokes go-linter for style issues
- dependency-manager β calls security-scanner for vulnerability checks
Sub-agent configurations are stored in .claude/agents/ and can be customized:
- Edit agent prompts to adjust behavior
- Modify tool access for security constraints
- Add project-specific instructions
- Specialized Expertise: Each agent excels in its domain
- Parallel Processing: Multiple agents can work simultaneously
- Isolated Contexts: Agents maintain separate contexts to prevent pollution
- Consistent Workflows: Standardized approaches across the team
- Improved Efficiency: Faster task completion with focused agents
For detailed information about each sub-agent's capabilities and configuration, see the individual agent files in .claude/agents/.
The project includes 20 powerful slash commands that orchestrate our sub-agents for common development tasks. These commands provide quick access to complex workflows:
/fix # Automatically fix test failures and linter issues
/test parser.go # Create comprehensive tests for a file
/coverage # Analyze and improve test coverage to 90%+
/pr-ready # Make your code PR-ready with all checks
/review # Get comprehensive code review
/secure # Run security vulnerability scan
/health # Complete project health check- Quality & Testing:
/fix,/test,/coverage,/dedupe - Documentation:
/doc-update,/doc-review,/explain,/prd - Development:
/review,/optimize,/refactor - Maintenance:
/deps,/secure,/health,/clean - Workflow:
/pr-ready,/debug-ci,/release-prep,/benchmark,/commit
See the complete Claude Code Commands Reference for detailed usage, examples, and best practices.
![]() |
|---|
| MrZ |
View the contributing guidelines and please follow the code of conduct.
All kinds of contributions are welcome π! The most basic way to show your support is to star π the project, or to raise issues π¬. You can also support this project by becoming a sponsor on GitHub π or by making a bitcoin donation to ensure this journey continues indefinitely! π
