Reported + Codecov Collector
Enforce Reported using data collected by Codecov Collector. Automatically check testing and quality standards on every PR.
How Codecov Collector Powers This Guardrail
The Codecov Collector gathers metadata from your testing systems. This data flows into Lunar's Component JSON, where the Reported guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the Codecov Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/codecov@v1.0.0
# with: ...
# Step 2: Enable the Coverage Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/coverage@v1.0.0
include: [reported]
# with: ...
What Codecov Collector Collects
This collector gathers the following data that the Reported guardrail evaluates.
ran
Records that Codecov ran in CI by writing source metadata to .testing.coverage. The presence of this object signals that codecov was executed. Also captures the Codecov CLI version when available via the codecov --version command.
results
Fetches coverage percentage and file-level details from the Codecov API after upload commands complete. Detects upload commands (-t, -f flags or upload subcommands), calls the Codecov API with the commit SHA, and writes coverage percentage to .testing.coverage.percentage with full API response in .testing.coverage.native.codecov.
Example Data Flow
Here's an example of the data that Codecov Collector writes to the Component JSON, which Reported then evaluates.
{
"testing": {
"coverage": {
"source": {
"tool": "codecov",
"integration": "ci",
"version": "0.7.2"
},
"percentage": 85.5,
"native": {
"codecov": {
"totals": {
"files": 3,
"lines": 1250,
"hits": 1068,
"misses": 182,
"partials": 0,
"coverage": 85.5
},
"files": [
{
"name": "src/main.py",
"totals": {
"lines": 500,
"hits": 450,
"misses": 50,
"coverage": 90.0
}
}
]
}
}
}
}
}
Configuration Options
Codecov Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
use_env_token |
Optional |
false
|
Use CODECOV_TOKEN from environment instead of Lunar secret |
Coverage Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_coverage |
Optional |
80
|
Minimum required coverage percentage |
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.