mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
81 lines
3.3 KiB
YAML
81 lines
3.3 KiB
YAML
name: Integration tests
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# The suite outgrew a single runner, then a half-suite outgrew a slow one,
|
|
# and then a third of it did too. Three shards of about 68 files cleared in
|
|
# 13 minutes on an ordinary runner, but a slow runner day ran every test at
|
|
# twice its usual duration and the first shard was still working through
|
|
# its list when the 25-minute guard cut it off: three of four pushes to main
|
|
# between 2026-08-31 and 2026-09-01 failed that way, with green tests logged
|
|
# up to the last second. Four shards keep each slice around 50 files, and
|
|
# the guard sits at three times the ordinary run rather than under two. A
|
|
# wedged test still surfaces through vitest's own 60-second budget, so the
|
|
# job timeout only needs to catch a container that never boots. Each shard
|
|
# boots its own Postgres testcontainer.
|
|
shard:
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 40
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4]
|
|
name: integration shard ${{ matrix.shard }}/4
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
|
|
|
- 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 }}/4
|
|
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 every shard: it fails when any shard
|
|
# failed or was cancelled, so a half-green matrix cannot satisfy the gate.
|
|
integration:
|
|
runs-on: ubuntu-24.04
|
|
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
|