Skip to content

Commit bfd254b

Browse files
authored
Merge pull request #274 from laeubi/publish_junit_results
Publish JUnit Results as part of the build
2 parents ffa6df0 + 558b44b commit bfd254b

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

.github/workflows/maven.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,22 @@ jobs:
2020
distribution: 'temurin'
2121
cache: maven
2222
- name: Build with Maven
23-
run: mvn -B package --file pom.xml
23+
run: mvn -D maven.test.failure.ignore=true -B package --file pom.xml
24+
- name: Upload Test Results
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: test-results-${{ matrix.os }}
28+
if-no-files-found: error
29+
path: |
30+
${{ github.workspace }}/**/target/surefire-reports/*.xml
31+
event_file:
32+
name: "Event File"
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Upload
36+
uses: actions/upload-artifact@v2
37+
with:
38+
name: Event File
39+
path: ${{ github.event_path }}
40+
2441

.github/workflows/testresults.yml

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

0 commit comments

Comments
 (0)