Code Coverage
August 25, 2026 · View on GitHub
This project includes support for measuring line and branch coverage, including a coverage baseline and checks to ensure coverage does not decrease.
How It Works
The coverage pipeline has three stages:
- Collect — Run tests with coverage enabled:
task test coverage=true - Report — Generate HTML and JSON reports:
task coverage:report - Enforce — Validate against the baseline:
task coverage:check
Local Usage
Prerequisites
- Python 3.10+
Running Coverage Locally
# Install coverage reporting tools
task coverage:install
# Run all tests with coverage collection
task test coverage=true
# Generate reports (HTML + JSON)
task coverage:report
# Check coverage against baseline
task coverage:check
# Update baseline (if coverage improved)
task coverage:update
# Clean coverage artifacts
task coverage:clean
Threshold
The coverage check passes only when measured coverage exactly matches the baseline. Any change (increase or decrease) fails the check — run task coverage:update to increase the baseline.
CI Behavior
coverage:checkruns on pull requests after tests. The build fails if coverage differs from the baseline.- Baseline updates: Run
task coverage:updatelocally and commit the updatedcoverage-baseline.json.
File Layout
dev/conf/
└── coverage-baseline.json # Coverage baseline
dev/coverage/
├── results/ # Raw .cobertura.xml coverage results (gitignored)
│ ├── unit/
│ └── integration/
└── reports/ # Generated HTML/JSON reports (gitignored)
├── unit/
├── integration/
└── combined/
Baseline File
The coverage baseline file (dev/conf/coverage-baseline.json) stores the coverage baseline and the server configuration used to collect it.
Example:
{
"server_type": "valkey",
"server_version": "9.0",
"line_coverage": 70.6,
"branch_coverage": 50.9
}