Hamburger Cross Icon
Min Coverage
+
Codecov Collector

Min Coverage + Codecov Collector

Guardrail Collector Stable Testing And Quality

Enforce Min Coverage using data collected by Codecov Collector. Automatically check testing and quality standards on every PR.

Guardrail: Enforces a minimum code coverage threshold (default 80%). Fails when coverage percentage is below the configured minimum.
Data Source: Automatically detect Codecov runs in CI and fetch coverage percentage and file-level details. Track test coverage trends across your organization.

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 Min Coverage 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.

1
Codecov Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Min Coverage Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# 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: [min-coverage]
    # with: ...

What Codecov Collector Collects

This collector gathers the following data that the Min Coverage guardrail evaluates.

Collector ci-after-command

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.

Collector ci-after-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 Min Coverage then evaluates.

{ } component.json From Codecov Collector
{
  "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.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Book a Demo
See it work with your own use cases
See How It Works