Skip to content

Commit

Permalink
Merge pull request #299 from tlsfuzzer/condition-coverage
Browse files Browse the repository at this point in the history
add automatic condition coverage badge
  • Loading branch information
tomato42 committed Jun 10, 2022
2 parents 31c062e + c3f973e commit 522f480
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ jobs:
run: |
apt-get update
apt-get install -y git make python-is-python3 python3 curl wget python3-distutils python3-pip
- name: workaround git failures with py3.10
run: |
git config --global --add safe.directory /__w/python-ecdsa/python-ecdsa
- name: Verify git status
run: |
git status
Expand Down Expand Up @@ -292,6 +295,19 @@ jobs:
instrumental -f .instrumental.cov -s
# just log the values when merging
instrumental -f .instrumental.cov -s | python diff-instrumental.py
echo "COND_COV=$(instrumental -f .instrumental.cov -s | python diff-instrumental.py --raw)" >> $GITHUB_ENV
- name: Create condition coverage badge
uses: schneegans/dynamic-badges-action@v1.4.0
if: ${{ contains(matrix.opt-deps, 'instrumental') && !github.event.pull_request }}
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 9b6ca1f3410207fbeca785a178781651
filename: python-ecdsa-condition-coverage.json
label: condition coverage
message: ${{ env.COND_COV }}%
valColorRange: ${{ env.COND_COV }}
maxColorRange: 100
minColorRange: 0
- name: Publish coverage to Coveralls
if: ${{ !matrix.opt-deps && matrix.tox-env != 'codechecks' }}
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![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)
[![Documentation Status](https://readthedocs.org/projects/ecdsa/badge/?version=latest)](https://ecdsa.readthedocs.io/en/latest/?badge=latest)
[![Coverage Status](https://coveralls.io/repos/github/tlsfuzzer/python-ecdsa/badge.svg?branch=master)](https://coveralls.io/github/tlsfuzzer/python-ecdsa?branch=master)
[![condition coverage](https://img.shields.io/badge/condition%20coverage-87%25-yellow)](https://travis-ci.com/github/tlsfuzzer/python-ecdsa/jobs/458951056#L544)
![condition coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/tomato42/9b6ca1f3410207fbeca785a178781651/raw/python-ecdsa-condition-coverage.json)
[![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)
[![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/)
[![Latest Version](https://img.shields.io/pypi/v/ecdsa.svg?style=flat)](https://pypi.python.org/pypi/ecdsa/)
Expand Down
10 changes: 8 additions & 2 deletions diff-instrumental.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
max_difference = 0
read_location = None
save_location = None
raw = False

argv = sys.argv[1:]

opts, args = getopt.getopt(
argv, "s:r:", ["fail-under=", "max-difference=", "save=", "read="]
argv, "s:r:", ["fail-under=", "max-difference=", "save=", "read=", "raw"]
)
if args:
raise ValueError("Unexpected parameters: {0}".format(args))
Expand All @@ -23,6 +24,8 @@
fail_under = float(arg) / 100.0
elif opt == "--max-difference":
max_difference = float(arg) / 100.0
elif opt == "--raw":
raw = True
else:
raise ValueError("Unknown option: {0}".format(opt))

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

print("Coverage: {0:6.2f}%".format(coverage * 100))
if raw:
print("{0:6.2f}".format(coverage * 100))
else:
print("Coverage: {0:6.2f}%".format(coverage * 100))

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

0 comments on commit 522f480

Please sign in to comment.