Skip to content

Commit 54665f8

Browse files
committed
Allow GHA to upload and report the unit tests results
See: https://github.com/DOMjudge/domjudge/actions/runs/12247242151/job/34164708661?pr=2879 Here the push from dependabot failed to add the check-run results. Other possible permissions: https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run We expect the file to be named per matrix job but this was not updated in the code so the upload action couldn't find the files.
1 parent e982562 commit 54665f8

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

.github/jobs/unit-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ php $phpcov webapp/bin/phpunit -c webapp/phpunit.xml.dist webapp/tests/$unittest
3636
UNITSUCCESS=$?
3737

3838
# Store the unit tests also in the root for the GHA
39-
cp $ARTIFACTS/unit-tests.xml $DIR/
39+
cp $ARTIFACTS/unit-tests.xml $DIR/unit-tests-${version}-${unittest}.xml
4040

4141
# Make sure the log exists before copy
4242
touch ${DIR}/webapp/var/log/test.log

.github/workflows/unit-tests.yml

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
run: diff newcodecov .github/jobs/uploadcodecov.sh
2727

2828
unit-tests:
29+
permissions:
30+
checks: write
2931
runs-on: ubuntu-24.04
3032
timeout-minutes: 20
3133
container:
@@ -87,3 +89,13 @@ jobs:
8789
/opt/domjudge/domserver/webapp/var/log/*.log
8890
/tmp/docker-logs
8991
/tmp/artifacts
92+
93+
event_file:
94+
name: "Post results assuming forks"
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Upload
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: Event File
101+
path: ${{ github.event_path }}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish unit test results
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Unit tests"]
6+
types:
7+
- completed
8+
permissions: {}
9+
10+
jobs:
11+
test-results:
12+
name: Process test results
13+
runs-on: ubuntu-latest
14+
if: github.event.workflow_run.conclusion != 'skipped'
15+
permissions:
16+
# required by download step to access artifacts API
17+
actions: read
18+
# write the actual check-run
19+
checks: write
20+
# needed unless run with comment_mode: off
21+
pull-requests: write
22+
steps:
23+
- name: Download and Extract Artifacts
24+
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
25+
with:
26+
run_id: ${{ github.event.workflow_run.id }}
27+
path: artifacts
28+
- name: Publish Test Results
29+
uses: EnricoMi/publish-unit-test-result-action@v2
30+
with:
31+
commit: ${{ github.event.workflow_run.head_sha }}
32+
event_file: artifacts/Event File/event.json
33+
event_name: ${{ github.event.workflow_run.event }}
34+
files: "tmp/artifacts/**/*.xml"

0 commit comments

Comments
 (0)