From 6e501b3ead0390801e030c7d5ecced5383d4686a Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 29 Nov 2021 22:49:56 +0100 Subject: [PATCH] UnitTesting: make the artifact name an option; generate it in Params --- .github/workflows/Params.yml | 1 + .github/workflows/UnitTesting.yml | 8 ++++---- ExamplePipeline.yml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Params.yml b/.github/workflows/Params.yml index 5d6fc5e..6817022 100644 --- a/.github/workflows/Params.yml +++ b/.github/workflows/Params.yml @@ -43,6 +43,7 @@ jobs: 'name': name, 'python_version': '${{ inputs.python_version }}', 'artifacts': { + 'unittesting': f'{name}-TestReport', 'coverage': f'{name}-coverage', 'typing': f'{name}-typing', 'package': f'{name}-package', diff --git a/.github/workflows/UnitTesting.yml b/.github/workflows/UnitTesting.yml index 45a83b0..47c53b8 100644 --- a/.github/workflows/UnitTesting.yml +++ b/.github/workflows/UnitTesting.yml @@ -12,10 +12,10 @@ on: required: false default: '-r tests/requirements.txt' type: string - TestReport: + artifact: description: "Generate unit test report with junitxml and upload results as an artifact." required: false - default: false + default: '' type: string jobs: @@ -45,14 +45,14 @@ jobs: - name: ☑ Run unit tests run: | - [ '${{ inputs.TestReport }}' = 'true' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS + [ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS python -m pytest -rA tests/unit $PYTEST_ARGS --color=yes - name: 📤 Upload 'TestReport.xml' artifact if: inputs.TestReport == 'true' uses: actions/upload-artifact@v2 with: - name: TestReport-${{ matrix.python }} + name: ${{ inputs.artifact }}-${{ matrix.python }} path: TestReport.xml if-no-files-found: error retention-days: 1 diff --git a/ExamplePipeline.yml b/ExamplePipeline.yml index 1f76246..4e69223 100644 --- a/ExamplePipeline.yml +++ b/ExamplePipeline.yml @@ -21,7 +21,7 @@ jobs: jobs: ${{ needs.Params.outputs.python_jobs }} # Optional requirements: '-r tests/requirements.txt' - TestReport: true + artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }} Coverage: uses: pyTooling/Actions/.github/workflows/CoverageCollection.yml@dev