Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add coverage badge #5

Merged
merged 15 commits into from
Oct 3, 2023
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.