From 2b3b021c91db79a24d71597f7740110fdc50867a Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sat, 4 Dec 2021 18:45:58 +0100 Subject: [PATCH 1/5] Added job template to publish unit test results. --- .github/workflows/PublishTestResults.yml | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/PublishTestResults.yml diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml new file mode 100644 index 0000000..3c2e81f --- /dev/null +++ b/.github/workflows/PublishTestResults.yml @@ -0,0 +1,54 @@ +# ============================================================================== +# Authors: +# Patrick Lehmann +# Unai Martinez-Corral +# +# ============================================================================== +# Copyright 2020-2021 The pyTooling Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============================================================================== +name: Publish Unit Test Results + +on: + workflow_call: + +jobs: + PublishTestResults: + name: 📊 Publish Test Results to Issue Comment + runs-on: ubuntu-latest + if: always() + + steps: + - name: ⏬ Checkout repository + uses: actions/checkout@v2 + + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + +# TODO: @umarcor do we want to make it optional or just kick it out? +# - name: 💬 Comment Unit Test Results in Pull Request +# uses: EnricoMi/publish-unit-test-result-action@v1 +# with: +# files: artifacts/**/*.xml + + - name: 📊 Publish Unit Test Results + uses: dorny/test-reporter@v1 + with: + name: Unit Test Results + path: artifacts/**/*.xml + reporter: java-junit From 4fac597238642bde377240d5d97a708b6a293db6 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sat, 4 Dec 2021 18:46:15 +0100 Subject: [PATCH 2/5] Added job into example pipeline. --- ExamplePipeline.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ExamplePipeline.yml b/ExamplePipeline.yml index 5bffa42..4976b46 100644 --- a/ExamplePipeline.yml +++ b/ExamplePipeline.yml @@ -49,6 +49,11 @@ jobs: requirements: '-r tests/requirements.txt' report: 'htmlmypy' + PublishTestResults: + uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@main + needs: + - UnitTesting + Package: uses: pyTooling/Actions/.github/workflows/Package.yml@main needs: From c2f7d273217bf164f83758762f9a49c937972efe Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 5 Dec 2021 13:36:50 +0100 Subject: [PATCH 3/5] Removed 'EnricoMi/publish-unit-test-result-action'. --- .github/workflows/PublishTestResults.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml index 3c2e81f..41e60f4 100644 --- a/.github/workflows/PublishTestResults.yml +++ b/.github/workflows/PublishTestResults.yml @@ -40,12 +40,6 @@ jobs: with: path: artifacts -# TODO: @umarcor do we want to make it optional or just kick it out? -# - name: 💬 Comment Unit Test Results in Pull Request -# uses: EnricoMi/publish-unit-test-result-action@v1 -# with: -# files: artifacts/**/*.xml - - name: 📊 Publish Unit Test Results uses: dorny/test-reporter@v1 with: From 40856aa731bef048c794ee67dc82a05a58a66e0d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 6 Dec 2021 16:57:03 +0100 Subject: [PATCH 4/5] Removed `to Issue Comment` from job name. --- .github/workflows/PublishTestResults.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml index 41e60f4..1b551e4 100644 --- a/.github/workflows/PublishTestResults.yml +++ b/.github/workflows/PublishTestResults.yml @@ -27,7 +27,7 @@ on: jobs: PublishTestResults: - name: 📊 Publish Test Results to Issue Comment + name: 📊 Publish Test Results runs-on: ubuntu-latest if: always() From 774ea7970e32cd1983d1fb57a41e1f43cc769347 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 7 Dec 2021 20:09:11 +0100 Subject: [PATCH 5/5] Added input parameter to the template and documented in the README. --- .github/workflows/PublishTestResults.yml | 8 +++++++- ExamplePipeline.yml | 3 +++ README.md | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml index 1b551e4..670e3b0 100644 --- a/.github/workflows/PublishTestResults.yml +++ b/.github/workflows/PublishTestResults.yml @@ -24,6 +24,12 @@ name: Publish Unit Test Results on: workflow_call: + inputs: + report_files: + description: 'Pattern of report files to upload. Can be a comma separated list.' + required: false + default: 'artifacts/**/*.xml' + type: string jobs: PublishTestResults: @@ -44,5 +50,5 @@ jobs: uses: dorny/test-reporter@v1 with: name: Unit Test Results - path: artifacts/**/*.xml + path: ${{ inputs.report_files }} reporter: java-junit diff --git a/ExamplePipeline.yml b/ExamplePipeline.yml index 4976b46..3e56ced 100644 --- a/ExamplePipeline.yml +++ b/ExamplePipeline.yml @@ -53,6 +53,9 @@ jobs: uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@main needs: - UnitTesting + with: + # Optional + report_files: artifacts/**/*.xml Package: uses: pyTooling/Actions/.github/workflows/Package.yml@main diff --git a/README.md b/README.md index de87c38..94e0902 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ As shown in the screenshot above, the expected order is: - [Release](.github/workflows/Release.yml): publish GitHub Release. - [Package](.github/workflows/Package.yml): generate source and wheel packages, and upload them as an artifact. - [PublishOnPyPI](.github/workflows/PublishOnPyPI.yml): publish source and wheel packages to PyPI. + - [PublishTestResults](.github/workflows/PublishTestResults.yml): publish unit test results through GH action `dorny/test-reporter`. - Documentation: - [BuildTheDocs](.github/workflows/BuildTheDocs.yml): build Sphinx documentation with BuildTheDocs, and upload HTML as an artifact.