Grade Toolkit code quality from static checks
build-test-release / release (push) Successful in 16m15s
build-test-release / release (push) Successful in 16m15s
This commit is contained in:
@@ -167,7 +167,7 @@ jobs:
|
||||
python3 ci/gen-badges.py --tests "$PASS" \
|
||||
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||
--bench-delta "$BENCH_DELTA"
|
||||
--bench-delta "$BENCH_DELTA" --clippy clean
|
||||
|
||||
- name: Publish measured badges
|
||||
env:
|
||||
|
||||
@@ -55,7 +55,8 @@ ci/coverage.sh --summary-only
|
||||
Keep build output off the source share. `main` runs the full CI gate and
|
||||
publishes qualifying releases; `next` builds `-rc` candidates. Badges
|
||||
report host tests and benchmarks, not installation support. Benchmark
|
||||
comparisons require the same CPU class.
|
||||
comparisons require the same CPU class. The code quality letter reports the
|
||||
Clippy gate; the separate coverage badge reports exercised lines.
|
||||
|
||||
## Firmware safety
|
||||
|
||||
|
||||
+5
-10
@@ -131,15 +131,10 @@ 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:
|
||||
def quality_grade(clippy: str | None) -> str:
|
||||
if clippy is None:
|
||||
return "pending"
|
||||
for minimum, grade in ((90, "A"), (80, "B"), (70, "C"), (60, "D")):
|
||||
if coverage >= minimum:
|
||||
return grade
|
||||
return "F"
|
||||
return "A" if clippy == "clean" else "F"
|
||||
|
||||
|
||||
def human(n: int) -> str:
|
||||
@@ -170,7 +165,7 @@ def main() -> int:
|
||||
# percentage string (e.g. "-3.2"), or "NEW"/"" when there is no baseline yet
|
||||
# (round 19 #1). Takes precedence over --bench for the bench badge.
|
||||
ap.add_argument("--bench-delta", default=None)
|
||||
ap.add_argument("--clippy", default="clean")
|
||||
ap.add_argument("--clippy", choices=("clean", "failed"))
|
||||
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):
|
||||
@@ -191,7 +186,7 @@ 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 = quality_grade(args.clippy, args.coverage)
|
||||
grade = quality_grade(args.clippy)
|
||||
write("quality", "code quality", grade,
|
||||
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||
"D": "orange", "F": "red", "pending": "lightgrey"}[grade])
|
||||
|
||||
Reference in New Issue
Block a user