Reduced number of parameters by passing JSON objects.

This commit is contained in:
Patrick Lehmann
2025-09-15 22:47:55 +02:00
parent e2e8b39c41
commit 1041e7b5c7
9 changed files with 389 additions and 429 deletions

View File

@@ -94,42 +94,42 @@ on:
required: false
default: 'unit'
type: string
unittest_report_xml_directory:
unittest_report_xml:
description: 'Path where to save the unittest summary report XML.'
required: false
default: 'report/unit'
type: string
unittest_report_xml_filename:
description: 'Filename of the unittest summary report XML.'
required: false
default: 'TestReportSummary.xml'
type: string
# unittest_report_xml_filename:
# description: 'Filename of the unittest summary report XML.'
# required: false
# default: 'TestReportSummary.xml'
# type: string
coverage_config:
description: 'Path to the .coveragerc file. Use pyproject.toml by default.'
required: false
default: 'pyproject.toml'
type: string
coverage_report_xml_directory:
coverage_report_xml:
description: 'Directory where the coverage report in XML format will be generated.'
required: false
default: 'report/coverage'
type: string
coverage_report_xml_filename:
description: 'Filename how the coverage report in XML format will be named.'
required: false
default: 'coverage.xml'
type: string
coverage_report_json_directory:
# coverage_report_xml_filename:
# description: 'Filename how the coverage report in XML format will be named.'
# required: false
# default: 'coverage.xml'
# type: string
coverage_report_json:
description: 'Directory where the coverage report in JSON format will be generated.'
required: false
default: 'report/coverage'
type: string
coverage_report_json_filename:
description: 'Filename how the coverage report in JSON format will be named.'
required: false
default: 'coverage.json'
type: string
coverage_report_html_directory:
# coverage_report_json_filename:
# description: 'Filename how the coverage report in JSON format will be named.'
# required: false
# default: 'coverage.json'
# type: string
coverage_report_html:
description: 'Directory where the coverage report in HTML format will be generated.'
required: false
default: 'report/coverage/html'
@@ -371,7 +371,7 @@ jobs:
export PYTHONPATH=$(pwd)
cd "${{ inputs.root_directory || '.' }}"
[ -n '${{ inputs.unittest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=${{ inputs.unittest_report_xml_directory }}/${{ inputs.unittest_report_xml_filename }}' || unset PYTEST_ARGS
[ -n '${{ inputs.unittest_xml_artifact }}' ] && PYTEST_ARGS='--junitxml=${{ fromJson(inputs.unittest_report_xml).fullpath }}' || unset PYTEST_ARGS
if [ -n '${{ inputs.coverage_config }}' ]; then
printf "%s\n" "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
@@ -389,7 +389,7 @@ jobs:
$env:PYTHONPATH = (Get-Location).ToString()
cd "${{ inputs.root_directory || '.' }}"
$PYTEST_ARGS = if ("${{ inputs.unittest_xml_artifact }}") { "--junitxml=${{ inputs.unittest_report_xml_directory }}/${{ inputs.unittest_report_xml_filename }}" } else { "" }
$PYTEST_ARGS = if ("${{ inputs.unittest_xml_artifact }}") { "--junitxml=${{ fromJson(inputs.unittest_report_xml).fullpath }}" } else { "" }
if ("${{ inputs.coverage_config }}") {
Write-Host "coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}"
coverage run --data-file=.coverage --rcfile=pyproject.toml -m pytest -raP $PYTEST_ARGS --color=yes ${{ inputs.tests_directory || '.' }}/${{ inputs.unittest_directory }}
@@ -415,19 +415,19 @@ jobs:
if: inputs.coverage_html_artifact != ''
continue-on-error: true
run: |
coverage html --data-file=.coverage -d ${{ inputs.coverage_report_html_directory }}
rm ${{ inputs.coverage_report_html_directory }}/.gitignore
coverage html --data-file=.coverage -d ${{ fromJson(inputs.coverage_report_html).directory }}
rm ${{ fromJson(inputs.coverage_report_html).directory }}/.gitignore
# Upload artifacts
- name: 📤 Upload '${{ inputs.unittest_report_xml_filename }}' artifact
- name: 📤 Upload '${{ fromJson(inputs.unittest_report_xml).filename }}' artifact
uses: pyTooling/upload-artifact@v4
if: inputs.unittest_xml_artifact != ''
continue-on-error: true
with:
name: ${{ inputs.unittest_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
working-directory: ${{ inputs.unittest_report_xml_directory }}
path: ${{ inputs.unittest_report_xml_filename }}
working-directory: ${{ fromJson(inputs.unittest_report_xml).directory }}
path: ${{ fromJson(inputs.unittest_report_xml).filename }}
if-no-files-found: error
retention-days: 1
@@ -458,8 +458,8 @@ jobs:
uses: pyTooling/upload-artifact@v4
with:
name: ${{ inputs.coverage_xml_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
working-directory: ${{ inputs.coverage_report_xml_directory }}
path: ${{ inputs.coverage_report_xml_filename }}
working-directory: ${{ fromJson(inputs.coverage_report_xml).directory }}
path: ${{ fromJson(inputs.coverage_report_xml).filename }}
if-no-files-found: error
retention-days: 1
@@ -469,8 +469,8 @@ jobs:
uses: pyTooling/upload-artifact@v4
with:
name: ${{ inputs.coverage_json_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
working-directory: ${{ inputs.coverage_report_json_directory }}
path: ${{ inputs.coverage_report_json_filename }}
working-directory: ${{ fromJson(inputs.coverage_report_json).directory }}
path: ${{ fromJson(inputs.coverage_report_json).filename }}
if-no-files-found: error
retention-days: 1
@@ -480,7 +480,7 @@ jobs:
uses: pyTooling/upload-artifact@v4
with:
name: ${{ inputs.coverage_html_artifact }}-${{ matrix.system }}-${{ matrix.runtime }}-${{ matrix.python }}
working-directory: ${{ inputs.coverage_report_html_directory }}
working-directory: ${{ fromJson(inputs.coverage_report_html).directory }}
path: '*'
if-no-files-found: error
retention-days: 1