Skip to content

coverage yml update

coverage yml update #7

Workflow file for this run

name: Update Coverage Badge
on:
push:
branches:
- main
jobs:
build:
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.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests and generate coverage
run: |
coverage run --rcfile=.coveragerc -m pytest tests/
coverage report -m > coverage.txt
- name: Extract coverage percentage and update README
run: |
COVERAGE=$(grep -Eo 'TOTAL.*[0-9]{1,3}%' coverage.txt | grep -Eo '[0-9]{1,3}')
ENCODED_COVERAGE="${COVERAGE}%25" # URL encode the percentage
BADGE_URL="https://img.shields.io/badge/Coverage-$ENCODED_COVERAGE-brightgreen.svg"
sed -i "s|https://img.shields.io/badge/Coverage-.*-brightgreen.svg|$BADGE_URL|" README.md
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "Update coverage badge"
git push https://${{secrets.GH_WF_CI_COV_TOKEN}}@github.com/${{github.repository}}.git