feat: add automated test count update workflow

- Created update-test-counts.yml workflow
- Triggers on push to main (when Tests/ or Sources/ change) or daily at 2 AM UTC
- Counts @Test and @Suite annotations
- Updates README.md badges and test count locations
- Auto-commits with [skip ci] to prevent rebuild loops
- Can be manually triggered via workflow_dispatch
This commit is contained in:
phranck
2026-02-15 00:06:30 +01:00
parent 7972f3a065
commit 5f91a3cae6
+58
View File
@@ -0,0 +1,58 @@
name: Update Test Counts
on:
push:
branches: [main]
paths:
- 'Tests/**'
- 'Sources/**'
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch:
permissions:
contents: write
jobs:
update-test-counts:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Count tests and suites
id: counts
run: |
TESTS=$(grep -r '@Test\b' Tests/ --include='*.swift' 2>/dev/null | wc -l | tr -d ' ')
SUITES=$(grep -r '@Suite\b' Tests/ --include='*.swift' 2>/dev/null | wc -l | tr -d ' ')
echo "tests=$TESTS" >> "$GITHUB_OUTPUT"
echo "suites=$SUITES" >> "$GITHUB_OUTPUT"
echo "Found $TESTS tests in $SUITES test suites"
- name: Update README badges
run: |
TESTS="${{ steps.counts.outputs.tests }}"
SUITES="${{ steps.counts.outputs.suites }}"
# Update badge: Tests-XXXX%2B_passing
sed -i '' "s/Tests-[0-9]*%2B_passing/Tests-${TESTS}%2B_passing/" README.md
# Update project structure line: "XXXX tests across YYYY test suites"
sed -i '' "s/[0-9]* tests across [0-9]* test suites/${TESTS} tests across ${SUITES} test suites/" README.md
# Update developer notes: "All XXXX tests run"
sed -i '' "s/All [0-9]* tests run/All ${TESTS} tests run/" README.md
- name: Commit if changed
run: |
git diff --quiet README.md && echo "No changes to README" && exit 0
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "chore: update test count badge to ${{ steps.counts.outputs.tests }} tests [skip ci]"
git push