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. # # 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: 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 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: Configure pnpm store run: pnpm config set store-dir .pnpm-store - name: Cache pnpm store uses: actions/cache@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 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: "" run: node scripts/post-coverage-gitea-comment.mjs