diff --git a/.github/workflows/CompletePipeline.yml b/.github/workflows/CompletePipeline.yml index 30f6c5e..9db08d2 100644 --- a/.github/workflows/CompletePipeline.yml +++ b/.github/workflows/CompletePipeline.yml @@ -172,7 +172,7 @@ jobs: - UnitTestingParams with: python_version: ${{ needs.UnitTestingParams.outputs.python_version }} - directory: ${{ inputs.package_namespace }}/${{ inputs.package_name }} + directory: ${{ inputs.package_namespace }}/${{ inputs.package_name }} # fail_below: 70 Package: @@ -182,7 +182,7 @@ jobs: - UnitTesting with: python_version: ${{ needs.UnitTestingParams.outputs.python_version }} - artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} # AppTesting: # uses: pyTooling/Actions/.github/workflows/ApplicationTesting.yml@dev @@ -198,13 +198,20 @@ jobs: PublishCoverageResults: uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@dev needs: + - ConfigParams - UnitTestingParams - UnitTesting with: -# coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }} -# coverage_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }} - coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} - coverage_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} +# coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }} +# coverage_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_xml }} +# coverage_report_xml_directory: ${{ needs.ConfigParams.outputs.coverage_report_xml_directory }} +# coverage_report_xml_filename: ${{ needs.ConfigParams.outputs.coverage_report_xml_filename }} + coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} + coverage_report_json_directory: ${{ needs.ConfigParams.outputs.coverage_report_json_directory }} + coverage_report_json_filename: ${{ needs.ConfigParams.outputs.coverage_report_json_filename }} + coverage_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} + coverage_report_html_directory: ${{ needs.ConfigParams.outputs.coverage_report_html_directory }} + secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} @@ -235,12 +242,12 @@ jobs: - PublishCoverageResults # - VerifyDocs with: - python_version: ${{ needs.UnitTestingParams.outputs.python_version }} + python_version: ${{ needs.UnitTestingParams.outputs.python_version }} coverage_report_json_directory: ${{ needs.ConfigParams.outputs.coverage_report_json_directory }} - unittest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} - coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} - html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} - latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }} + unittest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} + coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }} + html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + latex_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_latex }} IntermediateCleanUp: uses: pyTooling/Actions/.github/workflows/IntermediateCleanUp.yml@dev @@ -252,7 +259,7 @@ jobs: if: ${{ inputs.cleanup }} with: sqlite_coverage_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}- - xml_unittest_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}- + xml_unittest_artifacts_prefix: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }}- # PDFDocumentation: # uses: pyTooling/Actions/.github/workflows/LaTeXDocumentation.yml@dev @@ -273,9 +280,9 @@ jobs: - PublishCoverageResults - StaticTypeCheck with: - doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} + doc: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).documentation_html }} coverage: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }} - typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} + typing: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).statictyping_html }} ReleasePage: uses: pyTooling/Actions/.github/workflows/Release.yml@dev diff --git a/.github/workflows/PublishCoverageResults.yml b/.github/workflows/PublishCoverageResults.yml index c833832..2eefb94 100644 --- a/.github/workflows/PublishCoverageResults.yml +++ b/.github/workflows/PublishCoverageResults.yml @@ -48,16 +48,41 @@ on: required: false default: '' type: string + coverage_report_xml_directory: + description: 'Directory containing the XML coverage report file.' + required: false + default: 'report/coverage' + type: string + coverage_report_xml_filename: + description: 'Filename of the XML coverage report file.' + required: false + default: 'coverage.xml' + type: string coverage_json_artifact: description: 'Name of the JSON coverage artifact.' required: false default: '' type: string + coverage_report_json_directory: + description: 'Directory containing the JSON coverage report file.' + required: false + default: 'report/coverage' + type: string + coverage_report_json_filename: + description: 'Filename of the JSON coverage report file.' + required: false + default: 'coverage.json' + type: string coverage_html_artifact: description: 'Name of the HTML coverage artifact.' required: false default: '' type: string + coverage_report_html_directory: + description: 'HTML root directory of the generated coverage report.' + required: false + default: 'report/coverage/html' + type: string secrets: codacy_token: description: 'Token to push result to codacy.' @@ -90,66 +115,6 @@ jobs: run: | python -m pip install -U --disable-pip-version-check --break-system-packages coverage[toml] tomli - - name: 🔁 Extract configurations from pyproject.toml - id: getVariables - shell: python - run: | - from os import getenv - from pathlib import Path - from sys import version - from textwrap import dedent - - print(f"Python: {version}") - - from tomli import load as tomli_load - - htmlDirectory = Path("htmlcov") - xmlFile = Path("./coverage.xml") - jsonFile = Path("./coverage.json") - coverageRC = "${{ inputs.coverage_config }}".strip() - - # Read output paths from 'pyproject.toml' file - if coverageRC == "pyproject.toml": - pyProjectFile = Path("pyproject.toml") - if pyProjectFile.exists(): - with pyProjectFile.open("rb") as file: - pyProjectSettings = tomli_load(file) - - htmlDirectory = Path(pyProjectSettings["tool"]["coverage"]["html"]["directory"]) - xmlFile = Path(pyProjectSettings["tool"]["coverage"]["xml"]["output"]) - jsonFile = Path(pyProjectSettings["tool"]["coverage"]["json"]["output"]) - else: - print(f"File '{pyProjectFile}' not found.") - print(f"::error title=FileNotFoundError::File '{pyProjectFile}' not found.") - exit(1) - - # Read output paths from '.coveragerc' file - elif len(coverageRC) > 0: - coverageRCFile = Path(coverageRC) - if coverageRCFile.exists(): - with coverageRCFile.open("rb") as file: - coverageRCSettings = tomli_load(file) - - htmlDirectory = Path(coverageRCSettings["html"]["directory"]) - xmlFile = Path(coverageRCSettings["xml"]["output"]) - jsonFile = Path(coverageRCSettings["json"]["output"]) - else: - print(f"File '{coverageRCFile}' not found.") - print(f"::error title=FileNotFoundError::File '{coverageRCFile}' not found.") - exit(1) - - # Write jobs to special file - github_output = Path(getenv("GITHUB_OUTPUT")) - print(f"GITHUB_OUTPUT: {github_output}") - with github_output.open("a+", encoding="utf-8") as f: - f.write(dedent(f"""\ - coverage_report_html_directory={htmlDirectory.as_posix()} - coverage_report_xml={xmlFile} - coverage_report_json={jsonFile} - """)) - - print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}\n json={jsonFile}") - - name: Rename .coverage files and move them all into 'coverage/' run: | mkdir -p coverage @@ -193,7 +158,8 @@ jobs: continue-on-error: true with: name: ${{ inputs.coverage_xml_artifact }} - path: ${{ steps.getVariables.outputs.coverage_report_xml }} + working-directory: ${{ inputs.coverage_report_xml_directory }} + path: ${{ inputs.coverage_report_xml_filename }} if-no-files-found: error retention-days: 1 @@ -203,7 +169,8 @@ jobs: continue-on-error: true with: name: ${{ inputs.coverage_json_artifact }} - path: ${{ steps.getVariables.outputs.coverage_report_json }} + working-directory: ${{ inputs.coverage_report_json_directory }} + path: ${{ inputs.coverage_report_json_filename }} if-no-files-found: error retention-days: 1 @@ -213,7 +180,7 @@ jobs: continue-on-error: true with: name: ${{ inputs.coverage_html_artifact }} - working-directory: ${{ steps.getVariables.outputs.coverage_report_html_directory }} + working-directory: ${{ inputs.coverage_report_html_directory }} path: '*' if-no-files-found: error retention-days: 1 @@ -223,7 +190,7 @@ jobs: if: inputs.CodeCov == true continue-on-error: true with: - files: ${{ steps.getVariables.outputs.coverage_report_xml }} + files: ${{ inputs.coverage_report_xml_directory }}/${{ inputs.coverage_report_xml_filename }} flags: unittests env_vars: PYTHON @@ -233,4 +200,4 @@ jobs: continue-on-error: true with: project-token: ${{ secrets.codacy_token }} - coverage-reports: ${{ steps.getVariables.outputs.coverage_report_xml }} + coverage-reports: ${{ inputs.coverage_report_xml_directory }}/${{ inputs.coverage_report_xml_filename }}