Skip to content

Commit c03c93a

Browse files
Andy-Jostclaude
andcommitted
ci: one-line test-results comment built from the reporters' outputs
Both reporters publish check runs again. The comment on the PR is now a single line: dorny's passed/failed/skipped counts, and a link to each check run (EnricoMi's check_url from its json output, dorny's url_html). EnricoMi's own comment is off so there is one comment, not two. Also drops list-files from the dorny step, which is not one of its inputs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 0b5defd commit c03c93a

1 file changed

Lines changed: 40 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,21 @@ jobs:
683683
- doc
684684
- precommit-windows
685685
steps:
686-
# Merge every test job's JUnit XML into two checks on the commit. Both
687-
# steps are informational: continue-on-error keeps them from changing
688-
# the gate below, and neither fails on test failures.
686+
# Merge every test job's JUnit XML into two checks on the commit, and
687+
# post one comment on the PR that links to both. Every step here is
688+
# informational: continue-on-error keeps it from changing the gate
689+
# below, and none of them fails on test failures.
690+
#
691+
# Only mirror branches have a PR to comment on, and the local
692+
# get_pr_number action needs the repository checked out.
693+
- name: Checkout repository
694+
if: ${{ needs.should-skip.outputs.skip != 'true' && startsWith(github.ref_name, 'pull-request/') }}
695+
continue-on-error: true
696+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
697+
with:
698+
fetch-depth: 1
699+
persist-credentials: false
700+
689701
- name: Download test results
690702
if: ${{ needs.should-skip.outputs.skip != 'true' }}
691703
continue-on-error: true
@@ -696,7 +708,8 @@ jobs:
696708

697709
- name: Publish test results (aggregate)
698710
# One entry per distinct test across the whole matrix, with the
699-
# number of runs that failed; also posts a PR comment on failures.
711+
# number of runs that failed.
712+
id: aggregate
700713
if: ${{ needs.should-skip.outputs.skip != 'true' }}
701714
continue-on-error: true
702715
uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0
@@ -708,7 +721,8 @@ jobs:
708721
# one failure into several "k out of N runs" entries.
709722
report_individual_runs: false
710723
check_run_annotations: none
711-
comment_mode: failures
724+
# The comment step below covers both checks.
725+
comment_mode: "off"
712726
compare_to_earlier_commit: false
713727
# The run is on copy-pr-bot's pull-request/N mirror of the PR head, so
714728
# the PR lives in a fork: find it by commit search, not by branch.
@@ -718,14 +732,14 @@ jobs:
718732
- name: Publish test results (by configuration)
719733
# One section per test-results file, so a failure is listed under
720734
# the job configuration that produced it.
735+
id: by-config
721736
if: ${{ needs.should-skip.outputs.skip != 'true' }}
722737
continue-on-error: true
723738
uses: dorny/test-reporter@a6ddd83ac95ff4586f5d3aceeb314d9a1841db95 # v3.0.0
724739
with:
725740
name: Test Results (by configuration)
726741
path: test-results/**/*.xml
727742
reporter: python-xunit
728-
list-files: failed
729743
list-suites: failed
730744
list-tests: failed
731745
max-annotations: 0
@@ -737,6 +751,26 @@ jobs:
737751
# report to the job summary instead and creates no check.
738752
use-actions-summary: false
739753

754+
- name: Get PR number
755+
if: ${{ needs.should-skip.outputs.skip != 'true' && startsWith(github.ref_name, 'pull-request/') }}
756+
continue-on-error: true
757+
uses: ./.github/actions/get_pr_number
758+
759+
# One line with the counts and a link to each check, recreated at the
760+
# bottom of the thread on every run. The counts are dorny's: test
761+
# executions summed over every configuration.
762+
- name: Post the test-results comment
763+
if: ${{ needs.should-skip.outputs.skip != 'true' && startsWith(github.ref_name, 'pull-request/') && env.PR_NUMBER != '' }}
764+
continue-on-error: true
765+
uses: marocchino/sticky-pull-request-comment@d4d6b0936434b21bc8345ad45a440c5f7d2c40ff # v3.0.3
766+
with:
767+
header: test-results
768+
number: ${{ env.PR_NUMBER }}
769+
recreate: true
770+
message: |
771+
Test results for ${{ github.sha }}: ${{ steps.by-config.outputs.passed }} passed, ${{ steps.by-config.outputs.failed }} failed and ${{ steps.by-config.outputs.skipped }} skipped.
772+
[Results in aggregate](${{ steps.aggregate.outputs.json && fromJSON(steps.aggregate.outputs.json).check_url || '' }}) | [Results by configuration](${{ steps.by-config.outputs.url_html }})
773+
740774
- name: Exit
741775
env:
742776
NEEDS_JSON: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)