Skip to content

Harden napp init validation and docs build #89

Harden napp init validation and docs build

Harden napp init validation and docs build #89

Workflow file for this run

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"