Coverage workflow #24
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
name: Update Coverage Badge | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
cd webservice | |
python -m pip install --upgrade pip | |
apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends libpq-dev gcc libc6-dev gpg git | |
pip install -r requirements.txt | |
- name: Run tests with coverage | |
run: | | |
cd webservice | |
coverage run -m pytest tests/test_app.py | |
- name: Generate coverage badge | |
run: | | |
cd webservice | |
rm -f coverage.svg # Remove any existing coverage.svg file | |
coverage-badge -o coverage.svg | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add README.md webservice/coverage.svg | |
git commit -m "Add coverage badge to README" -a || true # Continue even if nothing to commit | |
git push |