Tests for PR 249 #223
Workflow file for this run
This file contains 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: Test PRs | |
run-name: Tests for PR ${{ github.event.pull_request.number }} | |
on: | |
pull_request: | |
types: | |
- synchronize | |
- opened | |
- ready_for_review | |
- reopened | |
concurrency: | |
group: ci-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
outputs: | |
tests-to-run: ${{ steps.test.outputs.tests-to-run }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1000 | |
fetch-tags: true | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'microsoft' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v3 | |
# Runs the collect-tests shell script and sets the output variable | |
- name: Determine tests to run | |
id: test | |
run: | | |
#!/bin/bash | |
./.github/scripts/collect-tests.sh | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1000 | |
fetch-tags: true | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'microsoft' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v3 | |
- name: Build | |
run: ./gradlew --info -s -x assemble | |
test: | |
name: "${{ matrix.test.displayName }} (${{ matrix.os }})" | |
runs-on: "${{ matrix.os }}-latest" | |
needs: setup | |
strategy: | |
max-parallel: 15 | |
fail-fast: false | |
matrix: | |
test: ${{ fromJSON(needs.setup.outputs.tests-to-run) }} | |
os: [ubuntu, windows, macos] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1000 | |
fetch-tags: true | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'microsoft' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Test | |
if: ${{ matrix.test.filter != null }} | |
run: ./gradlew --info -s ${{ matrix.test.path }} --tests "${{ matrix.test.filter }}" | |
- name: Test | |
if: ${{ matrix.test.filter == null }} | |
run: ./gradlew --info -s ${{ matrix.test.path }} | |
# Always upload test results | |
- name: Merge Test Reports | |
if: success() || failure() | |
run: npx junit-report-merger junit.xml "**/TEST-*.xml" | |
- name: Format test run name as artifact name | |
if: (success() || failure()) && runner.os == 'Windows' | |
id: format-artifact-name-windows | |
# Use the GITHUB_OUTPUT mechanic to set the output variable | |
run: | | |
# We need to remove all invalid characters from the test name: | |
# Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / | |
$NAME = "${{ matrix.test.displayName }}" -replace '[":<>|*?\\/]', '-' -replace ' ', '' | |
# Check if the GITHUB_OUTPUT is set | |
Write-Output "Determined name to be $NAME-${{ matrix.os }}" | |
if ([string]::IsNullOrEmpty($env:GITHUB_OUTPUT)) { | |
# We do not have github output, then use the set output command | |
Write-Output "::set-output name=artifact-name::$NAME-${{ matrix.os }}" | |
exit | |
} | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "artifact-name=$NAME-${{ matrix.os }}" | |
- name: Format test run name as artifact name | |
if: (success() || failure()) && runner.os != 'Windows' | |
id: format-artifact-name-unix | |
# Use the GITHUB_OUTPUT mechanic to set the output variable | |
run: | | |
# We need to remove all invalid characters from the test name: | |
# Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / | |
NAME=$(echo "${{ matrix.test.displayName }}" | tr '":<>|*?\\/' '-' | tr -d ' ') | |
# Check if the GITHUB_OUTPUT is set | |
echo "Determined name to be $NAME-${{ matrix.os }}" | |
if [ -z "$GITHUB_OUTPUT" ]; then | |
# We do not have github output, then use the set output command | |
echo "::set-output name=artifact-name::$NAME-${{ matrix.os }}" | |
exit 0 | |
fi | |
echo "artifact-name=$NAME-${{ matrix.os }}" >> "$GITHUB_OUTPUT" | |
- uses: actions/upload-artifact@v4 | |
if: (success() || failure()) && runner.os != 'Windows' | |
with: | |
if-no-files-found: ignore | |
name: test-results-${{ steps.format-artifact-name-unix.outputs.artifact-name }} | |
path: junit.xml | |
retention-days: 1 | |
- uses: actions/upload-artifact@v4 | |
if: (success() || failure()) && runner.os == 'Windows' | |
with: | |
if-no-files-found: ignore | |
name: test-results-${{ steps.format-artifact-name-windows.outputs.artifact-name }} | |
path: junit.xml | |
retention-days: 1 | |
process-test-data: | |
name: Process Test Data | |
runs-on: ubuntu-latest | |
needs: test | |
if: always() | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download reports' artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test-results-** | |
path: downloaded_artifacts | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: always() # always run even if the previous step fails | |
with: | |
report_paths: '**/*.xml' | |
- name: Merge Test Reports | |
if: always() | |
run: npx junit-report-merger junit.xml "**/*.xml" | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-results | |
path: junit.xml | |
- name: Failed build detection | |
uses: actions/github-script@v7 | |
if: >- | |
${{ | |
contains(needs.*.result, 'failure') | |
|| contains(needs.*.result, 'cancelled') | |
|| contains(needs.*.result, 'skipped') | |
}} | |
with: | |
script: | | |
core.setFailed('Test build failure!') | |