This project uses CodeCov to track code coverage and enforce coverage gates in CI/CD pipelines.
- Minimum Project Coverage: 80%
- Minimum Patch Coverage: 80%
- Threshold: 1% (allows minor fluctuations)
The CodeCov configuration is defined in codecov.yml at the root of the repository.
- Project Coverage Gate: Fails if overall project coverage drops below 80%
- Patch Coverage Gate: Fails if new code in a PR has less than 80% coverage
- Coverage Reports: Generated for:
- Explorer contract (Rust)
- Ticket contract (Rust)
- Indexer (Node.js/TypeScript)
The following file types are excluded from coverage calculations:
- Documentation files (
*.md) - Configuration files (
*.yml,*.yaml,*.json,*.toml) - Test snapshots
- Fuzz targets
- Test files
- GitHub workflows
- Documentation directory
-
CI Workflow (
.github/workflows/ci.yml)- Runs tests with coverage for explorer contract
- Runs indexer tests with coverage
- Uploads both coverage reports to CodeCov
-
Contract Tests Workflow (
.github/workflows/contract-tests.yml)- Runs comprehensive test suite for ticket contract
- Enforces 85% local coverage threshold
- Uploads coverage to CodeCov
Add the following secret to your GitHub repository:
CODECOV_TOKEN: Your CodeCov upload token- Get this from: https://app.codecov.io/gh/YOUR_ORG/YOUR_REPO/settings
- Add it to: Repository Settings → Secrets and variables → Actions → New repository secret
# Install cargo-llvm-cov
cargo install cargo-llvm-cov
# Explorer contract
cargo llvm-cov --workspace --lcov --output-path lcov.info
cargo llvm-cov report
# Ticket contract
cd contracts/ticket
cargo llvm-cov --features testutils --release --lcov --output-path lcov.info
cargo llvm-cov report --features testutils --releasecd indexer
npm test -- --coverage- On Push/PR: CI workflows run tests with coverage collection enabled
- Coverage Upload: Coverage reports (lcov format) are uploaded to CodeCov
- Analysis: CodeCov analyzes the coverage data and compares against thresholds
- Status Check: If coverage is below 80%, the CI check fails and blocks the PR
- Comments: CodeCov adds a comment to PRs showing coverage changes
- Online Dashboard: https://app.codecov.io/gh/YOUR_ORG/YOUR_REPO
- PR Comments: CodeCov automatically comments on PRs with coverage details
- Badge: Add to README:
[](https://codecov.io/gh/YOUR_ORG/YOUR_REPO)
- Verify
CODECOV_TOKENis set correctly in GitHub secrets - Check the CodeCov action logs for specific error messages
- Ensure the lcov.info file is being generated correctly
- Run tests locally with coverage to identify untested code
- Add tests to cover the missing code paths
- Consider adjusting thresholds in
codecov.ymlif necessary (with team approval)
- Update the
ignoresection incodecov.ymlto exclude generated or non-critical files