name: parallel-unit-tests #experimental work in progress - trying to figure out how to split tests across multi-modules by runtime on: workflow_dispatch: env: GRADLE_OPTS: "-Dorg.gradle.daemon=false" total-runners: 4 jobs: junit: runs-on: ubuntu-latest strategy: fail-fast: false matrix: runner_index: - 0 - 1 - 2 - 3 steps: - name: Checkout Repo uses: actions/checkout@v4.1.1 - name: Split tests id: split-tests uses: chaosaffe/split-tests@v1-alpha.1 with: glob: '**/src/test/java/**/*.java' split-total: ${{ env.total-runners }} split-index: ${{ matrix.runner_index }} line-count: true - name: Set up Java uses: actions/setup-java@v4.0.0 with: distribution: adopt java-version: 17 cache: gradle - name: write out test list run: echo "${{ steps.split-tests.outputs.test-suite }}" >> testList.txt - name: debug testfile paths run: cat testList.txt - name: format gradle args # regex means: truncate file paths to align with package name, replacing with tests switch, then drop file extension, # then swap path delimiter with package delimiter run: cat testList.txt | sed -e 's/[^ ]*src\/test\/java\//--tests\ /g' -e 's/\.java//g' -e 's/\//\./g' >> gradleArgs.txt - name: debug test class list run: cat gradleArgs.txt - name: run unit tests run: ./gradlew test `cat gradleArgs.txt`