mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user