small optimization #223
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: Generate Coverage Badges | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- .github/workflows/coverage.yml | |
- cat_win/** | |
# specify (all) branches such that the workflow will | |
# not trigger on tag/release-creation | |
branches: | |
- '**' | |
- '!badges' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Set Windows Line Ending | |
run: | | |
git config --global core.autocrlf true | |
- name: Git Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # otherwise, it will fail to push refs to dest repo | |
- name: Install Python 3.10 | |
id: python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Update PIP | |
run: | | |
python -m pip install --upgrade pip | |
- name: Setup Dependencies | |
run: | | |
python -m pip install --upgrade -r ./workflowHelper/requirements.txt | |
python -m pip install --upgrade coverage | |
python -m pip install --upgrade pytest | |
python -m pip install --upgrade genbadge[tests,coverage] | |
- name: Generate Reports | |
run: | | |
python -m coverage run -m pytest ./cat_win/tests/ --junitxml=./reports/pytest.xml | |
python -m coverage xml -o ./reports/coverage.xml | |
- name: Show Missing Coverage | |
run: | | |
python -m coverage report --show-missing | |
- name: Create / Move To Badge-Branch | |
run: | | |
git checkout badges 2> /dev/null || git checkout -b badges | |
mkdir -p .github/badges | |
- name: Generate Badges | |
run: | | |
python -m genbadge.main tests -i ./reports/pytest.xml -o ./.github/badges/badge-tests.svg | |
python -m genbadge.main coverage -i ./reports/coverage.xml -o ./.github/badges/badge-coverage.svg | |
- name: Show and Push | |
run: | | |
git status | |
git config --local user.name 'github-actions[bot]' | |
git config --local user.email 'github-actions[bot]@users.noreply.github.com' | |
git add ./.github/badges/badge-coverage.svg | |
git add ./.github/badges/badge-tests.svg | |
git commit -m "🤖Generated Coverage Badges." | |
git push origin HEAD:badges | |
continue-on-error: true |