-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (76 loc) · 3.1 KB
/
Copy pathpost-coverage-comment.yaml
File metadata and controls
87 lines (76 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright 2025 NVIDIA CORPORATION
# SPDX-License-Identifier: Apache-2.0
name: KAI Scheduler - Post Coverage Comment
on:
workflow_run:
workflows: ["KAI Scheduler - Pull Request"]
types:
- completed
jobs:
post-coverage-comment:
name: Post Coverage Comment
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
pull-requests: write
steps:
- name: Download PR number artifact
id: download_pr_number
continue-on-error: true
uses: actions/download-artifact@v8
with:
name: pr-number-for-comment
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download coverage report artifact
id: download_coverage_report
continue-on-error: true
uses: actions/download-artifact@v8
with:
name: coverage-report-for-comment
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read PR number
if: steps.download_pr_number.outcome == 'success' && steps.download_coverage_report.outcome == 'success'
id: pr
run: echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
- name: Find existing coverage comment
if: steps.download_pr_number.outcome == 'success' && steps.download_coverage_report.outcome == 'success'
uses: peter-evans/find-comment@v4
id: find-comment
with:
issue-number: ${{ steps.pr.outputs.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- code-coverage-report-comment -->'
- name: Prepare coverage comment body
if: steps.download_pr_number.outcome == 'success' && steps.download_coverage_report.outcome == 'success'
id: comment-body
env:
EXISTING_COMMENT_ID: ${{ steps.find-comment.outputs.comment-id }}
run: |
if [ -s coverage-report.txt ]; then
{
echo '<!-- code-coverage-report-comment -->'
cat coverage-report.txt
} > coverage-report-comment.md
echo "should_update=true" >> $GITHUB_OUTPUT
exit 0
fi
if [ -n "$EXISTING_COMMENT_ID" ]; then
{
echo '<!-- code-coverage-report-comment -->'
echo 'No changes to coverage.'
} > coverage-report-comment.md
echo "should_update=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "should_update=false" >> $GITHUB_OUTPUT
- name: Create or update coverage comment
if: steps.download_pr_number.outcome == 'success' && steps.download_coverage_report.outcome == 'success' && steps.comment-body.outputs.should_update == 'true'
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ steps.pr.outputs.number }}
body-path: coverage-report-comment.md
edit-mode: replace