Merge pull request #176 from taylorcox75/claude/fix-cold-launch-torre… #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| coverage: | |
| name: Test coverage | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests with coverage | |
| run: npx jest --coverage --coverageReporters=json-summary | |
| # The README coverage badge reads badge.json off the `coverage` branch | |
| # via shields.io's endpoint badge type, so this branch holds only that | |
| # file and is force-pushed on every run. We compute the threshold color | |
| # ourselves here because shields.io's dynamic/json badge only supports a | |
| # fixed `color` query param — it can't derive color from the JSON value. | |
| - name: Publish badge to coverage branch | |
| run: | | |
| pct=$(node -p "require('./coverage/coverage-summary.json').total.lines.pct") | |
| color=$(node -p " | |
| const pct = $pct; | |
| pct >= 90 ? 'brightgreen' : | |
| pct >= 80 ? 'green' : | |
| pct >= 70 ? 'yellowgreen' : | |
| pct >= 60 ? 'yellow' : | |
| pct >= 50 ? 'orange' : 'red'; | |
| ") | |
| mkdir /tmp/pub | |
| node -e " | |
| require('fs').writeFileSync('/tmp/pub/badge.json', JSON.stringify({ | |
| schemaVersion: 1, | |
| label: 'Coverage', | |
| message: '${pct}%', | |
| color: '${color}', | |
| })); | |
| " | |
| cd /tmp/pub | |
| git init -b coverage | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add badge.json | |
| git commit -m "coverage: ${pct}% lines ($GITHUB_SHA)" | |
| git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" coverage | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |