StaticTypeCheck
This job template runs a static type check using mypy and collects the results. These results can be converted to a HTML report and uploaded as an artifact.
Instantiation
Simple Example
This example runs mypy for the Python package myPackage
according to the configuration stored in
pyproject.toml
. It prints a report into the job’s log. In addition is generates a report in HTML format into the
directory report/typing
.
jobs:
StaticTypeCheck:
uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r6
with:
cobertura_artifact: 'TypeChecking-Cobertura'
junit_artifact: 'TypeChecking-JUnit'
html_artifact: 'TypeChecking-HTML'
[tool.mypy]
packages = ["myPackage"]
strict = true
pretty = true
html_report = "report/typing/html"
junit_xml = "report/typing/StaticTypingSummary.xml"
cobertura_xml_report = "report/typing"
Complex Example
To ease the handling of mypy parameters stored in pyproject.toml
, the ExtractConfiguration is
used to extract the set configuration parameters for later usage. Similarly, Parameters is used to
precompute the artifact’s name.
jobs:
ConfigParams:
uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6
with:
package_name: myPackage
Params:
uses: pyTooling/Actions/.github/workflows/Parameters.yml@r6
with:
package_name: myPackage
StaticTypeCheck:
uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r6
needs:
- ConfigParams
- Params
with:
python_version: ${{ needs.Params.outputs.python_version }}
junit_report: ${{ needs.ConfigParams.outputs.typing_report_junit }}
junit_artifact: ${{ fromJson(needs.Params.outputs.artifact_names).statictyping_junit }}
Parameter Summary
Goto input parameters
Parameter Name |
Required |
Type |
Default |
---|---|---|---|
no |
string |
|
|
no |
string |
|
|
no |
string |
|
|
no |
string |
|
|
no |
string (JSON) |
|
|
no |
string (JSON) |
|
|
no |
string (JSON) |
|
|
no |
string |
|
|
no |
string |
|
|
no |
string |
|
Goto secrets
This job template needs no secrets.
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.
python_version
- Type:
string
- Required:
no
- Default Value:
'3.13'
- Possible Values:
Any valid Python version conforming to the pattern
<major>.<minor>
orpypy-<major>.<minor>
.
See actions/python-versions - available Python versions and actions/setup-python - configurable Python versions.- Description:
Python version used to run Python code in the job.
requirements
- Type:
string
- Required:
no
- Default Value:
'-r tests/requirements.txt'
- Possible Values:
Any valid list of parameters for
pip install
.
Either a requirements file can be referenced using'-r path/to/requirements.txt'
, or a list of packages can be specified using a space separated list like'mypy lxml'
.- Description:
Python dependencies to be installed through pip.
mypy_options
- Type:
string
- Required:
no
- Default Value:
''
- Possible Values:
Any valid command line options for mypy.
- Description:
Additional options handed over to mypy as
mypy ${mypy_options}
.
cobertura_report
- Type:
string (JSON)
- Required:
no
- Default Value:
{ "directory": "reports/typing", "filename": "cobertura.xml", "fullpath": "reports/typing/cobertura.xml" }
- Possible Values:
Any valid JSON string containing a JSON object with fields:
- directory:
Directory or sub-directory where the type checking report in Cobertura XML format will be saved.
- filename:
Filename of the generated type checking report in Cobertura XML format.
Currently, this filename is hardcoded within mypy ascobertura.xml
.- fullpath:
The concatenation of both previous fields using the
/
separator.
- Description:
Directory, filename and fullpath as JSON object where the type checking report in Cobertura XML format will be saved.
This path is configured inpyproject.toml
and can be extracted by ExtractConfiguration.- Example:
ConfigParams: uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6 UnitTesting: uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r6 needs: - ConfigParams with: ... cobertura_report: ${{ needs.ConfigParams.outputs.statictyping_cobertura }}
junit_report
- Type:
string (JSON)
- Required:
no
- Default Value:
{ "directory": "reports/typing", "filename": "StaticTypingSummary.xml", "fullpath": "reports/typing/StaticTypingSummary.xml" }
- Possible Values:
Any valid JSON string containing a JSON object with fields:
- directory:
Directory or sub-directory where the type checking report in JUnit XML format will be saved.
- filename:
Filename of the generated type checking report in JUnit XML format.
Any valid file name for mypy’s JUnit XML report.- fullpath:
The concatenation of both previous fields using the
/
separator.
- Description:
Directory, filename and fullpath as JSON object where the type checking report in JUnit XML format will be saved.
This path is configured inpyproject.toml
and can be extracted by ExtractConfiguration.- Example:
ConfigParams: uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6 UnitTesting: uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r6 needs: - ConfigParams with: ... junit_report: ${{ needs.ConfigParams.outputs.statictyping_junit }}
html_report
- Type:
string (JSON)
- Required:
no
- Default Value:
{ "directory": "reports/typing/html" }
- Possible Values:
Any valid JSON string containing a JSON object with fields:
- directory:
Directory or sub-directory where the type checking report in HTML format will be saved.
- Description:
Directory as JSON object where the type checking report in HTML format will be saved.
This path is configured inpyproject.toml
and can be extracted by ExtractConfiguration.- Example:
ConfigParams: uses: pyTooling/Actions/.github/workflows/ExtractConfiguration.yml@r6 UnitTesting: uses: pyTooling/Actions/.github/workflows/StaticTypeCheck.yml@r6 needs: - ConfigParams with: ... html_report: ${{ needs.ConfigParams.outputs.statictyping_html }}
cobertura_artifact
- Type:
string
- Required:
no
- Default Value:
''
- Possible Values:
Any valid artifact name.
- Description:
Name of the artifact containing the Cobertura XML report.
junit_artifact
- Type:
string
- Required:
no
- Default Value:
''
- Possible Values:
Any valid artifact name.
- Description:
Name of the artifact containing the JUnit XML report.
html_artifact
- Type:
string
- Required:
no
- Default Value:
''
- Possible Values:
Any valid artifact name.
- Description:
Name of the artifact containing the HTML report.
Secrets
This job template needs no secrets.
Outputs
This job template has no output parameters.
Optimizations
This template offers no optimizations (reduced job runtime).