readme formatting #14
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: | |
- 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 'TOTAL' coverage.txt | awk '{print $NF}' | tr -d '%') | |
ENCODED_COVERAGE="${COVERAGE}%25" # URL encode the percentage | |
FILENAME="VRF.py" | |
ENCODED_FILENAME=$(echo "$FILENAME" | sed 's/ /%20/g') # URL encode the filename | |
BADGE_URL="https://img.shields.io/badge/$ENCODED_FILENAME-Coverage:$ENCODED_COVERAGE-brightgreen.svg" | |
# Echo the BADGE_URL for debugging purposes | |
echo "Generated Badge URL: $BADGE_URL" | |
# Update the README with the new badge URL | |
sed -i.bak "s|https://img.shields.io/badge/VRF.py-Coverage:.*-brightgreen.svg|$BADGE_URL|g" README.md | |
# COVERAGE=$(grep 'TOTAL' coverage.txt | awk '{print $NF}' | tr -d '%') | |
# ENCODED_COVERAGE="${COVERAGE}%25" # URL encode the percentage | |
# BADGE_URL="https://img.shields.io/badge/Coverage-$ENCODED_COVERAGE-brightgreen.svg" | |
# # Echo the BADGE_URL for debugging purposes | |
# echo "Generated Badge URL: $BADGE_URL" | |
# # Update the README with the new badge URL | |
# sed -i.bak "s|https://img.shields.io/badge/Coverage-.*-brightgreen.svg|$BADGE_URL|g" 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 |