Skip to content

Commit c22c6d2

Browse files
committed
Add integration test
1 parent 520fcba commit c22c6d2

File tree

3 files changed

+103
-2
lines changed

3 files changed

+103
-2
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Integration tests
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
7+
concurrency:
8+
group: integration-test-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
split-total: 4
13+
14+
jobs:
15+
generate-split-index-json:
16+
name: Generate split indexes
17+
runs-on: ubuntu-latest
18+
outputs:
19+
json: ${{ steps.generate.outputs.split-index-json }}
20+
steps:
21+
- name: Generate split index list
22+
id: generate
23+
uses: donnerbart/split-tests-java-action/generate-split-index-json@25d52b2bdc694f5077fde78908ee84fb23da4d90 # v1
24+
with:
25+
split-total: ${{ env.split-total }}
26+
27+
integration-test:
28+
name: "Test #${{ matrix.split-index }}"
29+
runs-on: ubuntu-latest
30+
needs:
31+
- generate-split-index-json
32+
permissions:
33+
contents: read
34+
checks: write
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
split-index: ${{ fromjson(needs.generate-split-index-json.outputs.json) }}
39+
env:
40+
DOWNLOAD_JAR: false
41+
JAR_PATH: build/libs/split-tests-java.jar
42+
steps:
43+
- name: Checkout split-test-java
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
45+
46+
- name: Set up JDK 21
47+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
48+
with:
49+
distribution: temurin
50+
java-version: 21
51+
52+
- name: Set up Gradle
53+
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4
54+
55+
- name: Compile split-tests-java
56+
run: ./gradlew shadowJar
57+
58+
- name: Split tests
59+
id: split-tests
60+
uses: donnerbart/split-tests-java-action@25d52b2bdc694f5077fde78908ee84fb23da4d90 # v1
61+
with:
62+
split-index: ${{ matrix.split-index }}
63+
split-total: ${{ env.split-total }}
64+
glob: '**/src/test/resources/tests/*Test.java'
65+
exclude-glob: '**/NoClassNameTest.java'
66+
junit-glob: '**/src/test/resources/reports/*.xml'
67+
format: 'list'
68+
new-test-time: 'average'
69+
calculate-optimal-total-split: true
70+
debug: true
71+
72+
- name: Assert split tests
73+
env:
74+
SPLIT_INDEX: ${{ matrix.split-index }}
75+
ACTUAL: ${{ steps.split-tests.outputs.test-suite }}
76+
run: |
77+
case "$SPLIT_INDEX" in
78+
"0")
79+
EXPECTED="de.donnerbart.example.SlowestTest"
80+
;;
81+
"1")
82+
EXPECTED="NoPackageTest de.donnerbart.example.ThirdPartyLibraryTest"
83+
;;
84+
"2")
85+
EXPECTED="de.donnerbart.example.NoTimingOneTest de.donnerbart.example.WhitespaceClassDefinitionTest"
86+
;;
87+
"3")
88+
EXPECTED="de.donnerbart.example.NoTimingTwoTest de.donnerbart.example.SlowTest de.donnerbart.example.FastTest"
89+
;;
90+
*)
91+
echo "Unexpected split index"
92+
exit 1
93+
;;
94+
esac
95+
echo "Expected: $EXPECTED"
96+
echo "Actual: $ACTUAL"
97+
if [ "$ACTUAL" != "$EXPECTED" ]; then
98+
echo "The split tests are not matching"
99+
exit 1
100+
fi

.github/workflows/check.yml renamed to .github/workflows/unit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Check
1+
name: Unit tests
22

33
on:
44
push:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[![CI Check](https://github.com/Donnerbart/split-tests-java/actions/workflows/check.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java/actions/workflows/check.yml)
1+
[![Unit tests](https://github.com/Donnerbart/split-tests-java/actions/workflows/unit-test.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java/actions/workflows/unit-test.yml)
2+
[![Integration tests](https://github.com/Donnerbart/split-tests-java/actions/workflows/integration-test.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java/actions/workflows/integration-test.yml)
23
[![Release](https://github.com/Donnerbart/split-tests-java/actions/workflows/release.yml/badge.svg)](https://github.com/Donnerbart/split-tests-java/actions/workflows/release.yml)
34

45
# Split Tests Java

0 commit comments

Comments
 (0)