mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Pytest using pyproject.toml.
This commit is contained in:
21
.github/workflows/CoverageCollection.yml
vendored
21
.github/workflows/CoverageCollection.yml
vendored
@@ -35,6 +35,16 @@ on:
|
||||
required: false
|
||||
default: '-r tests/requirements.txt'
|
||||
type: string
|
||||
unittest_directory:
|
||||
description: 'Path to the directory containing unit tests.'
|
||||
required: false
|
||||
default: 'tests/unit'
|
||||
type: string
|
||||
coverage_config:
|
||||
description: 'Path to the .coveragerc file. Use pyproject.toml if empty.'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
artifact:
|
||||
description: 'Name of the coverage artifact.'
|
||||
required: true
|
||||
@@ -67,7 +77,8 @@ jobs:
|
||||
- name: Collect coverage
|
||||
continue-on-error: true
|
||||
run: |
|
||||
python -m pytest -rA --cov=.. --cov-config=tests/.coveragerc tests/unit --color=yes
|
||||
[ 'x${{ inputs.coverage_config }}' != 'x' ] && PYCOV_ARGS='--cov-config=${{ inputs.coverage_config }}' || unset PYCOV_ARGS
|
||||
python -m pytest -rA --cov=.. $PYCOV_ARGS ${{ inputs.unittest_directory }} --color=yes
|
||||
|
||||
- name: Convert to cobertura format
|
||||
run: coverage xml
|
||||
@@ -75,14 +86,14 @@ jobs:
|
||||
- name: Convert to HTML format
|
||||
run: |
|
||||
coverage html
|
||||
rm htmlcov/.gitignore
|
||||
rm report/coverage/html/.gitignore
|
||||
|
||||
- name: 📤 Upload 'Coverage Report' artifact
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ inputs.artifact }}
|
||||
path: htmlcov
|
||||
path: report/coverage/html
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
@@ -90,7 +101,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
file: report/coverage/coverage.xml
|
||||
flags: unittests
|
||||
env_vars: PYTHON
|
||||
|
||||
@@ -99,4 +110,4 @@ jobs:
|
||||
uses: codacy/codacy-coverage-reporter-action@master
|
||||
with:
|
||||
project-token: ${{ secrets.codacy_token }}
|
||||
coverage-reports: ./coverage.xml
|
||||
coverage-reports: report/coverage/coverage.xml
|
||||
|
||||
7
.github/workflows/UnitTesting.yml
vendored
7
.github/workflows/UnitTesting.yml
vendored
@@ -34,6 +34,11 @@ on:
|
||||
required: false
|
||||
default: '-r tests/requirements.txt'
|
||||
type: string
|
||||
unittest_directory:
|
||||
description: 'Path to the directory containing unit tests.'
|
||||
required: false
|
||||
default: 'tests/unit'
|
||||
type: string
|
||||
artifact:
|
||||
description: "Generate unit test report with junitxml and upload results as an artifact."
|
||||
required: false
|
||||
@@ -68,7 +73,7 @@ jobs:
|
||||
- name: ☑ Run unit tests
|
||||
run: |
|
||||
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
|
||||
python -m pytest -rA tests/unit $PYTEST_ARGS --color=yes
|
||||
python -m pytest -rA ${{ inputs.unittest_directory }} $PYTEST_ARGS --color=yes
|
||||
|
||||
- name: 📤 Upload 'TestReport.xml' artifact
|
||||
if: inputs.artifact != ''
|
||||
|
||||
Reference in New Issue
Block a user