From de400ae2db03fce6608bd935eaa1e79f1bfcd8a3 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 17 Apr 2025 09:54:54 +0200 Subject: [PATCH] Fixed publishing code coverage results. --- .github/workflows/CompletePipeline.yml | 17 +++++++---- .github/workflows/PublishCoverageResults.yml | 28 +++++++++++++++---- .github/workflows/PublishTestResults.yml | 19 +++++++++++++ .github/workflows/_Checking_JobTemplates.yml | 14 +++++++--- .../_Checking_SimplePackage_Pipeline.yml | 1 + doc/requirements.txt | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 8 files changed, 66 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CompletePipeline.yml b/.github/workflows/CompletePipeline.yml index 9db08d2..315b913 100644 --- a/.github/workflows/CompletePipeline.yml +++ b/.github/workflows/CompletePipeline.yml @@ -102,6 +102,9 @@ on: PYPI_TOKEN: description: "Token for pushing releases to PyPI." required: false + CODECOV_TOKEN: + description: "Token for pushing coverage and unittest results to Codecov." + required: false CODACY_PROJECT_TOKEN: description: "Token for pushing coverage results to Codacy." required: false @@ -132,10 +135,10 @@ jobs: package_name: ${{ inputs.package_name }} python_version: ${{ inputs.apptest_python_version }} python_version_list: ${{ inputs.apptest_python_version_list }} - system_list: ${{ inputs.apptest_system_list }} - include_list: ${{ inputs.apptest_include_list }} - exclude_list: ${{ inputs.apptest_exclude_list }} - disable_list: ${{ inputs.apptest_disable_list }} + system_list: ${{ inputs.apptest_system_list }} + include_list: ${{ inputs.apptest_include_list }} + exclude_list: ${{ inputs.apptest_exclude_list }} + disable_list: ${{ inputs.apptest_disable_list }} UnitTesting: uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@dev @@ -211,9 +214,9 @@ jobs: 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 }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODACY_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} PublishTestResults: uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@dev @@ -225,6 +228,8 @@ jobs: additional_merge_args: '-d "--pytest=rewrite-dunder-init;reduce-depth:pytest.tests.unit"' merged_junit_filename: ${{ needs.ConfigParams.outputs.unittest_merged_report_xml_filename }} merged_junit_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).unittesting_xml }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # VerifyDocs: # uses: pyTooling/Actions/.github/workflows/VerifyDocs.yml@dev diff --git a/.github/workflows/PublishCoverageResults.yml b/.github/workflows/PublishCoverageResults.yml index 2eefb94..0ce487c 100644 --- a/.github/workflows/PublishCoverageResults.yml +++ b/.github/workflows/PublishCoverageResults.yml @@ -83,9 +83,22 @@ on: required: false default: 'report/coverage/html' type: string + codecov: + description: 'Publish merged coverage report to Codecov.' + required: false + default: true + type: boolean + codacy: + description: 'Publish merged coverage report to Codacy.' + required: false + default: true + type: boolean secrets: - codacy_token: - description: 'Token to push result to codacy.' + CODECOV_TOKEN: + description: 'Token to push result to Codecov.' + required: true + CODACY_TOKEN: + description: 'Token to push result to Codacy.' required: true jobs: @@ -128,7 +141,7 @@ jobs: run: coverage report --rcfile=pyproject.toml --data-file=.coverage - name: Convert to XML format (Cobertura) - if: inputs.coverage_xml_artifact != '' + if: inputs.coverage_xml_artifact != '' || inputs.codecov || inputs.codacy run: coverage xml --data-file=.coverage - name: Convert to JSON format @@ -187,17 +200,20 @@ jobs: - name: 📊 Publish code coverage at CodeCov uses: codecov/codecov-action@v5 - if: inputs.CodeCov == true + if: inputs.codecov continue-on-error: true with: + token: ${{ secrets.CODECOV_TOKEN }} + disable_search: true files: ${{ inputs.coverage_report_xml_directory }}/${{ inputs.coverage_report_xml_filename }} flags: unittests env_vars: PYTHON + fail_ci_if_error: true - name: 📉 Publish code coverage at Codacy uses: codacy/codacy-coverage-reporter-action@v1 - if: inputs.Codacy == true + if: inputs.codacy continue-on-error: true with: - project-token: ${{ secrets.codacy_token }} + project-token: ${{ secrets.CODACY_TOKEN }} coverage-reports: ${{ inputs.coverage_report_xml_directory }}/${{ inputs.coverage_report_xml_filename }} diff --git a/.github/workflows/PublishTestResults.yml b/.github/workflows/PublishTestResults.yml index 589e049..871abb8 100644 --- a/.github/workflows/PublishTestResults.yml +++ b/.github/workflows/PublishTestResults.yml @@ -59,6 +59,15 @@ on: required: false default: 'Unit Test Results' type: string + codecov: + description: 'Publish merged unittest results to Codecov.' + required: false + default: true + type: boolean + secrets: + CODECOV_TOKEN: + description: 'Token to push result to Codecov.' + required: true jobs: PublishTestResults: @@ -104,6 +113,16 @@ jobs: path: ${{ inputs.merged_junit_filename }} reporter: java-junit + - name: 📊 Publish unittest results at CodeCov + uses: codecov/test-results-action@v1 + if: inputs.codecov + with: + token: ${{ secrets.CODECOV_TOKEN }} + disable_search: true + files: ${{ inputs.merged_junit_filename }} + fail_ci_if_error: true + verbose: true + - name: 📤 Upload merged 'JUnit Test Summary' artifact uses: pyTooling/upload-artifact@v4 if: inputs.merged_junit_artifact != '' diff --git a/.github/workflows/_Checking_JobTemplates.yml b/.github/workflows/_Checking_JobTemplates.yml index 92662fe..230da9f 100644 --- a/.github/workflows/_Checking_JobTemplates.yml +++ b/.github/workflows/_Checking_JobTemplates.yml @@ -96,14 +96,20 @@ jobs: PublishCoverageResults: uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@dev needs: + - ConfigParams - UnitTestingParams - UnitTesting - PlatformTesting 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 }} diff --git a/.github/workflows/_Checking_SimplePackage_Pipeline.yml b/.github/workflows/_Checking_SimplePackage_Pipeline.yml index 3331c72..1f29e7e 100644 --- a/.github/workflows/_Checking_SimplePackage_Pipeline.yml +++ b/.github/workflows/_Checking_SimplePackage_Pipeline.yml @@ -9,6 +9,7 @@ jobs: uses: pyTooling/Actions/.github/workflows/CompletePipeline.yml@dev with: package_name: pyDummy + cleanup: false secrets: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} diff --git a/doc/requirements.txt b/doc/requirements.txt index 374a70e..c2de896 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,6 +1,6 @@ -r ../requirements.txt -pyTooling ~= 8.3 +pyTooling ~= 8.4 # Enforce latest version on ReadTheDocs sphinx ~= 8.2 diff --git a/pyproject.toml b/pyproject.toml index 796c0c9..6d28fca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools ~= 78.1", "wheel ~= 0.45", - "pyTooling ~= 8.3" + "pyTooling ~= 8.4" ] build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 88a2dac..3d2b3a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pyTooling ~= 8.3 +pyTooling ~= 8.4