Skip to content

(MODULES-11831) Add SimpleCov coverage gate with baseline mode#648

Open
imaqsood wants to merge 1 commit into
mainfrom
MODULES-11831-coverage-gate
Open

(MODULES-11831) Add SimpleCov coverage gate with baseline mode#648
imaqsood wants to merge 1 commit into
mainfrom
MODULES-11831-coverage-gate

Conversation

@imaqsood

Copy link
Copy Markdown
Contributor

What

Syncs a SimpleCov coverage gate to all CAT-supported modules via pdk update.

  • moduleroot/.github/workflows/coverage.yml.erb - thin caller that delegates to puppetlabs/cat-github-actions/.github/workflows/module_coverage.yml@main, passing threshold and baseline_mode from .sync.yml.
  • moduleroot/spec/spec_helper.rb.erb - SimpleCov hook placed at the top of the file (before any application code is required). Gated behind the simplecov config flag and the COVERAGE env var, so local rake spec runs are unaffected - no double-load and no json/json_pure conflict.
  • config_defaults.yml - adds simplecov: true, a managed coverage.yml entry (threshold: 80, baseline_mode: true), and the simplecov / simplecov-lcov gems.
  • README.md - documents the new keys and the two coverage modes.

Rollout behaviour

coverage.yml is managed (not unmanaged) so pdk update deploys it everywhere. baseline_mode with no .coverage_baseline file is a no-op gate (baseline 0), so deploying it is non-breaking: each module reports its current coverage and ratchets by committing a baseline, or sets baseline_mode: false to gate against threshold. Opt out per module with simplecov: false + unmanaged: true on .github/workflows/coverage.yml.

Depends on

puppetlabs/cat-github-actions#179 (the reusable module_coverage.yml). Merge that first.

Ticket

MODULES-11831 (epic MODULES-11828).

Acceptance criteria

  • Workflow runs on PRs to default branch; runs rake spec with SimpleCov
  • Emits LCOV report as a build artifact
  • absolute and baseline_mode modes via .sync.yml
  • Posts coverage delta as a PR comment
  • rake spec still passes when SimpleCov is loaded (env-gated, no double-load)
  • Green on concat / fails on injected uncovered branch (verified once remove ruby2.1.9 from .gitlab-ci #179 merges and @main resolves)

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a managed GitHub Actions coverage workflow and a SimpleCov hook to CAT-supported module templates so pdk update can roll out a coverage gate (either absolute threshold or baseline “ratchet” mode) across modules.

Changes:

  • Introduces a managed .github/workflows/coverage.yml template that delegates to puppetlabs/cat-github-actions reusable workflow and passes threshold/baseline_mode from .sync.yml.
  • Adds an env-gated SimpleCov + LCOV formatter hook at the top of spec/spec_helper.rb (only active when COVERAGE=yes and simplecov: true).
  • Updates defaults and documentation to include the new workflow/config keys and required gems.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
README.md Documents the new coverage.yml workflow behavior and the simplecov config flag.
moduleroot/spec/spec_helper.rb.erb Adds an env-gated SimpleCov/LCOV initialization before any app code loads.
moduleroot/.github/workflows/coverage.yml.erb Adds the managed coverage workflow delegating to the reusable module_coverage.yml.
config_defaults.yml Enables SimpleCov by default, adds coverage workflow defaults, and adds simplecov/simplecov-lcov gems.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

uses: "puppetlabs/cat-github-actions/.github/workflows/module_coverage.yml@main"
with:
threshold: <%= coverage['threshold'] || 80 %>
baseline_mode: <%= coverage['baseline_mode'] ? true : false %>
Sync a coverage gate to all modules via `pdk update`:

* moduleroot/.github/workflows/coverage.yml.erb - thin caller that
  delegates to puppetlabs/cat-github-actions module_coverage.yml,
  passing threshold and baseline_mode from .sync.yml.
* moduleroot/spec/spec_helper.rb.erb - SimpleCov hook that starts before
  any application code loads. Gated behind the COVERAGE env var and the
  `simplecov` config flag, so local `rake spec` runs are unaffected and
  there is no double-load or json/json_pure conflict.
* config_defaults.yml - add `simplecov: true`, a managed coverage.yml
  entry (threshold 80, baseline_mode true), and the simplecov /
  simplecov-lcov gems. baseline_mode with no `.coverage_baseline` file is
  a no-op gate, so the rollout is non-breaking.
* README.md - document the new keys and the two coverage modes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@imaqsood
imaqsood force-pushed the MODULES-11831-coverage-gate branch from cc20531 to 2786999 Compare July 1, 2026 10:36
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