69 lines
2.2 KiB
YAML
69 lines
2.2 KiB
YAML
name: Coverage
|
|
|
|
# Gitea variant of .github/workflows/coverage.yml. Runs vitest with --coverage
|
|
# and the per-path gate (scripts/verify-test-coverage.mjs) and upserts a
|
|
# sticky PR comment via the Gitea API.
|
|
#
|
|
# Spec: docs/improvement-plan/10-compliance-polish/test-coverage.md
|
|
# Docs: docs/architecture/test-coverage.md
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "apps/**"
|
|
- "packages/**"
|
|
- "scripts/coverage-targets.json"
|
|
- "scripts/verify-test-coverage.mjs"
|
|
- "scripts/coverage-summary.mjs"
|
|
- "vitest.config.ts"
|
|
- ".gitea/workflows/coverage.yml"
|
|
|
|
env:
|
|
TOOLCTRL_GITEA_HOST_IP: ${{ vars.TOOLCTRL_GITEA_HOST_IP }}
|
|
|
|
jobs:
|
|
coverage:
|
|
name: Measure coverage and gate thresholds
|
|
runs-on: toolctrl-ci
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Resolve internal Gitea host
|
|
run: |
|
|
if [ -n "${TOOLCTRL_GITEA_HOST_IP:-}" ]; then
|
|
if ! TOOLCTRL_GITEA_HOST_IP="$TOOLCTRL_GITEA_HOST_IP" node -e 'process.exit(require("node:net").isIP(process.env.TOOLCTRL_GITEA_HOST_IP || "") ? 0 : 1)'; then
|
|
echo "TOOLCTRL_GITEA_HOST_IP must be a single IPv4 or IPv6 token"
|
|
exit 1
|
|
fi
|
|
printf '%s git.tool-ctrl.de\n' "$TOOLCTRL_GITEA_HOST_IP" >> /etc/hosts
|
|
fi
|
|
|
|
- name: Checkout PR head
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Run vitest with coverage (enforces per-path gates)
|
|
run: pnpm run verify:test-coverage
|
|
|
|
- name: Render PR coverage comment
|
|
if: always()
|
|
run: node scripts/coverage-summary.mjs --pr-comment > coverage-comment.md
|
|
|
|
- name: Upsert Gitea PR comment
|
|
if: always()
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_HOST: ${{ vars.GITEA_HOST || 'git.tool-ctrl.de' }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
REPO: ${{ github.repository }}
|
|
COMMENT_PATH: coverage-comment.md
|
|
COMMENT_MARKER: "<!-- coverage-report -->"
|
|
run: node scripts/post-coverage-gitea-comment.mjs
|