Skip to content

Commit

Permalink
Add coverage badge to test workflows and inihib coverage workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzobeg committed Mar 6, 2024
1 parent b2adebd commit 28b3dec
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
File renamed without changes.
46 changes: 44 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,49 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
id: test
run: |
pytest tests
coverage run -m pytest
coverage report -m
echo "coverage_score=$(coverage report -m | awk 'END{print$4}')" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
with:
ref: badges
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
id: extract_branch

- name: Prepare badge
id: prepare
run: |
echo "coverage_badge_path=${{steps.extract_branch.outputs.branch}}" >> "${GITHUB_OUTPUT}"
mkdir -p ${{steps.extract_branch.outputs.branch}}
- name: Add coverage badge
uses: emibcn/badge-action@v2.0.2
with:
label: 'Test coverage'
status: ${{ steps.test.outputs.coverage_score }}
color: 'blue'
path: ${{ steps.prepare.outputs.coverage_badge_path }}/coverage.svg

- name: Commit badge
id: commit
run: |
ls ${{ steps.prepare.outputs.coverage_badge_path }}/coverage.svg
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add ${{ steps.prepare.outputs.coverage_badge_path }}
git commit -m "Add coverage badge"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges


0 comments on commit 28b3dec

Please sign in to comment.