Skip to content

Commit da9471d

Browse files
committed
Add merge-junit-reports sub-action
1 parent 0752d6e commit da9471d

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,34 @@ jobs:
4444
with:
4545
split-index: ${{ matrix.split-index }}
4646
split-total: ${{ env.split-total }}
47-
glob: '**/helm-charts/tests-hivemq-operator/**/*IT.java'
47+
glob: '**/src/integrationTest/**/*IT.java'
4848
junit-glob: '**/junit-reports/*.xml'
4949
format: 'gradle'
5050
averageTime: true
5151
debug: true
52-
- name: Run HiveMQ Legacy Operator integration tests
52+
- name: Run integration tests
5353
working-directory: helm-charts
5454
env:
5555
K8S_VERSION_TYPE: ${{ matrix.k8s-version-type }}
56-
run: ./gradlew :tests-hivemq-operator:integrationTest ${{ steps.split-tests.outputs.test-suite }}
56+
run: ./gradlew :integrationTest ${{ steps.split-tests.outputs.test-suite }}
5757
- name: Upload JUnit report artifact
5858
uses: actions/upload-artifact@v4
5959
with:
6060
name: junit-xml-reports-${{ matrix.split-index }}
6161
path: '**/test-results/integrationTest/*.xml'
62+
63+
merge-junit-reports:
64+
runs-on: ubuntu-latest
65+
name: "Merge JUnit reports"
66+
needs:
67+
- integration-test
68+
permissions:
69+
contents: write
70+
steps:
71+
- name: Merge JUnit reports
72+
uses: donnerbart/split-tests-java-action/merge-junit-reports@v1
73+
with:
74+
git-branch: junit-reports/${{ github.base_ref }}
75+
artifact-name: junit-xml-reports
76+
split-artifact-pattern: junit-xml-reports-*
6277
```

merge-junit-reports/action.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Merge JUnit reports
2+
3+
description: Merges the JUnit reports from the test split jobs and saves them in a Git branch
4+
inputs:
5+
git-branch:
6+
description: The Git branch in this repository to store the JUnit reports in (string)
7+
required: true
8+
artifact-name:
9+
description: The artifact name for the merged JUnit reports of all test split jobs
10+
required: true
11+
split-artifact-pattern:
12+
description: The artifact name pattern used by the test split jobs, e.g. junit-xml-reports-* (string)
13+
required: true
14+
split-artifact-delete-merged:
15+
description: Configures if the artifacts of the test split jobs should be deleted after the merge (boolean)
16+
required: false
17+
default: true
18+
cleanup-junit-reports:
19+
description: Configures if the test output should be removed from the merged JUnit reports (boolean)
20+
required: false
21+
default: true
22+
delete-old-junit-reports:
23+
description: Configures if the old JUnit reports in the Git branch should be deleted (boolean)
24+
required: false
25+
default: true
26+
runs:
27+
using: composite
28+
steps:
29+
- name: Set up xmlstarlet
30+
run: sudo apt update && sudo apt install -y xmlstarlet
31+
32+
- name: Checkout JUnit reports
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
34+
with:
35+
path: junit-reports
36+
ref: ${{ inputs.git-branch }}
37+
continue-on-error: true
38+
39+
- name: Merge JUnit report artifacts
40+
uses: actions/upload-artifact/merge@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
41+
with:
42+
name: ${{ inputs.artifact-name }}
43+
pattern: ${{ inputs.split-artifact-pattern }}
44+
delete-merged: ${{ split-artifact-delete-merged }}
45+
46+
- name: Download JUnit reports artifact
47+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
48+
with:
49+
name: ${{ inputs.artifact-name }}
50+
path: junit-reports-artifact
51+
52+
- name: Clean up JUnit reports
53+
if: ${{ inputs.cleanup-junit-reports }}
54+
working-directory: junit-reports-artifact
55+
run: |
56+
echo -n "JUnit report size before cleanup: "
57+
du -sch *.xml | tail -n 1 | cut -f1
58+
for REPORT in *.xml; do
59+
xmlstarlet ed -d '//system-out' -d '//system-err' "$REPORT" > tmp-report.xml && mv tmp-report.xml "$REPORT"
60+
done
61+
echo -n "JUnit report size after cleanup: "
62+
du -sch *.xml | tail -n 1 | cut -f1
63+
64+
- name: Delete old JUnit reports
65+
if: ${{ inputs.delete-old-junit-reports }}
66+
working-directory: junit-reports
67+
run: git rm *.xml || true
68+
69+
- name: Copy new JUnit reports
70+
run: cp junit-reports-artifact/*.xml junit-reports/
71+
72+
- name: Update JUnit reports
73+
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
74+
with:
75+
message: 'Update JUnit reports'
76+
add: '*.xml'
77+
cwd: junit-reports
78+
branding:
79+
icon: archive
80+
color: blue

0 commit comments

Comments
 (0)