Skip to content

Commit

Permalink
GitHub actions: create coverage badge
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdagger committed Oct 21, 2023
1 parent f1d8890 commit 5273f2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ permissions:


jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.10"]
env:
total: "-"

steps:
- uses: actions/checkout@v3
Expand All @@ -38,6 +40,25 @@ jobs:
- name: Unit tests with pytest
run: |
poetry run pytest
- name: prepare coverage data
continue-on-error: true
run: |
poetry run coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: create coverage badge
if : ${{ matrix.python-version == '3.11' }}
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 1a66c9e88a9e4267f7e0b1d185be98f4
filename: covbadge.json
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
- name: Static typechecking with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ zammadoo
:alt: Documentation Status


.. image:: https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Fflashdagger%2F1a66c9e88a9e4267f7e0b1d185be98f4%2Fraw
:target: https://gist.github.com/flashdagger/1a66c9e88a9e4267f7e0b1d185be98f4
:alt: Coverage

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black/
:alt: Code Style Black
Expand Down

0 comments on commit 5273f2f

Please sign in to comment.