Skip to content

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

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

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

Workflow file for this run

name: testing
on:
pull_request:
branches: [master, develop]
env:
COVERAGE_THRESHOLD: 80
FAIL_ON_BELOW_COVERAGE: 'true'
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.9.12]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- name: Checkout source repository
uses: actions/checkout@v2
with:
fetch-depth: 0
clean: false
- name: Checkout to current branch
run: git checkout ${{ env.BRANCH }}
- name: Install non-python dependencies on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install libbluetooth-dev -y
- name: Set up Python ${{ matrix.python }}
uses: s-weigand/setup-conda@v1
with:
python-version: ${{ matrix.python }}
conda-channels: anaconda, conda-forge
- name: Install liblsl from conda-forge
run: |
conda install -c conda-forge liblsl
pip install -e .[test]
- 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