PublishCoverageResults

The PublishCoverageResults job template downloads artifacts provided by UnitTesting containing code coverage databases created by Coverage.py. These databases are then merged and converted into various output formats like Cobertura XML, JSON or HTML. These outputs are either uploaded as a new artifact or can be published to cloud services like CodeCov or Codacy.

Instantiation

The following

jobs:
  ConfigParams:
    uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6
    with:
      package_name: myPackage

  UnitTestingParams:
    uses: pyTooling/Actions/.github/workflows/Parameters.yml@r6
    with:
      package_name: myPackage

  UnitTesting:
    uses: pyTooling/Actions/.github/workflows/UnitTesting.yml@r6
    needs:
      - ConfigParams
      - UnitTestingParams
    with:
      jobs:                     ${{ needs.UnitTestingParams.outputs.python_jobs }}
      coverage_sqlite_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_sqlite }}

  PublishCoverageResults:
    uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r6
    needs:
      - ConfigParams
      - UnitTestingParams
      - UnitTesting
    with:
      coverage_report_json:   ${{ needs.ConfigParams.outputs.coverage_report_json }}
      coverage_report_html:   ${{ needs.ConfigParams.outputs.coverage_report_html }}
      coverage_json_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_json }}
      coverage_html_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).codecoverage_html }}
      codecov:                'true'
      codacy:                 'true'
    secrets:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      CODACY_TOKEN:  ${{ secrets.CODACY_TOKEN }}

Parameter Summary

Goto input parameters

Parameter Name

Required

Type

Default

ubuntu_image_version

no

string

'24.04'

coverage_artifacts_pattern

no

string

'*-CodeCoverage-SQLite-*'

coverage_config

no

string

'pyproject.toml'

coverage_report_xml

no

string (JSON)

{"directory": "report/coverage", "filename": "coverage.xml", "fullpath": "report/coverage/coverage.xml"}

coverage_report_json

no

string (JSON)

{"directory": "report/coverage", "filename": "coverage.json", "fullpath": "report/coverage/coverage.json"}

coverage_report_html

no

string (JSON)

{"directory": "report/coverage/html"}

coverage_sqlite_artifact

no

string

''

coverage_xml_artifact

no

string

''

coverage_json_artifact

no

string

''

coverage_html_artifact

no

string

''

codecov

no

string

'false'

codacy

no

string

'false'

Goto secrets

Token Name

Required

Type

Default

CODECOV_TOKEN

no

string

— — — —

CODACY_TOKEN

no

string

— — — —

Goto output parameters

This job template has no output parameters.

Input Parameters

ubuntu_image_version

Type:

string

Required:

no

Default Value:

'24.04'

Possible Values:

See actions/runner-images - Available Images for available Ubuntu image versions.

Description:

Version of the Ubuntu image used to run the job.

Note

Unfortunately, GitHub Actions has only a limited set of functions, thus, the usual Ubuntu image name like 'ubuntu-24.04' can’t be split into image name and image version.

coverage_artifacts_pattern

Type:

string

Required:

no

Default Value:

'*-CodeCoverage-SQLite-*'

Possible Values:

Any valid artifact matching pattern using fixed text and * characters.

Description:

tbd

coverage_config

Type:

string

Required:

no

Default Value:

'pyproject.toml'

Possible Values:

Any valid path to a pyproject.toml file.
Alternatively, path to a .coveragerc file (deprecated).

Description:

Path to a Python project configuration file for extraction of project settings.

Example:

Extracted values from pyproject.toml

[tool.pytest]
junit_xml = "report/unit/UnittestReportSummary.xml"

[tool.pyedaa-reports]
junit_xml = "report/unit/unittest.xml"

[tool.coverage.xml]
output = "report/coverage/coverage.xml"

[tool.coverage.json]
output = "report/coverage/coverage.json"

[tool.coverage.html]
directory = "report/coverage/html"
title="Code Coverage of pyDummy"

coverage_report_xml

Type:

string (JSON)

Required:

no

Default Value:
{ "directory": "reports/coverage",
  "filename":  "coverage.xml",
  "fullpath":  "reports/coverage/coverage.xml"
}
Possible Values:

Any valid JSON string containing a JSON object with fields:

directory:

Directory or sub-directory where the code coverage report in Cobertura XML format will be saved.

filename:

Filename of the generated Cobertura XML report.
Any valid XML filename.

fullpath:

The concatenation of both previous fields using the / separator.

Description:

Directory, filename and fullpath as JSON object where the code coverage report in Cobertura XML format will be saved.
This path is configured in pyproject.toml and can be extracted by ExtractConfiguration.

Example:
ConfigParams:
  uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6

PublishCoverageResults:
  uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r6
  needs:
    - ConfigParams
  with:
    ...
    coverage_report_xml: ${{ needs.ConfigParams.outputs.coverage_report_xml }}

coverage_report_json

Type:

string (JSON)

Required:

no

Default Value:
{ "directory": "reports/coverage",
  "filename":  "coverage.json",
  "fullpath":  "reports/coverage/coverage.json"
}
Possible Values:

Any valid JSON string containing a JSON object with fields:

directory:

Directory or sub-directory where the code coverage report in Coverage.py’s JSON format will be saved.

filename:

Filename of the generated Coverage.py JSON report.
Any valid JSON filename.

fullpath:

The concatenation of both previous fields using the / separator.

Description:

Directory, filename and fullpath as JSON object where the code coverage report in Coverage.py’s JSON format will be saved.
This path is configured in pyproject.toml and can be extracted by ExtractConfiguration.

Example:
ConfigParams:
  uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6

PublishCoverageResults:
  uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r6
  needs:
    - ConfigParams
  with:
    ...
    coverage_report_json: ${{ needs.ConfigParams.outputs.coverage_report_json }}

coverage_report_html

Type:

string (JSON)

Required:

no

Default Value:
{ "directory": "reports/coverage/html"
}
Possible Values:

Any valid JSON string containing a JSON object with fields:

directory:

Directory or sub-directory where the code coverage report in HTML format will be saved.

Description:

Directory as JSON object where the code coverage report in HTML format will be saved.
This path is configured in pyproject.toml and can be extracted by ExtractConfiguration.

Example:
ConfigParams:
  uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6

PublishCoverageResults:
  uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r6
  needs:
    - ConfigParams
  with:
    ...
    coverage_report_html: ${{ needs.ConfigParams.outputs.coverage_report_html }}

coverage_sqlite_artifact

Type:

string

Required:

no

Default Value:

''

Possible Values:

Any valid artifact name.

Description:

Name of the artifact containing the merged SQLite code coverage database.

coverage_xml_artifact

Type:

string

Required:

no

Default Value:

''

Possible Values:

Any valid artifact name.

Description:

Name of the artifact containing the merged code coverage report as Cobertura XML file.

coverage_json_artifact

Type:

string

Required:

no

Default Value:

''

Possible Values:

Any valid artifact name.

Description:

Name of the artifact containing the merged code coverage report as Coverage.py JSON file.

coverage_html_artifact

Type:

string

Required:

no

Default Value:

'report/coverage/html'

Possible Values:

Any valid artifact name.

Description:

Name of the artifact containing the merged code coverage report as HTML report.

codecov

Type:

string

Required:

no

Default Value:

'false'

Possible Values:

'true', 'false'

Description:

If true, publish code coverage results to CodeCov.

codacy

Type:

string

Required:

no

Default Value:

'false'

Possible Values:

'true', 'false'

Description:

If true, publish code coverage results to Codacy.

Secrets

The workflow template uses the following secrets to publish results to other services.

CODECOV_TOKEN

Type:

string

Required:

no

Default Value:

— — — —

Description:

The token to publish code coverage and unit test results to CodeCov.

CODACY_TOKEN

Type:

string

Required:

no

Default Value:

— — — —

Description:

The token to publish code coverage results to Codacy.

Outputs

The following optimizations can be used to reduce the template’s runtime.

Disable code coverage SQLite database artifact upload

If parameter coverage_sqlite_artifact is empty, the collected code coverage database (SQLlite format) wont be uploaded as an artifact.

Disable code coverage report conversion to the Cobertura XML format.

If parameter coverage_xml_artifact is empty, no Cobertura XML file will be generated from code coverage report. As no Cobertura XML file exists, no code coverage XML artifact will be uploaded.

Disable code coverage report conversion to the Coverage.py JSON format.

If parameter coverage_json_artifact is empty, no Coverage.py JSON file will be generated from code coverage report. As no JSON file exists, no code coverage JSON artifact will be uploaded.

Disable code coverage report conversion to an HTML website.

If parameter coverage_html_artifact is empty, no coverage report HTML report will be generated from code coverage report. As no HTML report exists, no code coverage HTML artifact will be uploaded.

Todo

PublishCoverageResults:: Disable publishing to codecov and codacy.
If upload is enabled, XML will be always generated.