Skip to content

Commit f2052a5

Browse files
committed
Added coverage badge info generator
1 parent 817e916 commit f2052a5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

print-coverage.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Prints code testing coverage as percentage for badge generation.
2+
import xml.etree.ElementTree as et
3+
4+
tree = et.parse("cov.xml")
5+
root = tree.getroot()
6+
coverage = float(root.attrib["line-rate"]) * 100
7+
print(f"COVERAGE={coverage:3.4}%")
8+
if coverage >= 95.0:
9+
print("COVERAGE_COLOR=green")
10+
elif coverage >= 90.0:
11+
print("COVERAGE_COLOR=yellow")
12+
elif coverage >= 85.0:
13+
print("COVERAGE_COLOR=orange")
14+
else:
15+
print("COVERAGE_COLOR=red")

0 commit comments

Comments
 (0)