(MODULES-11831) Add module_coverage reusable workflow#179
Open
imaqsood wants to merge 2 commits into
Open
Conversation
6 tasks
There was a problem hiding this comment.
Pull request overview
Adds a new reusable GitHub Actions workflow intended to enforce Ruby unit-test line coverage (via SimpleCov) for Puppet modules, including optional baseline gating and automated PR commenting.
Changes:
- Introduces
.github/workflows/module_coverage.ymlreusable workflow withworkflow_callinputs for threshold/baseline mode, Ruby version, and runner OS. - Adds a coverage gate step that reads
coverage/.last_run.json, supports absolute and baseline gating, and fails the workflow when coverage is below the configured target. - Uploads LCOV artifacts and posts/updates a PR coverage summary comment via
actions/github-script.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if-no-files-found: "warn" | ||
|
|
||
| - name: "Post coverage comment" | ||
| if: ${{ always() && github.event_name == 'pull_request' }} |
Add a reusable Module Coverage workflow that enforces Ruby unit-test
coverage via SimpleCov. It runs `bundle exec rake spec` with COVERAGE=yes,
uploads the LCOV report as a build artifact, and posts the coverage result
as a PR comment. The gate supports two modes:
* absolute - fail if line coverage is below `threshold` (default 80).
* baseline_mode - gate against `.coverage_baseline`; fail on regression,
stay green and suggest a new baseline when coverage rises.
Consumed by the coverage.yml workflow synced from pdk-templates.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80cc227 to
4b07e86
Compare
Address Copilot review feedback on PR #179: - Pin actions/checkout and ruby/setup-ruby to commit SHAs and set persist-credentials: false on checkout, matching the hardened pattern in module_ci.yml. Also pin upload-artifact and github-script. - Run the coverage comment step on pull_request_target as well as pull_request, so fork PRs that need pull-requests: write still get the summary. - Paginate issues.listComments so the marker comment is found even when it drifts past the first page, preventing duplicate coverage comments. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a reusable Module Coverage workflow that enforces Ruby unit-test coverage on a Puppet module using SimpleCov. Consumed by the new
coverage.ymlworkflow synced from pdk-templates (companion PR).How it works
bundle exec rake specwithCOVERAGE=yes(SimpleCov hook lives in the modulesspec_helper.rb).coverage/.last_run.jsonfor line coverage and gates the build in one of two modes:threshold(default80)..coverage_baselinefrom the repo root; fail on regression, stay green and suggest a new baseline when coverage rises. Missing baseline =0= no-op gate (non-breaking rollout).actions/upload-artifact).actions/github-script).Inputs:
threshold,baseline_mode,ruby_version,runs_on. Caller must grantpull-requests: write.Ticket
MODULES-11831 (S2 maturity coverage gate, epic MODULES-11828).
Merge order
Merge this before the pdk-templates PR, which references
module_coverage.yml@main.🤖 Generated with Claude Code