Skip to content

feat(ci): add automated badge update workflow (#138) - #343

Open
frankbria wants to merge 1 commit into
mainfrom
feature/issue-138-feat-automate-version-and-test-count-bad
Open

feat(ci): add automated badge update workflow (#138)#343
frankbria wants to merge 1 commit into
mainfrom
feature/issue-138-feat-automate-version-and-test-count-bad

Conversation

@frankbria

Copy link
Copy Markdown
Owner

Summary

Implements #138: feat: automate version and test count badges via GitHub Actions

  • Workflow triggers on successful CI completion on main branch
  • Counts tests from bats @test entries in 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 a badge-only update
  • Uses conventional commit format for badge updates

Acceptance Criteria

  • Workflow runs after successful CI on main branch
  • Test count badge updates automatically
  • No workflow runs on badge-only commits (infinite loop prevention)
  • Commit messages follow conventional commit format

Closes #138

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
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

Claude finished @frankbria's task in 10m 19s —— View job


Precision review complete — PR #343

Posted 3 inline findings (all minor) on .github/workflows/update-badges.yml and a summary table comment.

  • 48-51 — README refs at lines 1069 / 1201 match no sed → doc holds two different test counts
  • 37 — count excludes tests/e2e/ (1279 vs 1297 real), contradicts README "end-to-end" wording
  • 79 — no concurrency group → concurrent runs race on git push

No critical/major, security, data-loss, or runtime-crash defects. Did not modify files or push.

Comment on lines +48 to +51
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
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

Comment on lines +37 to +38
TEST_COUNT=$(grep -rE '^\s*@test\s' tests/unit/ tests/integration/ | wc -l)
TEST_FILES=$(find tests/unit/ tests/integration/ -name "*.bats" | wc -l)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@github-actions

Copy link
Copy Markdown

GLM precision review — PR #343

Scoped to concrete defects only (logic errors, security, data loss, races). Style/architecture/coverage are covered by the general review.

severity file:line finding
minor .github/workflows/update-badges.yml:48-51 README refs at lines 1069 (All N tests) and 1201 (**N tests across) match no sed → README shows two different test counts after the run
minor .github/workflows/update-badges.yml:37 Count excludes tests/e2e/ (1279 vs 1297 real), contradicting README line 1201's "end-to-end" wording the workflow writes onto
minor .github/workflows/update-badges.yml:79 No concurrency group → concurrent workflow_run jobs race on git push; the loser fails non-fast-forward and its update is dropped

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: automate version and test count badges via GitHub Actions

1 participant