summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-12-28 06:42:55 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-12-28 11:24:32 -0500
commitf2822a8903135a441a28510dd5c94bc437eabde4 (patch)
treeee37144093c5411530eb630c1c2cdbc7ed96af25
parentfb5193003b380cc768bbc0035667c4f672ba898d (diff)
downloadpython-coveragepy-git-f2822a8903135a441a28510dd5c94bc437eabde4.tar.gz
build: generate a metacov badge
-rw-r--r--.github/workflows/coverage.yml18
-rw-r--r--README.rst4
2 files changed, 20 insertions, 2 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 0a3fba69..4db18278 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -140,7 +140,7 @@ jobs:
name: json_report
path: coverage.json
- - name: "Create info for pushing to report repo"
+ - name: "Create info for later steps"
id: info
run: |
export SHA10=$(echo ${{ github.sha }} | cut -c 1-10)
@@ -150,6 +150,11 @@ jobs:
echo "::set-output name=slug::$SLUG"
echo "::set-output name=url::https://nedbat.github.io/coverage-reports/reports/$SLUG/htmlcov"
echo "::set-output name=branch::${REF#refs/heads/}"
+ export PCTINT=$(echo ${{ steps.combine.outputs.total }} | cut -f1 -d.)
+ if (($PCTINT >= 85)); then echo "::set-output name=badgecolor::green"; fi
+ if (($PCTINT < 85)); then echo "::set-output name=badgecolor::yellow"; fi
+ if (($PCTINT < 70)); then echo "::set-output name=badgecolor::orange"; fi
+ if (($PCTINT < 60)); then echo "::set-output name=badgecolor::red"; fi
- name: "Push to report repository"
uses: sebastian-palma/github-action-push-to-another-repository@allow-creating-destination-directory
@@ -187,3 +192,14 @@ jobs:
- name: "Show link to report"
run: |
echo "Coverage report: ${{ steps.info.outputs.url }}"
+
+ - name: "Create badge"
+ # https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5
+ uses: schneegans/dynamic-badges-action@v1.1.0
+ with:
+ auth: ${{ secrets.METACOV_GIST_SECRET }}
+ gistID: 8c6980f77988a327348f9b02bbaf67f5
+ filename: metacov.json
+ label: Coverage
+ message: ${{ steps.combine.outputs.total }}%
+ color: ${{ steps.info.outputs.badgecolor }}
diff --git a/README.rst b/README.rst
index c4d14995..592c606b 100644
--- a/README.rst
+++ b/README.rst
@@ -8,7 +8,7 @@ Coverage.py
Code coverage testing for Python.
| |license| |versions| |status|
-| |test-status| |quality-status| |docs|
+| |test-status| |quality-status| |docs| |metacov|
| |kit| |downloads| |format| |repos|
| |stars| |forks| |contributors|
| |tidelift| |twitter-coveragepy| |twitter-nedbat|
@@ -122,6 +122,8 @@ Licensed under the `Apache 2.0 License`_. For details, see `NOTICE.txt`_.
:target: https://pypi.org/project/coverage/
:alt: License
.. |metacov| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5/raw/metacov.json
+ :target: https://github.com/nedbat/coverage-reports/commits/main
+ :alt: Coverage reports
.. |repos| image:: https://repology.org/badge/tiny-repos/python:coverage.svg
:target: https://repology.org/project/python:coverage/versions
:alt: Packaging status