93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
name: Coverage
|
|
|
|
# Enforces the per-path Vitest coverage thresholds on the self-hosted Gitea
|
|
# runner. The rendered report is attached to the run so it remains available
|
|
# without a GitHub-specific PR-comment action.
|
|
|
|
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"
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
HIVEGRID_GITEA_HOST_IP: ${{ vars.HIVEGRID_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 "${HIVEGRID_GITEA_HOST_IP:-}" ]; then
|
|
if ! HIVEGRID_GITEA_HOST_IP="$HIVEGRID_GITEA_HOST_IP" node -e 'process.exit(require("node:net").isIP(process.env.HIVEGRID_GITEA_HOST_IP || "") ? 0 : 1)'; then
|
|
echo "HIVEGRID_GITEA_HOST_IP must be a single IPv4 or IPv6 token"
|
|
exit 1
|
|
fi
|
|
printf '%s git.tool-ctrl.de\n' "$HIVEGRID_GITEA_HOST_IP" >> /etc/hosts
|
|
fi
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
|
with:
|
|
node-version-file: .nvmrc
|
|
|
|
- name: Persist Node.js toolchain
|
|
run: bash scripts/ci/persist-node-toolchain.sh
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable --install-directory /usr/local/bin
|
|
|
|
- name: Prepare pnpm 11.12.0
|
|
run: corepack prepare pnpm@11.12.0 --activate
|
|
|
|
- name: Configure pnpm store
|
|
run: pnpm config set store-dir .pnpm-store
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Run Vitest coverage gate
|
|
run: pnpm run verify:test-coverage
|
|
|
|
- name: Render coverage report
|
|
if: always()
|
|
env:
|
|
COVERAGE_SUMMARY_PATH: coverage-gate/coverage-summary.json
|
|
run: node scripts/coverage-summary.mjs --pr-comment > coverage-report.md
|
|
|
|
- name: Upload coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3
|
|
with:
|
|
name: coverage-report-${{ gitea.run_id }}
|
|
path: |
|
|
coverage-gate/
|
|
coverage-report.md
|
|
retention-days: 14
|