Run Pytest #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Action that runs pytest | |
name: Run Pytest | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
# execute once a week on monday | |
- cron: '0 1 * * 1' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: # https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch | |
ref: ${{ github.head_ref }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: 'x64' | |
- run: | | |
pip install . | |
pip install pytest | |
pip install pytest-cov | |
- name: Run tests | |
run: | | |
pytest --exitfirst --verbose --failed-first --cov=src tests/ --cov-report=term-missing --cov-report=xml | |
- name: Generate Coverage Badge | |
run: | | |
pip install setuptools | |
pip install genbadge[coverage] | |
genbadge coverage -i coverage.xml -o docs/coverage-badge.svg | |
- run: git diff --exit-code ./docs/coverage-badge.svg | |
- name: Update Coverage Badge if needed | |
if: failure() | |
run: | |
git config --local user.email '${GITHUB_ACTOR}@users.noreply.github.com' | |
git config --local user.name "update-coverage-badge[bot]" | |
git commit -am "Auto updating coverage badge" | |
git push |