Harden napp init validation and docs build #89
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] | |
| paths: | |
| - "src/**" | |
| - "tests/**" | |
| - "deno.json" | |
| pull_request: | |
| paths: | |
| - "src/**" | |
| - "tests/**" | |
| - "deno.json" | |
| workflow_dispatch: | |
| # Read-only by default; write only granted to the badge-commit job | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: coverage-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: Run Tests & Generate Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Deno | |
| uses: denoland/setup-deno@v1 | |
| with: | |
| deno-version: v2.x | |
| - name: Run tests with coverage | |
| run: deno task coverage | |
| - name: Generate LCOV report | |
| run: deno coverage test-output/coverage --lcov > test-output/coverage.lcov | |
| - name: Generate coverage badges | |
| run: deno run --allow-read --allow-write --allow-run scripts/generate-coverage-badges.ts | |
| - name: Upload badge artifacts | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-badges | |
| path: | | |
| static/coverage-badge.svg | |
| static/coverage-lines-badge.svg | |
| static/coverage-branches-badge.svg | |
| commit-badges: | |
| name: Commit Updated Badges | |
| needs: test | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download badge artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-badges | |
| path: static/ | |
| - name: Commit updated badges | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add static/coverage-badge.svg static/coverage-lines-badge.svg static/coverage-branches-badge.svg | |
| git diff --staged --quiet || git commit -m "ci: update coverage badges [skip ci]" | |
| git pull --rebase | |
| push_stderr="$(mktemp)" | |
| if ! git push 2>"$push_stderr"; then | |
| if grep -qiE 'GH006|GH013|protected branch|repository rule violations' "$push_stderr"; then | |
| echo "Push blocked by branch protection (badges not updated)" | |
| else | |
| cat "$push_stderr" >&2 | |
| rm -f "$push_stderr" | |
| exit 1 | |
| fi | |
| fi | |
| rm -f "$push_stderr" |