From ffe5e955c5d908b8ab14f157b273e4a582d7dd0a Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sun, 11 Sep 2022 22:26:00 +0300 Subject: [PATCH] Fix test artifact names (#716) * Fix test artifact names - Fixes empty parens in Linux artifacts - Fixes invalid artifact names containing * - Fixes Windows artifacts not being different from Linux ones * Fix Windows tests --- .github/workflows/test-push.yml | 10 ++++++---- build.gradle | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-push.yml b/.github/workflows/test-push.yml index e3e2d2d2..3fdd3704 100644 --- a/.github/workflows/test-push.yml +++ b/.github/workflows/test-push.yml @@ -56,14 +56,15 @@ 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 - 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 +84,15 @@ 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 - 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 diff --git a/build.gradle b/build.gradle index 002b43f2..7e9be933 100644 --- a/build.gradle +++ b/build.gradle @@ -334,4 +334,22 @@ task downloadGradleSources() { println("Downloading (${url}) to (${gradleApiSources})") gradleApiSources << new URL(url).newInputStream() } -} \ No newline at end of file +} + +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" + } +}