Skip to content

Commit a73636f

Browse files
committed
ci: Fix posting coverage comments
1 parent e004ae4 commit a73636f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

.github/workflows/test_rust.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions:
14+
pull-requests: write
15+
1316
env:
1417
FEATURES: lzma,jpegxr
1518
TEST_OPTS: --workspace --locked --no-fail-fast -j 4
@@ -271,13 +274,23 @@ jobs:
271274
if: always()
272275
run: cat target/diff-cover/report.md >> $GITHUB_STEP_SUMMARY
273276

274-
- name: Comment
277+
- name: Generate comment
278+
id: generate_comment
275279
if: always()
276280
env:
277-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
278281
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
279282
run: |
280-
$COVERAGE_SCRIPT comment_report "target/diff-cover/report.json" "${{ github.event.pull_request.number }}" "${RUN_URL}"
283+
comment=$($COVERAGE_SCRIPT comment_report "target/diff-cover/report.json" "" "${RUN_URL}")
284+
echo "comment<<EOF" >> $GITHUB_OUTPUT
285+
echo "$comment" >> $GITHUB_OUTPUT
286+
echo "EOF" >> $GITHUB_OUTPUT
287+
288+
- name: Post comment
289+
if: always() && steps.generate_comment.outputs.comment != ''
290+
uses: thollander/actions-comment-pull-request@v3
291+
with:
292+
message: ${{ steps.generate_comment.outputs.comment }}
293+
comment-tag: coverage-report
281294

282295
dependencies:
283296
needs: changes

0 commit comments

Comments
 (0)