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 f0ed9b9
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 @@ -19,6 +19,10 @@ zammadoo
:alt: Core Tests


.. 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://readthedocs.org/projects/zammadoo/badge/?version=latest
:target: https://zammadoo.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Expand Down

0 comments on commit f0ed9b9

Please sign in to comment.