name: Integration tests on: pull_request: branches: [main] push: branches: [main] permissions: contents: read jobs: # The suite outgrew a single runner, and then a half-suite outgrew a slow # one: two shards cleared in ~14 minutes on a quiet day, but with six pull # requests running side by side the larger shard hit the same 25-minute # guard the split was meant to escape. Three shards keep the biggest slice # around 60 files, which clears the guard with real headroom even on the # slowest runner observed. Each shard boots its own Postgres testcontainer; # the timeout stays a hang detector, not a performance budget. shard: runs-on: ubuntu-latest timeout-minutes: 25 strategy: fail-fast: false matrix: shard: [1, 2, 3] name: integration shard ${{ matrix.shard }}/3 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 22 cache: pnpm - run: pnpm install --frozen-lockfile - run: pnpm db:generate # vitest is invoked directly: pnpm passes the `--` separator through to # the script literally, so `pnpm test:integration -- --shard=…` hands # vitest a stray positional argument and the shard flag never applies — # both "shards" then run the full suite. Proven by a paired local run # before this workflow shipped. - run: pnpm exec vitest run --config vitest.integration.config.mts --shard=${{ matrix.shard }}/3 env: # The integration suite boots a Postgres testcontainer and points # Prisma at it via DATABASE_URL set inside `tests/integration/setup.ts`. # These env vars satisfy code paths that read them at module load. # # ENCRYPTION_KEY MUST be quoted: YAML 1.2 parses an unquoted run of # zeros as the integer 0, which then arrives in `process.env` as the # string "0" — failing crypto's hex/base64 length check and breaking # the backups + integration-status suites for 50+ runs (regression # since v1.4.13). Quoting forces a literal scalar. API_TOKEN_HMAC_KEY: "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" ENCRYPTION_KEY: "0000000000000000000000000000000000000000000000000000000000000000" SESSION_SECRET: "integration-tests" # Branch protection requires a check named exactly "integration". This job # carries that name and answers for both shards: it fails when any shard # failed or was cancelled, so a half-green matrix cannot satisfy the gate. integration: runs-on: ubuntu-latest needs: shard if: always() timeout-minutes: 5 steps: - name: Every shard finished green run: | if [ "${{ needs.shard.result }}" != "success" ]; then echo "shard result: ${{ needs.shard.result }}" exit 1 fi