Skip to content

ci(coverage): enforce 90% minimum line coverage on pull requests#348

Merged
rhuanbarreto merged 3 commits into
mainfrom
ci/enforce-coverage-threshold
May 25, 2026
Merged

ci(coverage): enforce 90% minimum line coverage on pull requests#348
rhuanbarreto merged 3 commits into
mainfrom
ci/enforce-coverage-threshold

Conversation

@rhuanbarreto

@rhuanbarreto rhuanbarreto commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a 90% minimum line coverage threshold to the Coverage Report job. PRs that drop below 90% fail the Validate Code gate and cannot be merged.
  • Extract two reusable composite actions for workflow readability:
    • .github/actions/setup-bun-project — moonrepo/setup-toolchain + bun install, used by 3 workflows
    • .github/actions/coverage-report — coverage merging, HTML report, threshold computation, PR comment posting (~100 lines of inline bash → 1 step)
  • Show threshold status (met / **not met**) in the PR coverage comment so authors see the result before the gate blocks.
  • Update ARCH-005 (Testing Standards) to document the 90% enforced target — previously was an 80% unenforced guideline.

How it works

  1. The coverage-report composite action merges Linux + Windows coverage traces, generates an HTML report, computes stats, and posts a sticky PR comment — all behind a single uses: step
  2. It outputs coverage (percentage) and threshold-met (boolean) for the caller
  3. A separate Enforce coverage threshold step in the workflow reads the output and fails with ::error:: if coverage < 90%
  4. The status gate job (branch protection's single required check) includes coverage in its needs — so a threshold failure blocks the PR

Test plan

  • Open a PR with existing tests — coverage should be above 90% and the gate passes
  • Verify the PR coverage comment includes the new Threshold row showing 90% minimum — met
  • Verify the Validate Code status check depends on the Coverage Report job completing successfully
  • Verify smoke tests (Linux + Windows) still pass with the setup-bun-project composite action

Add a coverage threshold enforcement step to the Validate workflow.
PRs that drop total line coverage below 90% now fail the Validate Code
gate and cannot be merged.

Changes:
- Add "Enforce coverage threshold" step after coverage report generation
- Wire coverage job into the status gate job
- Show threshold status (met / not met) in the PR coverage comment
- Update ARCH-005 to document the 90% enforced target (was 80% guideline)

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 25, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0635999
Status: ✅  Deploy successful!
Preview URL: https://590ecc59.archgate-cli.pages.dev
Branch Preview URL: https://ci-enforce-coverage-threshol.archgate-cli.pages.dev

View logs

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.0% (6510 / 7231)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 2069 / 2348
src/engine/ 93.1% 1193 / 1282
src/formats/ 100.0% 141 / 141
src/helpers/ 89.8% 3107 / 3460

Extract two reusable composite actions to improve workflow readability:

- .github/actions/setup-bun-project: Encapsulates moonrepo/setup-toolchain
  (SHA-pinned) + bun install. Used by validate, smoke-test-windows, and
  smoke-test-linux workflows.

- .github/actions/coverage-report: Encapsulates the ~100-line inline bash
  script for coverage merging, HTML report generation, threshold computation,
  job summary, and PR comment posting. Reduces the coverage job from ~50
  workflow lines to ~25 clearly named steps.

Third-party actions inside composite actions remain SHA-pinned for security
consistency, even though CI-001 only scans workflow files.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto rhuanbarreto merged commit c697936 into main May 25, 2026
11 checks passed
@rhuanbarreto rhuanbarreto deleted the ci/enforce-coverage-threshold branch May 25, 2026 18:38
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.

1 participant