From c549c5fd7a0219b382e34fbdffa2cb470c19270d Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Thu, 8 Sep 2022 03:59:29 +0300 Subject: [PATCH] Create test report (#102) --- .github/workflows/test.yml | 47 ++++++++++++++++++++++++++++++++++---- build.gradle | 18 +++++++++++++++ 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3e2d2d2..476e6eff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,14 +56,22 @@ jobs: steps: - uses: actions/checkout@v2 - - run: gradle test --tests ${{ matrix.test }} --stacktrace --warning-mode fail + - run: gradle printActionsTestName --name="${{ matrix.test }}" test --tests ${{ matrix.test }} --stacktrace --warning-mode fail env: TEST_WARNING_MODE: fail + id: test + - name: Publish test results for report + uses: actions/upload-artifact@v2 + if: ${{ failure() || success() }} + with: + name: Raw Test Results + path: build/test-results/**/*.xml + retention-days: 1 - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: - name: ${{ matrix.test }} (${{ matrix.java }}) Results + name: ${{ steps.test.outputs.test }} Results path: build/reports/ run_tests_windows: @@ -83,14 +91,22 @@ jobs: uses: actions/setup-java@v1 with: java-version: ${{ matrix.java }} - - run: ./gradlew test --tests ${{ matrix.test }} --stacktrace --warning-mode fail + - run: ./gradlew printActionsTestName --name="${{ matrix.test }}" test --tests ${{ matrix.test }} --stacktrace --warning-mode fail env: TEST_WARNING_MODE: fail + id: test + - name: Publish test results for report + uses: actions/upload-artifact@v2 + if: ${{ failure() || success() }} + with: + name: Raw Test Results + path: build/test-results/**/*.xml + retention-days: 1 - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: - name: ${{ matrix.test }} (${{ matrix.java }}) Results + name: ${{ steps.test.outputs.test }} (${{ matrix.java }}) Results (Windows) path: build/reports/ # Special case this test to run across all os's @@ -111,9 +127,30 @@ jobs: java-version: ${{ matrix.java }} - run: ./gradlew test --tests *ReproducibleBuildTest --stacktrace --warning-mode fail + - name: Publish test results for report + uses: actions/upload-artifact@v2 + if: ${{ failure() || success() }} + with: + name: Raw Test Results + path: build/test-results/**/*.xml + retention-days: 1 - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: name: Reproducible Build ${{ matrix.os }} (${{ matrix.java }}) Results - path: build/reports/ \ No newline at end of file + path: build/reports/ + + test_report: + runs-on: ubuntu-latest + needs: [run_tests, run_tests_windows, reproducible_build_test] + if: ${{ failure() || success() }} + steps: + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Publish test report + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + junit_files: "artifacts/**/*.xml" diff --git a/build.gradle b/build.gradle index d0ee384f..bed37e7b 100644 --- a/build.gradle +++ b/build.gradle @@ -362,3 +362,21 @@ task downloadGradleSources() { tasks.withType(GenerateModuleMetadata) { enabled = false } + +task printActionsTestName(type: PrintActionsTestName) { +} + +/** + * Replaces invalid characters in test names for GitHub Actions artifacts. + */ +class PrintActionsTestName extends DefaultTask { + @Input + @Option(option = "name", description = "The test name") + String testName + + @TaskAction + def run() { + def sanitised = testName.replace('*', '_') + println "::set-output name=test::$sanitised" + } +}