Derive toolkit quality grade from measured coverage
build-test-release / release (push) Successful in 15m52s

This commit is contained in:
2026-10-15 03:34:11 -06:00
parent 694e2fc7e5
commit cb46adada2
2 changed files with 22 additions and 2 deletions
+3
View File
@@ -12,6 +12,9 @@
The CI badge shows the last completed attempt for this branch while newer
runs are queued. Badge SVGs are stored in a private, machine-maintained branch.
The code-quality letter requires warnings-denied Clippy and measured test plus
UI self-test line coverage: A at 90%, B at 80%, C at 70%, D at 60%, and F
below 60%. A missing coverage measurement displays pending.
A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
ASIC miners. It scans a fleet over the network, shows live health and hashrate
+19 -2
View File
@@ -11,6 +11,7 @@ Metrics not passed on the command line are computed here (LOC from the source
tree, dependency count from Cargo.lock, license from Cargo.toml).
"""
import argparse
import math
import os
import re
import sys
@@ -130,6 +131,17 @@ def cov_color(pct: float) -> str:
return "red"
def quality_grade(clippy: str, coverage: float | None) -> str:
if clippy != "clean":
return "F"
if coverage is None:
return "pending"
for minimum, grade in ((90, "A"), (80, "B"), (70, "C"), (60, "D")):
if coverage >= minimum:
return grade
return "F"
def human(n: int) -> str:
suffixes = ("", "K", "M", "G")
value = float(n)
@@ -160,6 +172,9 @@ def main() -> int:
ap.add_argument("--bench-delta", default=None)
ap.add_argument("--clippy", default="clean")
args = ap.parse_args()
for value in (args.coverage, args.bench_coverage):
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
ap.error("coverage must be a finite percentage between 0 and 100")
os.makedirs(os.path.join(args.root, args.out), exist_ok=True)
@@ -176,8 +191,10 @@ def main() -> int:
write("loc", "lines of code", human(loc), loc_color(loc))
write("license", "license", lic, "blue")
write("dependencies", "dependencies", str(deps), "blue")
grade = "A" if args.clippy == "clean" else "F"
write("quality", "code quality", grade, "brightgreen" if grade == "A" else "red")
grade = quality_grade(args.clippy, args.coverage)
write("quality", "code quality", grade,
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
"D": "orange", "F": "red", "pending": "lightgrey"}[grade])
if args.tests is not None:
write("tests", "tests", f"{args.tests} passing", "brightgreen")
if args.coverage is not None: