Clarify Toolkit quality badge scope
build-test-release / release (push) Canceled after 0s

This commit was merged in pull request #11.
This commit is contained in:
2026-10-20 19:28:47 -06:00
3 changed files with 24 additions and 6 deletions
+4
View File
@@ -10,6 +10,10 @@
![dependencies](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/dependencies.svg) ![dependencies](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/dependencies.svg)
![license](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/license.svg) ![license](https://gitea.bluefla.re/blueflare/alkane-toolkit/raw/branch/ci-badges/badges/license.svg)
The code quality grade reports first-party Clippy checks from the last
successful main build. Test coverage has a separate badge. Formatting is not
part of the grade yet.
Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through
a patched [wx-rs bridge](thirdparty/wx-rs). In-app image flashing is disabled a patched [wx-rs bridge](thirdparty/wx-rs). In-app image flashing is disabled
while that path is reworked. while that path is reworked.
+9 -6
View File
@@ -40,7 +40,8 @@ def text_width(s: str) -> float:
return len(s) * CHAR_W + 2 * PAD return len(s) * CHAR_W + 2 * PAD
def badge_svg(label: str, message: str, color: str) -> str: def badge_svg(label: str, message: str, color: str,
description: str | None = None) -> str:
color = COLORS.get(color, color) color = COLORS.get(color, color)
lw = round(text_width(label), 1) lw = round(text_width(label), 1)
mw = round(text_width(message), 1) mw = round(text_width(message), 1)
@@ -48,8 +49,9 @@ def badge_svg(label: str, message: str, color: str) -> str:
lx = round(lw / 2, 1) lx = round(lw / 2, 1)
mx = round(lw + mw / 2, 1) mx = round(lw + mw / 2, 1)
# Text is drawn twice (a dark shadow then the light glyphs) for the shields look. # Text is drawn twice (a dark shadow then the light glyphs) for the shields look.
return f'''<svg xmlns="http://www.w3.org/2000/svg" width="{total}" height="20" role="img" aria-label="{label}: {message}"> description = description or f"{label}: {message}"
<title>{label}: {message}</title> return f'''<svg xmlns="http://www.w3.org/2000/svg" width="{total}" height="20" role="img" aria-label="{description}">
<title>{description}</title>
<linearGradient id="s" x2="0" y2="100%"> <linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/> <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/> <stop offset="1" stop-opacity=".1"/>
@@ -174,10 +176,10 @@ def main() -> int:
os.makedirs(os.path.join(args.root, args.out), exist_ok=True) os.makedirs(os.path.join(args.root, args.out), exist_ok=True)
def write(name, label, message, color): def write(name, label, message, color, description=None):
path = os.path.join(args.root, args.out, name + ".svg") path = os.path.join(args.root, args.out, name + ".svg")
with open(path, "w", encoding="utf-8") as fh: with open(path, "w", encoding="utf-8") as fh:
fh.write(badge_svg(label, message, color)) fh.write(badge_svg(label, message, color, description))
print(f"wrote {path}: {label}={message}") print(f"wrote {path}: {label}={message}")
loc = count_loc(args.root) loc = count_loc(args.root)
@@ -190,7 +192,8 @@ def main() -> int:
grade = quality_grade(args.clippy) 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],
f"code quality: {grade} (first-party Clippy only)")
if args.tests is not None: if args.tests is not None:
write("tests", "tests", f"{args.tests} passing", "brightgreen") write("tests", "tests", f"{args.tests} passing", "brightgreen")
if args.coverage is not None: if args.coverage is not None:
+11
View File
@@ -50,6 +50,17 @@ class BenchBadgeTests(unittest.TestCase):
self.assertEqual(gen_badges.bench_color(30.0), "brightgreen") self.assertEqual(gen_badges.bench_color(30.0), "brightgreen")
self.assertEqual(gen_badges.bench_color(-55.5555556), "orange") self.assertEqual(gen_badges.bench_color(-55.5555556), "orange")
def test_quality_grade_is_only_the_clippy_result(self):
self.assertEqual(gen_badges.quality_grade("clean"), "A")
self.assertEqual(gen_badges.quality_grade("failed"), "F")
self.assertEqual(gen_badges.quality_grade(None), "pending")
svg = gen_badges.badge_svg(
"code quality", "A", "brightgreen",
"code quality: A (first-party Clippy only)",
)
self.assertIn('aria-label="code quality: A (first-party Clippy only)"', svg)
self.assertIn('>A</text>', svg)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()