experiment: parallel running tests #134
Workflow file for this run
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: Unit Tests | ||
| on: | ||
| workflow_call: | ||
| env: | ||
| total-runners: 6 | ||
| jobs: | ||
| dependency-branches: | ||
| name: Dependency Branches | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| branches: ${{ steps.result.outputs.branches }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: supertokens/get-core-dependencies-action@main | ||
| id: result | ||
| with: | ||
| run-for: PR | ||
| runner-indexes: | ||
| runs-on: ubuntu-latest | ||
| name: Generate runner indexes | ||
| needs: dependency-branches | ||
| outputs: | ||
| json: ${{ steps.generate-index-list.outputs.json }} | ||
| steps: | ||
| - id: generate-index-list | ||
| run: | | ||
| MAX_INDEX=$((${{ env.total-runners }}-1)) | ||
| INDEX_LIST=$(seq 0 ${MAX_INDEX}) | ||
| INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) | ||
| echo "::set-output name=json::${INDEX_JSON}" | ||
| run-parallel-tests: | ||
| runs-on: ubuntu-latest | ||
| name: "Runner #${{ matrix.runner-index }}: Run test suite in parallel" | ||
| needs: | ||
| - runner-indexes | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| runner-index: ${{ fromjson(needs.runner-indexes.outputs.json) }} | ||
| plugin: | ||
| - sqlite | ||
| - postgresql | ||
| steps: | ||
| - steps: | ||
| - name: Set up JDK 15.0.1 | ||
| uses: actions/setup-java@v2 | ||
| with: | ||
| java-version: 15.0.1 | ||
| distribution: zulu | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| repository: supertokens/supertokens-root | ||
| path: ./supertokens-root | ||
| ref: for_jdk_15_releases | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| path: ./supertokens-root/supertokens-core | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| repository: supertokens/supertokens-plugin-interface | ||
| path: ./supertokens-root/supertokens-plugin-interface | ||
| ref: ${{ fromJson(needs.dependency-branches.outputs.branches)['plugin-interface'] }} | ||
| - uses: actions/checkout@v2 | ||
| if: matrix.plugin != 'sqlite' | ||
| with: | ||
| repository: supertokens/supertokens-${{ matrix.plugin }}-plugin | ||
| path: ./supertokens-root/supertokens-${{ matrix.plugin }}-plugin | ||
| ref: ${{ fromJson(needs.dependency-branches.outputs.branches)[matrix.plugin] }} | ||
| - name: Load Modules | ||
| run: | | ||
| cd supertokens-root | ||
| echo "core,master | ||
| plugin-interface,master | ||
| ${{ matrix.plugin }}-plugin,master | ||
| " > modules.txt | ||
| cat modules.txt | ||
| ./loadModules | ||
| - name: Setup test env | ||
| run: cd supertokens-root && ./utils/setupTestEnv --local | ||
| - name: Start ${{ matrix.plugin }} server | ||
| if: matrix.plugin != 'sqlite' | ||
| run: cd supertokens-root/supertokens-${{ matrix.plugin }}-plugin && ./startDb.sh | ||
| - uses: actions/checkout@v2 | ||
| - uses: chaosaffe/split-tests@v1-alpha.1 | ||
| id: split-tests | ||
| name: Split tests | ||
| with: | ||
| glob: 'src/test/java/**/*.java' | ||
| split-total: ${{ env.total-runners }} | ||
| split-index: ${{ matrix.runner-index }} | ||
| - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' | ||
| - name: Run tests | ||
| env: | ||
| ST_PLUGIN_NAME: ${{ matrix.plugin }} | ||
| run: | | ||
| cd supertokens-root | ||
| ./gradlew test ${{ steps.split-tests.outputs.test-suite }} | ||
| - name: Publish Test Report | ||
| uses: mikepenz/action-junit-report@v5 | ||
| if: always() | ||
| with: | ||
| report_paths: '**/build/test-results/test/TEST-*.xml' | ||
| detailed_summary: true | ||
| include_passed: false | ||
| annotate_notice: true | ||