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
|
required: false
|
||||||
default: '-r tests/requirements.txt'
|
default: '-r tests/requirements.txt'
|
||||||
type: string
|
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:
|
artifact:
|
||||||
description: 'Name of the coverage artifact.'
|
description: 'Name of the coverage artifact.'
|
||||||
required: true
|
required: true
|
||||||
@@ -67,7 +77,8 @@ jobs:
|
|||||||
- name: Collect coverage
|
- name: Collect coverage
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
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
|
- name: Convert to cobertura format
|
||||||
run: coverage xml
|
run: coverage xml
|
||||||
@@ -75,14 +86,14 @@ jobs:
|
|||||||
- name: Convert to HTML format
|
- name: Convert to HTML format
|
||||||
run: |
|
run: |
|
||||||
coverage html
|
coverage html
|
||||||
rm htmlcov/.gitignore
|
rm report/coverage/html/.gitignore
|
||||||
|
|
||||||
- name: 📤 Upload 'Coverage Report' artifact
|
- name: 📤 Upload 'Coverage Report' 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.artifact }}
|
||||||
path: htmlcov
|
path: report/coverage/html
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
@@ -90,7 +101,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
with:
|
with:
|
||||||
file: ./coverage.xml
|
file: report/coverage/coverage.xml
|
||||||
flags: unittests
|
flags: unittests
|
||||||
env_vars: PYTHON
|
env_vars: PYTHON
|
||||||
|
|
||||||
@@ -99,4 +110,4 @@ jobs:
|
|||||||
uses: codacy/codacy-coverage-reporter-action@master
|
uses: codacy/codacy-coverage-reporter-action@master
|
||||||
with:
|
with:
|
||||||
project-token: ${{ secrets.codacy_token }}
|
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
|
required: false
|
||||||
default: '-r tests/requirements.txt'
|
default: '-r tests/requirements.txt'
|
||||||
type: string
|
type: string
|
||||||
|
unittest_directory:
|
||||||
|
description: 'Path to the directory containing unit tests.'
|
||||||
|
required: false
|
||||||
|
default: 'tests/unit'
|
||||||
|
type: string
|
||||||
artifact:
|
artifact:
|
||||||
description: "Generate unit test report with junitxml and upload results as an artifact."
|
description: "Generate unit test report with junitxml and upload results as an artifact."
|
||||||
required: false
|
required: false
|
||||||
@@ -68,7 +73,7 @@ jobs:
|
|||||||
- name: ☑ Run unit tests
|
- name: ☑ Run unit tests
|
||||||
run: |
|
run: |
|
||||||
[ 'x${{ inputs.artifact }}' != 'x' ] && PYTEST_ARGS='--junitxml=TestReport.xml' || unset PYTEST_ARGS
|
[ '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
|
- name: 📤 Upload 'TestReport.xml' artifact
|
||||||
if: inputs.artifact != ''
|
if: inputs.artifact != ''
|
||||||
|
|||||||
Reference in New Issue
Block a user