Skip to content

Commit

Permalink
fix: add dynamic coverage badge
Browse files Browse the repository at this point in the history
* Updated coverage.svg

* fix: add coverage badge

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
McLargo and github-actions[bot] authored Oct 3, 2023
1 parent 94fd339 commit 31e6489
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
38 changes: 36 additions & 2 deletions .github/workflows/python-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
Expand Down Expand Up @@ -54,4 +59,33 @@ jobs:
- name: Run test with pytest
run: |
pytest --cov-report=json --cov=.
pytest --cov=.
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v2
with:
output: assets/badges/coverage.svg

- name: Verify Changed coverage
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
with:
files: assets/badges/coverage.svg

- name: Commit coverage badge file
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add assets/badges/coverage.svg
git commit -m "Updated coverage.svg"
echo ${{ github.repository }}
echo ${{ github.server_url }}
echo ${{ github }}
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.COVERAGE_SECRET }}
branch: ${{ github.ref }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# python-frawework

[![Python framework](https://github.com/McLargo/python-framework/actions/workflows/python-app.yaml/badge.svg)](https://github.com/McLargo/python-framework/actions/workflows/python-app.yaml)
[![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/McLargo/python-framework/actions/workflows/python-app.yaml)
[![coverage](./assets/badges/coverage.svg)](https://github.com/McLargo/python-framework/actions/workflows/python-app.yaml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

Expand Down
21 changes: 21 additions & 0 deletions assets/badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31e6489

Please sign in to comment.