Add integration test #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration tests | |
| on: | |
| push: | |
| branches: ["**"] | |
| concurrency: | |
| group: integration-test-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| split-total: 4 | |
| jobs: | |
| generate-split-index-json: | |
| name: Generate split indexes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| json: ${{ steps.generate.outputs.split-index-json }} | |
| steps: | |
| - name: Checkout split-tests-java-action | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Generate split index list | |
| id: generate | |
| uses: ./generate-split-index-json | |
| with: | |
| split-total: ${{ env.split-total }} | |
| integration-test: | |
| name: "Test #${{ matrix.split-index }}" | |
| runs-on: ubuntu-latest | |
| needs: | |
| - generate-split-index-json | |
| permissions: | |
| contents: read | |
| checks: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| split-index: ${{ fromjson(needs.generate-split-index-json.outputs.json) }} | |
| env: | |
| DOWNLOAD_JAR: false | |
| JAR_PATH: split-tests-java/build/libs/split-tests-java.jar | |
| steps: | |
| - name: Checkout split-tests-java-action | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Checkout split-tests-java | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| with: | |
| repository: Donnerbart/split-tests-java | |
| path: split-tests-java | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4 | |
| - name: Compile split-tests-java | |
| working-directory: split-tests-java | |
| run: ./gradlew shadowJar | |
| - name: Split tests | |
| id: split-tests | |
| uses: ./ | |
| with: | |
| split-index: ${{ matrix.split-index }} | |
| split-total: ${{ env.split-total }} | |
| glob: '**/integration-test/tests/*Test.java' | |
| exclude-glob: '**/NoClassNameTest.java' | |
| junit-glob: '**/integration-test/reports/*.xml' | |
| format: 'list' | |
| new-test-time: 'average' | |
| calculate-optimal-total-split: true | |
| debug: true | |
| - name: Assert split tests | |
| env: | |
| SPLIT_INDEX: ${{ matrix.split-index }} | |
| ACTUAL: ${{ steps.split-tests.outputs.test-suite }} | |
| run: | | |
| case "$SPLIT_INDEX" in | |
| "0") | |
| EXPECTED="de.donnerbart.example.SlowestTest" | |
| ;; | |
| "1") | |
| EXPECTED="NoPackageTest de.donnerbart.example.ThirdPartyLibraryTest" | |
| ;; | |
| "2") | |
| EXPECTED="de.donnerbart.example.NoTimingOneTest de.donnerbart.example.WhitespaceClassDefinitionTest" | |
| ;; | |
| "3") | |
| EXPECTED="de.donnerbart.example.NoTimingTwoTest de.donnerbart.example.SlowTest de.donnerbart.example.FastTest" | |
| ;; | |
| *) | |
| echo "Unexpected split index" | |
| exit 1 | |
| ;; | |
| esac | |
| echo "Expected: $EXPECTED" | |
| echo "Actual: $ACTUAL" | |
| if [ "$ACTUAL" != "$EXPECTED" ]; then | |
| echo "The split tests are not matching" | |
| exit 1 | |
| fi |