Skip to content

build: Fix test artifacts #70

build: Fix test artifacts

build: Fix test artifacts #70

Workflow file for this run

name: Run Tests
on:
push:
branches:
- '**'
tags-ignore:
- stage0/v*
- stage2/v*
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
16
17
# Can't use setup-java for this because https://github.com/actions/setup-java/issues/366
- uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-caches-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle.properties', 'gradle/*.versions.toml') }}
restore-keys: |
gradle-caches-${{ hashFiles('**/*.gradle*') }}
gradle-caches-
- run: ./gradlew build -x integrationTest setupDownloadsApi --stacktrace
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: Raw Test Results
path: "**/build/test-results/**/*.xml"
retention-days: 1 # only for the report at the end
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: Unit Test Results
path: "**/build/reports/"
- uses: actions/cache/save@v4
with:
path: |
**/.gradle
**/build
key: test-build-${{ github.run_id }}-${{ github.run_attempt }}
prepare_integration_test_matrix:
needs: build # don't even bother with tests if it doesn't even build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
id: create-matrix
with:
script: |
const tests = []
for (platform of ["launchwrapper", "fabric"]) {
const prefix = `integrationTest/${platform}/src/main/java/`
for await (const file of (await glob.create(`${prefix}/**/*Tests.java`)).globGenerator()) {
const cls = file.slice(file.indexOf(prefix) + prefix.length, file.length - 5).replaceAll("/", ".")
tests.push({ platform, "class": cls })
}
}
return tests
github-token: dummy # we don't need one but it'll complain without one (when running locally via act)
outputs:
matrix: ${{ steps.create-matrix.outputs.result }}
integration_tests:
needs:
- prepare_integration_test_matrix
- build # we'll want to re-use the caches it produces
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.prepare_integration_test_matrix.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
8
16
17
- uses: actions/cache/restore@v4
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}
- uses: actions/cache/restore@v4
with:
path: ~/.gradle/caches
key: gradle-caches-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle.properties', 'gradle/*.versions.toml') }}
- uses: actions/cache/restore@v4
with:
path: |
**/.gradle
**/build
key: test-build-${{ github.run_id }}-${{ github.run_attempt }}
- run: ./gradlew :integrationTest:${{ matrix.test.platform }}:integrationTest --tests ${{ matrix.test.class }} --stacktrace
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: ${{ matrix.test.platform }}_${{ matrix.test.class }} Results
path: integrationTest/${{ matrix.test.platform }}/build/test-results/**/*.xml
retention-days: 1 # only for the report at the end
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ matrix.test.platform }}_${{ matrix.test.class }} Reports
path: integrationTest/${{ matrix.test.platform }}/build/reports/
test_report:
runs-on: ubuntu-latest
needs: [build, integration_tests]
if: ${{ !cancelled() }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish test report
uses: EnricoMi/publish-unit-test-result-action@567cc7f8dcea3eba5da355f6ebc95663310d8a07 # v2.17.0
with:
junit_files: "artifacts/**/*.xml"