Skip to content

Commit 808fc62

Browse files
committed
Add merging of JUnit reports to integration test
1 parent f4b126f commit 808fc62

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

.github/workflows/integration-test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,70 @@ jobs:
108108
echo "The split tests are not matching"
109109
exit 1
110110
fi
111+
112+
- name: Create simulated JUnit report
113+
run: |
114+
mkdir -p build/reports/test-results
115+
CLASS="de.donnerbart.example.ActionSplit${{ matrix.split-index }}Test"
116+
FILE="build/reports/test-results/TEST-$CLASS.xml"
117+
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $FILE
118+
echo "<testsuite name=\"$CLASS\" tests=\"1\" skipped=\"0\" failures=\"0\" errors=\"0\" timestamp=\"1970-01-01T00:00:00\" hostname=\"foobar\" time=\"23.42\">" >> $FILE
119+
echo " <properties/>" >> $FILE
120+
echo " <testcase name=\"testMethod()\" classname=\"$CLASS\" time=\"23.42\">" >> $FILE
121+
echo " <system-out><![CDATA[00:00:00.000 [Test] INFO Test log for split ${{ matrix.split-index }}" >> $FILE
122+
echo "00:00:00.001 [Test] INFO Done" >> $FILE
123+
echo "]]></system-out>" >> $FILE
124+
echo " <system-err><![CDATA[]]></system-err>" >> $FILE
125+
echo " </testcase>" >> $FILE
126+
echo "</testsuite>" >> $FILE
127+
128+
- name: Upload JUnit report artifact
129+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
130+
with:
131+
name: junit-xml-reports-${{ matrix.split-index }}
132+
path: build/reports/test-results/*.xml
133+
134+
merge-junit-reports:
135+
name: Merge JUnit reports
136+
runs-on: ubuntu-latest
137+
needs:
138+
- integration-test
139+
permissions:
140+
contents: write
141+
steps:
142+
- name: Checkout split-tests-java-action
143+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
144+
145+
- name: Merge JUnit reports
146+
uses: ./merge-junit-reports
147+
with:
148+
git-branch: junit-reports-it-${{ github.sha }}
149+
artifact-name: junit-xml-reports
150+
split-artifact-pattern: junit-xml-reports-*
151+
152+
- name: Checkout JUnit reports
153+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
154+
with:
155+
path: junit-reports-assertion
156+
ref: junit-reports-it-${{ github.sha }}
157+
158+
- name: Assert JUnit reports
159+
working-directory: junit-reports-assertion
160+
run: |
161+
ls -l
162+
163+
- name: Download JUnit reports artifact
164+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4
165+
with:
166+
name: junit-xml-reports
167+
path: junit-reports-artifact-assertion
168+
169+
- name: Assert JUnit reports artifact
170+
working-directory: junit-reports-artifact-assertion
171+
run: |
172+
ls -l
173+
174+
- name: Cleanup JUnit reports branch
175+
if: always()
176+
run: |
177+
git push origin --delete junit-reports-it-${{ github.sha }} || true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
debug: true
7979

8080
- name: Run integration tests
81-
run: ./gradlew :integrationTest ${{ steps.split-tests.outputs.test-suite }}
81+
run: ./gradlew :integrationTest ${{ steps.split-tests.outputs.test-suite }}
8282

8383
- name: Upload JUnit report artifact
8484
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)