This GitHub action runs python tests using pytest
and creates a comment for PR with a coverage table.
It supports projects with the most popular python package managers (pip
, poetry
, pipenv
)
-
requirements-file
- requirements filepath for project
- if left empty will default to
requirements.txt
- necessary if you use
pip
python package manager
-
pytest-root-dir
- root directory to recursively search for .py files
-
pytest-tests-dir
- directory with pytest tests
- if left empty will identify test(s) dir by default
-
cov-omit-list
- list of directories and/or files to ignore
-
cov-threshold-single
- fail if any single file coverage is less than threshold
-
cov-threshold-total
- fail if the total coverage is less than threshold
-
async-tests
- Add support for async tests
-
poetry-version
- Poetry version to be used. The latest version is used by default
name: pytest-reporter workflow
on: [pull_request]
jobs:
tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9.6' # Define your project python version
- id: run-tests
uses: JotaFan/[email protected]
with:
cov-omit-list: tests/*
cov-threshold-single: 85
cov-threshold-total: 90
async-tests: true
poetry-version: 1.4.2