Skip to content

Commit 2e60bab

Browse files
committed
add automatic condition coverage badge
1 parent 31c062e commit 2e60bab

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,19 @@ jobs:
292292
instrumental -f .instrumental.cov -s
293293
# just log the values when merging
294294
instrumental -f .instrumental.cov -s | python diff-instrumental.py
295+
echo "COND_COV=$(instrumental -f .instrumental.cov -s | python diff-instrumental.py --raw)" >> $GITHUB_ENV
296+
- name: Create condition coverage badge
297+
uses: schneegans/dynamic-badges-action@v1.4.0
298+
if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }}
299+
with:
300+
auth: ${{ secrets.GIST_SECRET }}
301+
gistID: 9b6ca1f3410207fbeca785a178781651
302+
filename: python-ecdsa-condition-coverage.json
303+
label: condition coverage
304+
message: ${{ env.COND_COV }}%
305+
valColorRange: ${{ env.COND_COV }}
306+
maxColorRange: 100
307+
minColorRange: 0
295308
- name: Publish coverage to Coveralls
296309
if: ${{ !matrix.opt-deps && matrix.tox-env != 'codechecks' }}
297310
env:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://github.com/tlsfuzzer/python-ecdsa/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/tlsfuzzer/python-ecdsa/actions?query=workflow%3A%22GitHub+CI%22+branch%3Amaster)
44
[![Documentation Status](https://readthedocs.org/projects/ecdsa/badge/?version=latest)](https://ecdsa.readthedocs.io/en/latest/?badge=latest)
55
[![Coverage Status](https://coveralls.io/repos/github/tlsfuzzer/python-ecdsa/badge.svg?branch=master)](https://coveralls.io/github/tlsfuzzer/python-ecdsa?branch=master)
6-
[![condition coverage](https://img.shields.io/badge/condition%20coverage-87%25-yellow)](https://travis-ci.com/github/tlsfuzzer/python-ecdsa/jobs/458951056#L544)
6+
![condition coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/tomato42/9b6ca1f3410207fbeca785a178781651/raw/python-ecdsa-condition-coverage.json)
77
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/tlsfuzzer/python-ecdsa.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tlsfuzzer/python-ecdsa/context:python)
88
[![Total alerts](https://img.shields.io/lgtm/alerts/g/tlsfuzzer/python-ecdsa.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tlsfuzzer/python-ecdsa/alerts/)
99
[![Latest Version](https://img.shields.io/pypi/v/ecdsa.svg?style=flat)](https://pypi.python.org/pypi/ecdsa/)

diff-instrumental.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
max_difference = 0
77
read_location = None
88
save_location = None
9+
raw = False
910

1011
argv = sys.argv[1:]
1112

1213
opts, args = getopt.getopt(
13-
argv, "s:r:", ["fail-under=", "max-difference=", "save=", "read="]
14+
argv, "s:r:", ["fail-under=", "max-difference=", "save=", "read=", "raw"]
1415
)
1516
if args:
1617
raise ValueError("Unexpected parameters: {0}".format(args))
@@ -23,6 +24,8 @@
2324
fail_under = float(arg) / 100.0
2425
elif opt == "--max-difference":
2526
max_difference = float(arg) / 100.0
27+
elif opt == "--raw":
28+
raw = True
2629
else:
2730
raise ValueError("Unknown option: {0}".format(opt))
2831

@@ -49,7 +52,10 @@
4952
with open(save_location, "w") as f:
5053
f.write("{0:1.40f}".format(coverage))
5154

52-
print("Coverage: {0:6.2f}%".format(coverage * 100))
55+
if raw:
56+
print("{0:6.2f}".format(coverage * 100))
57+
else:
58+
print("Coverage: {0:6.2f}%".format(coverage * 100))
5359

5460
if read_location:
5561
print("Difference: {0:6.2f}%".format((old_coverage - coverage) * 100))

0 commit comments

Comments
 (0)