name: Coverage

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

concurrency:
  group: coverage-${{ github.ref }}
  cancel-in-progress: true

# Runs Vitest with --coverage and uploads the HTML report as an artifact.
# Coverage thresholds are not enforced by default — opt in by configuring
# `test.coverage.thresholds` in vitest.config.ts when your suite is ready.

jobs:
  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
      - uses: ./.github/actions/setup
        with:
          node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
      - run: pnpm theme:build
      - run: pnpm coverage
      - name: Upload coverage report
        if: always()
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: coverage-report
          path: coverage/
          retention-days: 14
