Skip to content

Commit f1aca41

Browse files
authored
Tweaks to case count reports on PRs (#4551)
* Print something when there's no diff Otherwise it's kind of confusing. * Also don't post the 'waiting for build job' if there isn't already a comment * Also don't post an update if it was cancelled
1 parent 8f6f731 commit f1aca41

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.github/workflows/pr-comment.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
body-includes: "<!-- pr-comment -->"
4242

4343
# If 'pr' workflow run was 'requested'...
44-
- if: github.event.action == 'requested'
44+
- if: github.event.action == 'requested' && steps.find-comment.outputs.comment-id != ''
4545
name: PR workflow started - Update Comment
4646
uses: peter-evans/create-or-update-comment@v5
4747
with:
@@ -52,8 +52,9 @@ jobs:
5252
<!-- pr-comment -->
5353
Waiting for [build job](https://github.com/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}) (at ${{ github.event.workflow_run.head_sha }})...
5454
55-
# If 'pr' workflow run was 'completed'...
56-
- if: github.event.action == 'completed'
55+
# If 'pr' workflow run was 'completed' (but not 'cancelled', that usually means a new job is
56+
# running, and we don't want to race with it)...
57+
- if: github.event.action == 'completed' && github.event.workflow_run.conclusion != 'cancelled'
5758
name: PR workflow completed - Download pr-comment-body.txt
5859
uses: actions/download-artifact@v4
5960
continue-on-error: true
@@ -62,7 +63,7 @@ jobs:
6263
repository: ${{ github.event.workflow_run.repository.full_name }}
6364
run-id: ${{ github.event.workflow_run.id }}
6465
name: pr-comment-body.txt
65-
- if: github.event.action == 'completed'
66+
- if: github.event.action == 'completed' && github.event.workflow_run.conclusion != 'cancelled'
6667
name: PR workflow completed - Create pr-comment.txt
6768
env:
6869
REPO: ${{github.repository}}
@@ -84,8 +85,8 @@ jobs:
8485
echo '(No pr-comment-body.txt artifact found from this job.)'
8586
fi
8687
) > pr-comment.txt
87-
- if: github.event.action == 'completed'
88-
name: PR workflow completed - Update Comment
88+
- if: github.event.action == 'completed' && github.event.workflow_run.conclusion != 'cancelled'
89+
name: PR workflow completed - Post or Update Comment
8990
uses: peter-evans/create-or-update-comment@v5
9091
with:
9192
issue-number: ${{ steps.pr-context.outputs.number }}

.github/workflows/pr.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ jobs:
5353
diff --unified=0 case-count-report-{before,after}.txt | grep '^[+-][^+-]' | tee case-count-report-diff.txt
5454
(
5555
echo '```diff'
56-
if [[ "$(wc -l < case-count-report-diff.txt)" -le 20 ]] ; then
56+
line_count=$(wc -l < case-count-report-diff.txt)
57+
if [[ "${line_count}" -eq 0 ]] ; then
58+
echo ' Test case/subcase counts did not change.'
59+
elif [[ "${line_count}" -le 20 ]] ; then
5760
cat case-count-report-diff.txt
5861
else
5962
head -n18 case-count-report-diff.txt
60-
echo '[snip - full report in action logs]'
63+
echo ' [snip - full report in action logs]'
6164
tail -n2 case-count-report-diff.txt
6265
fi
6366
echo '```'

0 commit comments

Comments
 (0)