Skip to content

Commit 522f480

Browse files
authored
Merge pull request #299 from tlsfuzzer/condition-coverage
add automatic condition coverage badge
2 parents 31c062e + c3f973e commit 522f480

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ jobs:
154154
run: |
155155
apt-get update
156156
apt-get install -y git make python-is-python3 python3 curl wget python3-distutils python3-pip
157+
- name: workaround git failures with py3.10
158+
run: |
159+
git config --global --add safe.directory /__w/python-ecdsa/python-ecdsa
157160
- name: Verify git status
158161
run: |
159162
git status
@@ -292,6 +295,19 @@ jobs:
292295
instrumental -f .instrumental.cov -s
293296
# just log the values when merging
294297
instrumental -f .instrumental.cov -s | python diff-instrumental.py
298+
echo "COND_COV=$(instrumental -f .instrumental.cov -s | python diff-instrumental.py --raw)" >> $GITHUB_ENV
299+
- name: Create condition coverage badge
300+
uses: schneegans/[email protected]
301+
if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }}
302+
with:
303+
auth: ${{ secrets.GIST_SECRET }}
304+
gistID: 9b6ca1f3410207fbeca785a178781651
305+
filename: python-ecdsa-condition-coverage.json
306+
label: condition coverage
307+
message: ${{ env.COND_COV }}%
308+
valColorRange: ${{ env.COND_COV }}
309+
maxColorRange: 100
310+
minColorRange: 0
295311
- name: Publish coverage to Coveralls
296312
if: ${{ !matrix.opt-deps && matrix.tox-env != 'codechecks' }}
297313
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)