Skip to content

Commit 4177256

Browse files
committed
Switch to better test reporter, and make it work with PRs
1 parent 6d68e95 commit 4177256

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ concurrency:
1111
group: ${{ github.ref }}
1212
cancel-in-progress: true
1313

14+
# Sets permissions of the GITHUB_TOKEN to allow publishing of workflow checks
15+
permissions:
16+
contents: read
17+
id-token: write
18+
checks: write
19+
1420
jobs:
1521
build:
1622
runs-on: ubuntu-latest
@@ -96,9 +102,10 @@ jobs:
96102
run: mvn --batch-mode -e clean install
97103

98104
- name: Publish Test Report
99-
uses: scacap/action-surefire-report@v1
105+
if: success() || failure()
106+
uses: EnricoMi/publish-unit-test-result-action@v2
100107
with:
101-
fail_if_no_tests: false
108+
junit_files: "target/surefire-reports/*.xml"
102109

103110
- name: Build site
104111
run: mvn --batch-mode -e -DskipTests site
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test Reports (PR)
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Pull Request"]
6+
types:
7+
- completed
8+
9+
permissions: {}
10+
11+
jobs:
12+
test-results:
13+
name: Test Results
14+
runs-on: ubuntu-latest
15+
if: github.event.workflow_run.conclusion != 'skipped'
16+
17+
permissions:
18+
checks: write
19+
pull-requests: write
20+
actions: read
21+
22+
steps:
23+
- name: Download and Extract Artifacts
24+
env:
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
run: |
27+
mkdir -p artifacts && cd artifacts
28+
29+
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
30+
31+
gh api --paginate "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
32+
do
33+
IFS=$'\t' read name url <<< "$artifact"
34+
gh api $url > "$name.zip"
35+
unzip -d "$name" "$name.zip"
36+
done
37+
38+
- name: Publish Test Results
39+
uses: EnricoMi/publish-unit-test-result-action@v2
40+
with:
41+
commit: ${{ github.event.workflow_run.head_sha }}
42+
event_file: artifacts/Event File/event.json
43+
event_name: ${{ github.event.workflow_run.event }}
44+
junit_files: "artifacts/Test Results/**/*.xml"

.github/workflows/pull-request.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Pull Request
22

33
on:
44
pull_request:
@@ -79,11 +79,13 @@ jobs:
7979
- name: Build with Maven
8080
run: mvn --batch-mode -e clean install
8181

82-
- name: Publish Test Report
83-
uses: scacap/action-surefire-report@v1
82+
- name: Upload Test Results
8483
if: success() || failure()
84+
uses: actions/upload-artifact@v3
8585
with:
86-
fail_if_no_tests: false
86+
name: Test Results
87+
path: |
88+
target/surefire-reports/*.xml
8789
8890
- name: Build site
8991
run: mvn --batch-mode -e -DskipTests site
@@ -95,3 +97,13 @@ jobs:
9597
if: always()
9698
run: |
9799
find ~/.m2/repository -name \*-SNAPSHOT -type d -exec rm -rf {} \+ || :
100+
101+
event_file:
102+
name: "Event File"
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Upload
106+
uses: actions/upload-artifact@v3
107+
with:
108+
name: Event File
109+
path: ${{ github.event_path }}

0 commit comments

Comments
 (0)