Skip to content

ci: gate PR merges on per-package coverage regression - #1247

Open
Surabhi-1605 wants to merge 1 commit into
mainfrom
ci/coverage-regression-gate
Open

ci: gate PR merges on per-package coverage regression#1247
Surabhi-1605 wants to merge 1 commit into
mainfrom
ci/coverage-regression-gate

Conversation

@Surabhi-1605

Copy link
Copy Markdown
Contributor

Summary

Adds a per-package coverage regression gate to consul-dataplane, ensuring no PR can lower the average test coverage of any package below its current baseline on main.

This complements the existing 90% patch coverage gate (merged in #1178) — patch coverage asks "are your new lines tested?", this gate asks "did the overall package health go down?"

How it works

  1. On every merge to main, reusable-coverage-report.yml commits the per-package coverage averages to .github/coverage-baseline.txt (the authoritative baseline).
  2. On every PR, the new coverage-regression-gate job downloads the per-package summary artifact, compares each package against the baseline, and fails if any package average dropped.
  3. New packages (no prior baseline) are always allowed through.
  4. On the first PR after this merges the gate skips gracefully — no baseline exists yet. The baseline is created on the next push to main.

Changes

  • reusable-coverage-report.yml:

    • Upload pkg-summary artifact so the regression gate job can consume it
    • On merges to main, commit pkg-summary.txt as .github/coverage-baseline.txt
    • Fix coverage-gate if: expression (remove erroneous ${{ }} wrapper on job-level condition)
  • consul-dataplane-checks.yaml:

    • Add coverage-regression-gate job that enforces per-package coverage does not regress

Notes

  • Single module repo (github.com/hashicorp/consul-dataplane) — no multi-module complexity
  • Mocks excluded (/mocks/, /mock_) consistent with existing coverage filtering
  • Make coverage-regression-gate a required branch-protection check to enforce on merge

Add a coverage regression gate that ensures no PR can lower the average
test coverage of any package below its current baseline on main.

Changes:
- reusable-coverage-report.yml: upload pkg-summary artifact for the
  regression gate to consume; on merges to main, commit pkg-summary.txt
  as .github/coverage-baseline.txt (the authoritative per-package baseline).
  Also fix coverage-gate if: expression (remove erroneous ${{ }} wrapper).
- consul-dataplane-checks.yaml: add coverage-regression-gate job that
  downloads the pkg-summary artifact, checks each package's average
  against the baseline, and fails if any package regresses.

On the first PR after this merges the gate skips gracefully (no baseline
yet); the baseline is created on the next push to main.

Make coverage-regression-gate a required branch-protection check to
enforce on merge.
@Surabhi-1605
Surabhi-1605 requested review from a team as code owners August 14, 2026 12:05
@github-actions

Copy link
Copy Markdown

Go Test Coverage: 66.7%

Patch coverage: N/A (no coverable Go lines changed)

See the workflow run for the full per-package breakdown and downloadable HTML report.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.48%. Comparing base (fefa27a) to head (363f080).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1247   +/-   ##
=======================================
  Coverage   68.48%   68.48%           
=======================================
  Files          19       19           
  Lines        2186     2186           
=======================================
  Hits         1497     1497           
  Misses        587      587           
  Partials      102      102           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants