Skip to content

Commit ddc9b53

Browse files
committed
the README badges match the tree again: version 1.0.0 and the real suite count, with a new suite (test-badges) recomputing both from the manifests and hooks/ on every run
1 parent e31ea8e commit ddc9b53

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
<p>
99
<img src="https://img.shields.io/badge/license-MIT-1f6feb?style=flat-square" alt="License: MIT">
10-
<img src="https://img.shields.io/badge/version-0.8.0-8250df?style=flat-square" alt="Version 0.8.0">
11-
<img src="https://img.shields.io/badge/tests-16%20suites-3fb950?style=flat-square" alt="Tests: 16 suites">
10+
<img src="https://img.shields.io/badge/version-1.0.0-8250df?style=flat-square" alt="Version 1.0.0">
11+
<img src="https://img.shields.io/badge/tests-19%20suites-3fb950?style=flat-square" alt="Tests: 19 suites">
1212
<img src="https://img.shields.io/badge/routing%20eval-24%2F25-d29922?style=flat-square" alt="Routing eval: 24 of 25">
1313
</p>
1414

‎hooks/test-badges.sh‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# README badges state a version and a suite count. Every value here is
3+
# recomputed from the tree: the manifests are the only source for the version,
4+
# the hooks directory is the only source for the suite count. A badge number
5+
# that cannot be recomputed from the tree does not belong on the README.
6+
# Rationale: DECISIONS.md D-43.
7+
set -u
8+
here="$(cd "$(dirname "$0")" && pwd)"; root="$here/.."
9+
readme="$root/README.md"
10+
plugin="$root/.claude-plugin/plugin.json"
11+
market="$root/.claude-plugin/marketplace.json"
12+
13+
command -v jq >/dev/null || { echo "jq is required for this suite"; exit 1; }
14+
15+
fails=0; checks=0
16+
fail() { echo " FAIL: $1"; fails=$((fails+1)); }
17+
18+
v_plugin="$(jq -r .version "$plugin")"
19+
v_market="$(jq -r '.plugins[0].version' "$market")"
20+
21+
checks=$((checks+1))
22+
[ "$v_plugin" = "$v_market" ] || fail "manifest versions disagree: plugin.json $v_plugin vs marketplace.json $v_market"
23+
24+
n=0
25+
for f in "$root"/hooks/test-*.sh; do [ -f "$f" ] && n=$((n+1)); done
26+
27+
b_version="$(sed -n 's/.*img\.shields\.io\/badge\/version-\([0-9][0-9.]*\)-.*/\1/p' "$readme" | head -1)"
28+
b_suites="$(sed -n 's/.*img\.shields\.io\/badge\/tests-\([0-9][0-9]*\)%20suites.*/\1/p' "$readme" | head -1)"
29+
30+
checks=$((checks+1))
31+
[ "$b_version" = "$v_plugin" ] || fail "version badge says '${b_version:-none}', the manifests say $v_plugin"
32+
checks=$((checks+1))
33+
grep -qF "alt=\"Version $v_plugin\"" "$readme" || fail "version badge alt text does not say $v_plugin"
34+
checks=$((checks+1))
35+
[ "$b_suites" = "$n" ] || fail "tests badge says '${b_suites:-none}' suites, hooks/ holds $n"
36+
checks=$((checks+1))
37+
grep -qF "alt=\"Tests: $n suites\"" "$readme" || fail "tests badge alt text does not say $n suites"
38+
39+
echo
40+
if [ "$fails" -eq 0 ]; then
41+
echo "all checks pass ($checks)"
42+
exit 0
43+
else
44+
echo "$fails of $checks badge check(s) failed: recompute the badge from the tree (manifest version, live suite count) instead of hand-editing the number."
45+
exit 1
46+
fi

0 commit comments

Comments
 (0)