mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 04:32:42 +00:00
The determinism guard reads the job that runs the browser, which is now the shard matrix rather than the gate that only carries the required check name. The report artifact is named per shard so the two uploads cannot clobber each other.
128 lines
4.5 KiB
YAML
128 lines
4.5 KiB
YAML
name: e2e
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# Cancel in-progress runs when a new commit lands on the same PR.
|
|
concurrency:
|
|
group: e2e-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# The suite outgrew the runner the same way the integration suite did: the
|
|
# single job passed at ~18 minutes against a 20-minute cap, and the settings
|
|
# geometry measurements pushed it over. Same remedy, split rather than raise:
|
|
# two Playwright shards, each with its own database and production build, and
|
|
# a gate job below that carries the exact name branch protection requires.
|
|
shard:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2]
|
|
name: e2e shard ${{ matrix.shard }}/2
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_USER: healthlog
|
|
POSTGRES_PASSWORD: healthlog
|
|
POSTGRES_DB: healthlog
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U healthlog"
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
|
|
env:
|
|
DATABASE_URL: postgresql://healthlog:healthlog@localhost:5432/healthlog?schema=public
|
|
ENCRYPTION_KEYS: '{"v1":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
|
|
ENCRYPTION_ACTIVE_KEY_ID: v1
|
|
API_TOKEN_HMAC_KEY: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
AUTH_RP_NAME: HealthLog
|
|
AUTH_RP_ID: localhost
|
|
AUTH_RP_ORIGIN: http://localhost:3000
|
|
SESSION_COOKIE_SECURE: "false"
|
|
NODE_ENV: production
|
|
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
|
|
|
|
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
|
|
- run: pnpm db:generate
|
|
|
|
- run: pnpm db:migrate:deploy
|
|
|
|
- name: Cache Playwright browsers
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
playwright-${{ runner.os }}-
|
|
|
|
- run: pnpm exec playwright install --with-deps chromium
|
|
|
|
# `pnpm build` (not bare `next build`): the prebuild hook generates
|
|
# the versioned service-worker stamp AND the static i18n catalog
|
|
# assets (public/i18n/<locale>.js) the client boots from — without
|
|
# them every UI interaction waits on missing catalogs.
|
|
# The repository-wide Next type worker exceeds V8's ~4 GiB default
|
|
# old-space ceiling. Keep the larger heap scoped to this production
|
|
# build only; tests and the runtime retain their normal limits.
|
|
- run: NODE_OPTIONS=--max-old-space-size=8192 pnpm build
|
|
|
|
# Client-bundle budget gate — rides this job because it is the one
|
|
# place CI already has a production build on disk. Catches the
|
|
# regressions the dead webpack-era tooling (ANALYZE=1, the old
|
|
# bundle-report) let through: a statically imported message catalog
|
|
# (~100 KB gz on every route) or a chart import bypassing the shared
|
|
# chart-runtime boundary (a duplicated ~92 KB gz recharts chunk).
|
|
- run: pnpm bundle-check
|
|
|
|
- run: pnpm exec playwright test --shard=${{ matrix.shard }}/2
|
|
env:
|
|
E2E_BASE_URL: http://localhost:3000
|
|
|
|
- name: Upload Playwright HTML report
|
|
if: always()
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: playwright-report-shard-${{ matrix.shard }}
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
if-no-files-found: ignore
|
|
|
|
# Branch protection requires a check named exactly "e2e". 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.
|
|
e2e:
|
|
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
|