Skip to content

Run Pytest

Run Pytest #55

Workflow file for this run

# 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", "3.13"]
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
- name: Check if coverage badge changed
id: coverage_check
run: |
if ! git diff --exit-code ./docs/coverage-badge.svg; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Update Coverage Badge if needed
if: steps.coverage_check.outputs.changed == 'true' && matrix.python-version == '3.12'
run: |
git config --global user.name coverage_badge_update
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
git add docs/coverage-badge.svg
git commit -m "Auto updating coverage badge"
git pull --rebase origin main || true
git push