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" \
|
python3 ci/gen-badges.py --tests "$PASS" \
|
||||||
--coverage "${{ steps.cov.outputs.pct }}" \
|
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||||
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||||
--bench-delta "$BENCH_DELTA"
|
--bench-delta "$BENCH_DELTA" --clippy clean
|
||||||
|
|
||||||
- name: Publish measured badges
|
- name: Publish measured badges
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ ci/coverage.sh --summary-only
|
|||||||
Keep build output off the source share. `main` runs the full CI gate and
|
Keep build output off the source share. `main` runs the full CI gate and
|
||||||
publishes qualifying releases; `next` builds `-rc` candidates. Badges
|
publishes qualifying releases; `next` builds `-rc` candidates. Badges
|
||||||
report host tests and benchmarks, not installation support. Benchmark
|
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
|
## Firmware safety
|
||||||
|
|
||||||
|
|||||||
+5
-10
@@ -131,15 +131,10 @@ def cov_color(pct: float) -> str:
|
|||||||
return "red"
|
return "red"
|
||||||
|
|
||||||
|
|
||||||
def quality_grade(clippy: str, coverage: float | None) -> str:
|
def quality_grade(clippy: str | None) -> str:
|
||||||
if clippy != "clean":
|
if clippy is None:
|
||||||
return "F"
|
|
||||||
if coverage is None:
|
|
||||||
return "pending"
|
return "pending"
|
||||||
for minimum, grade in ((90, "A"), (80, "B"), (70, "C"), (60, "D")):
|
return "A" if clippy == "clean" else "F"
|
||||||
if coverage >= minimum:
|
|
||||||
return grade
|
|
||||||
return "F"
|
|
||||||
|
|
||||||
|
|
||||||
def human(n: int) -> str:
|
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
|
# 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.
|
# (round 19 #1). Takes precedence over --bench for the bench badge.
|
||||||
ap.add_argument("--bench-delta", default=None)
|
ap.add_argument("--bench-delta", default=None)
|
||||||
ap.add_argument("--clippy", default="clean")
|
ap.add_argument("--clippy", choices=("clean", "failed"))
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
for value in (args.coverage, args.bench_coverage):
|
for value in (args.coverage, args.bench_coverage):
|
||||||
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
|
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("loc", "lines of code", human(loc), loc_color(loc))
|
||||||
write("license", "license", lic, "blue")
|
write("license", "license", lic, "blue")
|
||||||
write("dependencies", "dependencies", str(deps), "blue")
|
write("dependencies", "dependencies", str(deps), "blue")
|
||||||
grade = quality_grade(args.clippy, args.coverage)
|
grade = quality_grade(args.clippy)
|
||||||
write("quality", "code quality", grade,
|
write("quality", "code quality", grade,
|
||||||
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||||
"D": "orange", "F": "red", "pending": "lightgrey"}[grade])
|
"D": "orange", "F": "red", "pending": "lightgrey"}[grade])
|
||||||
|
|||||||
Reference in New Issue
Block a user