feat(ci): add automated badge update workflow (#138) - #343
Conversation
Implements #138 - Workflow triggers on successful CI run on main branch - Counts tests from bats unit + integration test files - Updates README.md test count badge and text references - Updates CLAUDE.md test references if present - Prevents infinite loops by skipping if last commit was badge-only - Uses conventional commit format for badge updates
|
Claude finished @frankbria's task in 10m 19s —— View job Precision review complete — PR #343Posted 3 inline findings (all minor) on
No critical/major, security, data-loss, or runtime-crash defects. Did not modify files or push. |
| sed -i "s|https://img.shields.io/badge/tests-[0-9]*%20passing|https://img.shields.io/badge/tests-${TEST_COUNT}%20passing|g" README.md | ||
| sed -i "s|tests-[0-9]*%20passing|tests-${TEST_COUNT}%20passing|g" README.md | ||
| sed -i "s/\*\*Test Coverage\*\*: [0-9]* tests/\*\*Test Coverage\*\*: ${TEST_COUNT} tests/g" README.md | ||
| sed -i "s/\*\*[0-9]* tests\*\* across/\*\*${TEST_COUNT} tests\*\* across/g" README.md |
There was a problem hiding this comment.
[minor] Two README test-count references use patterns that no sed here matches, so they stay stale while the badge and the other lines are rewritten — the README ends up displaying two different test counts at once.
Failure scenario: README currently shows 784 at line 1069 (# All 784 tests must pass) and line 1201 (- **784 tests across 34 test files**). After this workflow runs, the badge and lines 6/21/960 flip to the new count (e.g. 1279) but 1069 and 1201 keep 784, so the document contradicts itself. Line 1201's **N tests across lacks the inner ** that the line-51 regex requires, and All N tests isn't matched by any pattern.
| sed -i "s|https://img.shields.io/badge/tests-[0-9]*%20passing|https://img.shields.io/badge/tests-${TEST_COUNT}%20passing|g" README.md | |
| sed -i "s|tests-[0-9]*%20passing|tests-${TEST_COUNT}%20passing|g" README.md | |
| sed -i "s/\*\*Test Coverage\*\*: [0-9]* tests/\*\*Test Coverage\*\*: ${TEST_COUNT} tests/g" README.md | |
| sed -i "s/\*\*[0-9]* tests\*\* across/\*\*${TEST_COUNT} tests\*\* across/g" README.md | |
| sed -i "s|https://img.shields.io/badge/tests-[0-9]*%20passing|https://img.shields.io/badge/tests-${TEST_COUNT}%20passing|g" README.md | |
| sed -i "s|tests-[0-9]*%20passing|tests-${TEST_COUNT}%20passing|g" README.md | |
| sed -i "s/\*\*Test Coverage\*\*: [0-9]* tests/\*\*Test Coverage\*\*: ${TEST_COUNT} tests/g" README.md | |
| sed -i "s/\*\*[0-9]* tests\*\* across/\*\*${TEST_COUNT} tests\*\* across/g" README.md | |
| # also catch "**N tests across" (no inner **) and "All N tests", else those refs drift | |
| sed -i "s/\*\*[0-9]* tests across/\*\*${TEST_COUNT} tests across/g" README.md | |
| sed -i "s/All [0-9]* tests/All ${TEST_COUNT} tests/g" README.md |
| TEST_COUNT=$(grep -rE '^\s*@test\s' tests/unit/ tests/integration/ | wc -l) | ||
| TEST_FILES=$(find tests/unit/ tests/integration/ -name "*.bats" | wc -l) |
There was a problem hiding this comment.
[minor] The count excludes tests/e2e/, so the badge advertises fewer tests than the suite actually runs and than the README's own prose claims.
Failure scenario: grep over tests/unit/ tests/integration/ yields 1279, but the real total including tests/e2e/ is 1297 (the @test regex itself is fine — the only lines it "misses" are email addresses like e2e@test.local). README line 1201, which this workflow is meant to keep accurate, explicitly states the count covers "unit, integration, and end-to-end," so writing 1279 onto it makes that sentence false. Either include tests/e2e/ or drop "end-to-end" from the README wording.
| TEST_COUNT=$(grep -rE '^\s*@test\s' tests/unit/ tests/integration/ | wc -l) | |
| TEST_FILES=$(find tests/unit/ tests/integration/ -name "*.bats" | wc -l) | |
| TEST_COUNT=$(grep -rE '^\s*@test\s' tests/unit/ tests/integration/ tests/e2e/ | wc -l) | |
| TEST_FILES=$(find tests/unit/ tests/integration/ tests/e2e/ -name "*.bats" | wc -l) |
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add README.md CLAUDE.md | ||
| git commit -m "ci(badge): update test count to ${TEST_COUNT} (${TEST_FILES} files)" | ||
| git push |
There was a problem hiding this comment.
[minor] With no concurrency group, two near-simultaneous merges each complete "Test Suite" and fire this workflow; both jobs compute and push, and the second git push is rejected (non-fast-forward), failing the job and dropping that badge update until the next push.
Failure scenario: PR A and PR B land on main within a minute → two workflow_run triggers → two update-badges jobs run concurrently → job 1 pushes ci(badge):… → job 2's git push exits non-zero → job 2 fails (red ❌) and its count update is silently lost (self-heals only on the next real push). Fix: add a job-level concurrency: group (e.g. group: update-badges, cancel-in-progress: false) so the pushes serialize.
GLM precision review — PR #343Scoped to concrete defects only (logic errors, security, data loss, races). Style/architecture/coverage are covered by the general review.
3 inline comments posted with failure scenarios + suggestion blocks. No critical/major issues; no security, data-loss, or runtime-crash defects found. Not approving or requesting changes. |
Summary
Implements #138: feat: automate version and test count badges via GitHub Actions
@testentries in unit + integration test filesAcceptance Criteria
Closes #138