Skip to content

Commit 01be623

Browse files
imaqsoodclaude
andcommitted
(MODULES-11831) Harden module_coverage workflow per review
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>
1 parent 4b07e86 commit 01be623

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎.github/workflows/module_coverage.yml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ jobs:
5151
steps:
5252

5353
- name: "Checkout"
54-
uses: "actions/checkout@v4"
54+
uses: "actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10" # v6.0.3
5555
with:
5656
ref: ${{ github.event.pull_request.head.sha }}
57+
persist-credentials: false
5758

5859
- name: "Setup ruby"
59-
uses: "ruby/setup-ruby@v1"
60+
uses: "ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f" # v1.310.0
6061
with:
6162
ruby-version: ${{ inputs.ruby_version }}
6263
bundler-cache: true
@@ -109,15 +110,15 @@ jobs:
109110

110111
- name: "Upload LCOV report"
111112
if: ${{ always() }}
112-
uses: "actions/upload-artifact@v4"
113+
uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02" # v4.6.2
113114
with:
114115
name: "coverage-lcov"
115116
path: "coverage/lcov/*.lcov"
116117
if-no-files-found: "warn"
117118

118119
- name: "Post coverage comment"
119-
if: ${{ always() && github.event_name == 'pull_request' }}
120-
uses: "actions/github-script@v7"
120+
if: ${{ always() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') }}
121+
uses: "actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b" # v7.0.1
121122
with:
122123
script: |
123124
const o = ${{ toJSON(steps.gate.outputs) }};
@@ -139,7 +140,7 @@ jobs:
139140
const body = lines.join('\n');
140141
const { owner, repo } = context.repo;
141142
const issue_number = context.issue.number;
142-
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number });
143+
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
143144
const prev = comments.find((c) => c.body && c.body.includes('<!-- coverage-gate -->'));
144145
if (prev) {
145146
await github.rest.issues.updateComment({ owner, repo, comment_id: prev.id, body });

0 commit comments

Comments
 (0)