Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest-cov to setup.py and testing script, fail on coverage below 80 #279

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 23 additions & 7 deletions .github/workflows/testing.yml
Expand Up @@ -2,6 +2,11 @@ name: testing
on:
pull_request:
branches: [master, develop]

env:
COVERAGE_THRESHOLD: 80
FAIL_ON_BELOW_COVERAGE: 'true'

jobs:
test:
strategy:
Expand Down Expand Up @@ -34,10 +39,21 @@ jobs:
run: |
conda install -c conda-forge liblsl
pip install -e .[test]
python -m pytest --import-mode=append --html=pytest_report.html --self-contained-html
- name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: pytest-results
path: pytest_report.html
- name: Run tests and fail below code coverage threshold of ${{ env.COVERAGE_THRESHOLD }}
if: ${{ env.FAIL_ON_BELOW_COVERAGE == 'true' }}
run: python -m pytest --import-mode=append --html=pytest_report.html --self-contained-html --cov-report html --cov=./src/explorepy/ --cov-fail-under=${{ env.COVERAGE_THRESHOLD }}
- name: Run tests
if: ${{ env.FAIL_ON_BELOW_COVERAGE != 'true' }}
run: python -m pytest --import-mode=append --html=pytest_report.html --self-contained-html --cov-report html --cov=./src/explorepy/
- name: Archive test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: pytest-test-results
path: pytest_report.html
- name: Archive code coverage report
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: pytest-cov-results
path: ./htmlcov
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -36,6 +36,7 @@ def read(*names, **kwargs):
test_requirements = ["pytest==6.2.5",
"pytest-mock==3.10.0",
"pytest-html==3.2.0",
"pytest-cov==4.1.0",
"flake8==4.0.1",
"isort==5.10.1"]
extras = {"test": test_requirements}
Expand Down