mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Create, collect and publish junit reports for static typing.
(cherry picked from commit fb8363afdf53d6656fe020dd08f9e91d9da45565)
This commit is contained in:
17
.github/workflows/CoverageCollection.yml
vendored
17
.github/workflows/CoverageCollection.yml
vendored
@@ -35,13 +35,13 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: '-r tests/requirements.txt'
|
default: '-r tests/requirements.txt'
|
||||||
type: string
|
type: string
|
||||||
test_directory:
|
tests_directory:
|
||||||
description: 'Path to the directory containing tests (test working directory).'
|
description: 'Path to the directory containing tests (test working directory).'
|
||||||
required: false
|
required: false
|
||||||
default: 'tests'
|
default: 'tests'
|
||||||
type: string
|
type: string
|
||||||
unittest_directory:
|
unittest_directory:
|
||||||
description: 'Path to the directory containing unit tests (relative to test_directory).'
|
description: 'Path to the directory containing unit tests (relative to tests_directory).'
|
||||||
required: false
|
required: false
|
||||||
default: 'unit'
|
default: 'unit'
|
||||||
type: string
|
type: string
|
||||||
@@ -122,16 +122,19 @@ jobs:
|
|||||||
- name: Collect coverage
|
- name: Collect coverage
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
cd ${{ inputs.test_directory }}
|
RELDIR="$(realpath --relative-to=${{ inputs.tests_directory }} .)"
|
||||||
[ 'x${{ inputs.coverage_config }}' != 'x' ] && PYCOV_ARGS='--cov-config=${{ inputs.coverage_config }}' || unset PYCOV_ARGS
|
echo $RELDIR
|
||||||
python -m pytest -rA --cov=. $PYCOV_ARGS ${{ inputs.unittest_directory }} --color=yes
|
cd ${{ inputs.tests_directory }}
|
||||||
|
[ 'x${{ inputs.coverage_config }}' != 'x' ] && PYCOV_ARGS="--cov-config=$RELDIR/${{ inputs.coverage_config }}" || unset PYCOV_ARGS
|
||||||
|
echo python -m pytest -rA --cov=$RELDIR $PYCOV_ARGS ${{ inputs.unittest_directory }} --color=yes
|
||||||
|
python -m pytest -rA --cov=$RELDIR $PYCOV_ARGS ${{ inputs.unittest_directory }} --color=yes
|
||||||
|
|
||||||
- name: Convert to cobertura format
|
- name: Convert to cobertura format
|
||||||
run: coverage xml
|
run: coverage xml --data-file=${{ inputs.tests_directory }}/.coverage
|
||||||
|
|
||||||
- name: Convert to HTML format
|
- name: Convert to HTML format
|
||||||
run: |
|
run: |
|
||||||
coverage html -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
coverage html --data-file=${{ inputs.tests_directory }}/.coverage -d ${{ steps.getVariables.outputs.coverage_report_html_directory }}
|
||||||
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
|
rm ${{ steps.getVariables.outputs.coverage_report_html_directory }}/.gitignore
|
||||||
|
|
||||||
- name: 📤 Upload 'Coverage Report' artifact
|
- name: 📤 Upload 'Coverage Report' artifact
|
||||||
|
|||||||
12
.github/workflows/Parameters.yml
vendored
12
.github/workflows/Parameters.yml
vendored
@@ -92,11 +92,13 @@ jobs:
|
|||||||
params = {
|
params = {
|
||||||
'python_version': pythonVersion,
|
'python_version': pythonVersion,
|
||||||
'artifacts': {
|
'artifacts': {
|
||||||
'unittesting': f"{name}-TestReport",
|
'unittesting': f"{name}-Unittest-Summary",
|
||||||
'coverage': f"{name}-Coverage",
|
'code-coverage': f"{name}-Code-Coverage",
|
||||||
'typing': f"{name}-Typing",
|
'typing_html': f"{name}-Typing",
|
||||||
'package': f"{name}-Package",
|
'typing_junit': f"{name}-Typing-Summary",
|
||||||
'doc': f"{name}-Documentation",
|
'package': f"{name}-Package",
|
||||||
|
'doc': f"{name}-Documentation",
|
||||||
|
'doc-coverage': f"{name}-Documentation-Coverage",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(f"::set-output name=params::{params!s}")
|
print(f"::set-output name=params::{params!s}")
|
||||||
|
|||||||
40
.github/workflows/StaticTypeCheck.yml
vendored
40
.github/workflows/StaticTypeCheck.yml
vendored
@@ -35,19 +35,29 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: '-r tests/requirements.txt'
|
default: '-r tests/requirements.txt'
|
||||||
type: string
|
type: string
|
||||||
report:
|
|
||||||
description: 'Directory to upload as an artifact.'
|
|
||||||
required: false
|
|
||||||
default: 'htmlmypy'
|
|
||||||
type: string
|
|
||||||
commands:
|
commands:
|
||||||
description: 'Commands to run the static type checks.'
|
description: 'Commands to run the static type checks.'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
artifact:
|
html_report:
|
||||||
|
description: 'Directory to upload as an artifact.'
|
||||||
|
required: false
|
||||||
|
default: 'htmlmypy'
|
||||||
|
type: string
|
||||||
|
junit_report:
|
||||||
|
description: 'junit file to upload as an artifact.'
|
||||||
|
required: false
|
||||||
|
default: 'StaticTypingSummary.xml'
|
||||||
|
type: string
|
||||||
|
html_artifact:
|
||||||
description: 'Name of the typing artifact.'
|
description: 'Name of the typing artifact.'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
junit_artifact:
|
||||||
|
description: 'Name of the typing artifact.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
@@ -73,12 +83,22 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: ${{ inputs.commands }}
|
run: ${{ inputs.commands }}
|
||||||
|
|
||||||
- name: 📤 Upload 'Static Typing Report' artifact
|
- name: 📤 Upload 'Static Typing Report' HTML artifact
|
||||||
if: ${{ inputs.artifact != '' }}
|
if: ${{ inputs.html_artifact != '' }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.artifact }}
|
name: ${{ inputs.html_artifact }}
|
||||||
path: ${{ inputs.report }}
|
path: ${{ inputs.html_report }}
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
- name: 📤 Upload 'Static Typing Report' JUnit artifact
|
||||||
|
if: ${{ inputs.junit_artifact != '' }}
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ${{ inputs.junit_artifact }}
|
||||||
|
path: ${{ inputs.junit_report }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
python-coverage:p
|
python-coverage:p
|
||||||
python-lxml:p
|
python-lxml:p
|
||||||
mingw_requirements: '-r tests/requirements.mingw.txt'
|
mingw_requirements: '-r tests/requirements.mingw.txt'
|
||||||
test_directory: 'tests'
|
tests_directory: 'tests'
|
||||||
unittest_directory: 'unit'
|
unittest_directory: 'unit'
|
||||||
artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}
|
artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
# Optional
|
# Optional
|
||||||
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
|
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
|
||||||
requirements: '-r tests/requirements.txt'
|
requirements: '-r tests/requirements.txt'
|
||||||
test_directory: 'tests'
|
tests_directory: 'tests'
|
||||||
unittest_directory: 'unit'
|
unittest_directory: 'unit'
|
||||||
secrets:
|
secrets:
|
||||||
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||||
@@ -75,18 +75,22 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- Params
|
- Params
|
||||||
with:
|
with:
|
||||||
commands: mypy --html-report htmlmypy -p ToolName
|
commands: |
|
||||||
artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.typing }}
|
mypy --junit-xml StaticTypingSummary.xml --html-report htmlmypy -p ToolName
|
||||||
|
html_artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.typing_html }}
|
||||||
|
junit_artifact: ${{ fromJson(needs.Params.outputs.params).artifacts.typing_junit }}
|
||||||
# Optional
|
# Optional
|
||||||
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
|
python_version: ${{ fromJson(needs.Params.outputs.params).python_version }}
|
||||||
requirements: '-r tests/requirements.txt'
|
requirements: '-r tests/requirements.txt'
|
||||||
report: 'htmlmypy'
|
html_report: 'htmlmypy'
|
||||||
|
junit_report: 'StaticTypingSummary.xml'
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
PublishTestResults:
|
PublishTestResults:
|
||||||
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@main
|
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@main
|
||||||
needs:
|
needs:
|
||||||
- UnitTesting
|
- UnitTesting
|
||||||
|
- StaticTypeCheck
|
||||||
with:
|
with:
|
||||||
# Optional
|
# Optional
|
||||||
report_files: artifacts/**/*.xml
|
report_files: artifacts/**/*.xml
|
||||||
@@ -178,5 +182,6 @@ jobs:
|
|||||||
${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-macos-3.9
|
${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-macos-3.9
|
||||||
${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-macos-3.10
|
${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-macos-3.10
|
||||||
${{ fromJson(needs.Params.outputs.params).artifacts.coverage }}
|
${{ fromJson(needs.Params.outputs.params).artifacts.coverage }}
|
||||||
${{ fromJson(needs.Params.outputs.params).artifacts.typing }}
|
${{ fromJson(needs.Params.outputs.params).artifacts.typing_html }}
|
||||||
|
${{ fromJson(needs.Params.outputs.params).artifacts.typing_junit }}
|
||||||
${{ fromJson(needs.Params.outputs.params).artifacts.doc }}
|
${{ fromJson(needs.Params.outputs.params).artifacts.doc }}
|
||||||
|
|||||||
Reference in New Issue
Block a user