name: Nightly unit coverage

on:
  schedule:
    - cron: '17 2 * * *'

concurrency:
  group: nightly-unit-coverage
  cancel-in-progress: true

permissions:
  contents: read

env:
  NODE_OPTIONS: --max-old-space-size=6144
  BUILD_VITEST_MAX_FORKS: '2'
  BUILD_VITEST_MAX_THREADS: '2'
  BUILD_SCHED_IDLE: '0'
  # Heavy lanes share a host under build.slice's aggregate ceiling instead of
  # queueing inside a timed step, where the wait consumed timeout-minutes.
  BUILD_NO_LOCK: '1'

jobs:
  coverage:
    name: Unit + coverage
    runs-on: [self-hosted, linux, x64, multideal-gate]
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v7
      - uses: ./.github/actions/setup
        with:
          github-packages-token: ${{ secrets.GH_PKG_READ_TOKEN }}
      - name: Unit + coverage tests
        run: bash apps/web/scripts/cpu-limit.sh pnpm --filter web test:coverage
