mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 15:37:55 +01:00
/auth/login, /auth/register and /auth/forgot-password are AccountKit's forms: password, passkey, an email sign-in link, recovery, Sign in with OrangeCat and the shared bitbaum sign-in, each when its env is set. /dashboard/security carries AccountKit's account panel (password, passkeys, two-step sign-in, linked sign-ins, deletion). compat passes screens: 'accountkit' (AccountKit 0.20). AccountKit is the only credential writer. evig's /api/auth/register, forgot-password, reset-password and verify-email and /api/user/change-password are removed: they shadowed AccountKit's endpoints of the same names. Kept, as AccountKit hooks or evig's own code: the per-account lockout, the 6-digit address code (it replaces AccountKit's confirmation mail), IT-Hilfe's claim link (now an AccountKit reset token, old links honoured), the team invitation claim, the HR hire, staff permissions and referral credit. Deletion is refused for a super admin and for a person on kept records. Migration 143 (additive, idempotent) makes the panel's rename and deletion reach users. The e2e job imports the seeded accounts before the journeys and runs a browser journey through every method, with mail caught by a sink. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com>
590 lines
24 KiB
YAML
590 lines
24 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
workflow_dispatch: {}
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
NODE_VERSION: '24'
|
|
|
|
# A newer push to a PR branch supersedes the older run — dependabot rebases and
|
|
# agent re-pushes were each paying ~10 minutes of CI for a commit nobody would
|
|
# merge. On main the group is per COMMIT and never cancels: two merges run side
|
|
# by side, and a re-armed dispatch for the same commit queues behind its push
|
|
# run instead of killing it (deploy chains off a run that finished).
|
|
concurrency:
|
|
group: ci-${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || 'branch' }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
jobs:
|
|
# Quality checks - runs on all branches and PRs
|
|
# Self-host deploy: .github/workflows/deploy-selfhost.yml on push to main
|
|
quality:
|
|
name: Code Quality Checks
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# Next keeps its compiler output in .next/cache. Without restoring it every
|
|
# build in this repo is COLD — and this workflow builds twice (here and in
|
|
# the E2E job), while the deploy builds again. Measured 2026-09-07: the
|
|
# verify step alone was 9.6m. The deploy workflow already caches this; CI
|
|
# never did, which is why CI was the slower of the two.
|
|
#
|
|
# Key includes the job so the two builds do not fight over one cache entry;
|
|
# restore-keys let either warm from whichever ran last on this lockfile.
|
|
- name: Cache Next.js build
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: .next/cache
|
|
key: nextjs-${{ runner.os }}-verify-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
nextjs-${{ runner.os }}-verify-${{ hashFiles('pnpm-lock.yaml') }}-
|
|
nextjs-${{ runner.os }}-
|
|
|
|
# SSOT: lint + umlauts + typecheck + test + build are bundled in the
|
|
# `verify` script (package.json). CI calls it verbatim so the gating
|
|
# chain can't drift from what runs locally. Do not re-inline these checks
|
|
# here — the umlaut gate (Swiss ä/ö/ü convention) lives inside `verify`
|
|
# too. Unit tests are ALSO run by the standalone `test` job below, which
|
|
# the post-main verdict needs by name; that duplication is deliberate and
|
|
# parallel (no wall-clock cost), not an oversight.
|
|
#
|
|
# MERGE → LIVE: ONE FULL PROOF PER CHANGE, ON THE PULL REQUEST. A squash
|
|
# merge onto main has already passed the whole bundle on its PR, and the
|
|
# deploy builds the app again, so repeating tests + build here only
|
|
# doubled merge→live (main CI 9.3 min median, 2026-10-27). A main tip whose
|
|
# subject names a PR — squash merges end in `(#N)` — gets `verify:main`
|
|
# (formatting, lint, the repo's own checks, typecheck). Pull requests and a
|
|
# main push WITHOUT `(#N)` keep the full bundle. Same rule as bitbaum/loki.
|
|
- name: Verify (lint + umlauts + typecheck + test + build)
|
|
run: |
|
|
set -euo pipefail
|
|
subject=$(git log -1 --format=%s)
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
echo "PR — full verify"
|
|
pnpm run verify
|
|
elif [ "${{ github.ref }}" = "refs/heads/main" ] && echo "$subject" | grep -Eq '\(#[0-9]+\)'; then
|
|
echo "main tip looks like a PR merge ($subject) — fast verify:main"
|
|
pnpm run verify:main
|
|
else
|
|
echo "main without PR subject ($subject) — full verify"
|
|
pnpm run verify
|
|
fi
|
|
env:
|
|
# Build-time placeholders so strict env validation doesn't fail during CI compile.
|
|
AUTH_SECRET: ci-build-placeholder-secret-32chars
|
|
DB_HOST: localhost
|
|
DB_NAME: evig_ci
|
|
DB_USER: ci
|
|
DB_PASSWORD: ci
|
|
|
|
# Auth smoke gate: verifies prod login when E2E secrets are present.
|
|
# Prefers dual-persona admin credentials; falls back to legacy AUTH_TEST_*.
|
|
auth-smoke:
|
|
name: Auth Smoke Test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
# Already proven on the pull request; a PR-merge push to main (subject has
|
|
# `(#N)`) skips it. Dispatched and non-PR main runs still run it.
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '(#')
|
|
# Deliberately NO `needs:`. This job tests the ALREADY-DEPLOYED production
|
|
# site (PLAYWRIGHT_BASE_URL defaults to https://evig.orangecat.ch); it
|
|
# never builds this branch and reads nothing `quality` produced. Waiting on
|
|
# `quality` (429s) was ordering, not dependency — and after #303 unblocked
|
|
# the e2e job, this pair became the new critical path: quality 429s →
|
|
# inventory-smoke 181s = 610s of a 634s run.
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Install Playwright browser
|
|
run: pnpm exec playwright install --with-deps chromium
|
|
|
|
- name: Run auth smoke (if credentials configured)
|
|
env:
|
|
AUTH_TEST_EMAIL: ${{ secrets.AUTH_TEST_EMAIL }}
|
|
AUTH_TEST_PASSWORD: ${{ secrets.AUTH_TEST_PASSWORD }}
|
|
AUTH_TEST_ADMIN_EMAIL: ${{ secrets.AUTH_TEST_ADMIN_EMAIL }}
|
|
AUTH_TEST_ADMIN_PASSWORD: ${{ secrets.AUTH_TEST_ADMIN_PASSWORD }}
|
|
run: |
|
|
EMAIL="${AUTH_TEST_EMAIL:-${AUTH_TEST_ADMIN_EMAIL:-}}"
|
|
PASSWORD="${AUTH_TEST_PASSWORD:-${AUTH_TEST_ADMIN_PASSWORD:-}}"
|
|
if [ -z "$EMAIL" ] || [ -z "$PASSWORD" ]; then
|
|
echo "No AUTH_TEST_* or AUTH_TEST_ADMIN_* secrets — skipping auth smoke."
|
|
exit 0
|
|
fi
|
|
export AUTH_TEST_EMAIL="$EMAIL"
|
|
export AUTH_TEST_PASSWORD="$PASSWORD"
|
|
PLAYWRIGHT_BASE_URL="${PLAYWRIGHT_BASE_URL:-https://evig.orangecat.ch}" \
|
|
pnpm exec playwright test tests/e2e/auth-smoke.spec.ts --project=chromium --reporter=line
|
|
|
|
# Prod health gate: full dual-persona route inventory (186 routes) when passwords set.
|
|
# Primary gate is post-deploy in deploy-selfhost.yml; this catches prod regressions on PRs too.
|
|
inventory-smoke:
|
|
name: Dual-Persona Inventory Smoke
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
# Already proven on the pull request; a PR-merge push to main (subject has
|
|
# `(#N)`) skips it. Dispatched and non-PR main runs still run it.
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '(#')
|
|
# Deliberately NO `needs:` — same reason as auth-smoke above. This walks 186
|
|
# routes on the LIVE site via scripts/e2e-inventory-prod.sh; nothing about
|
|
# that verdict depends on whether this branch lints. Removing the wait moves
|
|
# 181s off the critical path without changing what is checked.
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Install Playwright browser
|
|
run: pnpm exec playwright install --with-deps chromium
|
|
|
|
- name: Run inventory smoke (if dual-persona secrets configured)
|
|
env:
|
|
AUTH_TEST_USER_PASSWORD: ${{ secrets.AUTH_TEST_USER_PASSWORD }}
|
|
AUTH_TEST_ADMIN_PASSWORD: ${{ secrets.AUTH_TEST_ADMIN_PASSWORD }}
|
|
AUTH_TEST_USER_EMAIL: ${{ secrets.AUTH_TEST_USER_EMAIL }}
|
|
AUTH_TEST_ADMIN_EMAIL: ${{ secrets.AUTH_TEST_ADMIN_EMAIL }}
|
|
run: |
|
|
# The script has no baked-in persona addresses any more, so a missing
|
|
# address secret would abort inside it with a bare `parameter null`.
|
|
# Name the secret instead — but only once the passwords say the smoke
|
|
# is meant to run at all; with no secrets configured this still skips.
|
|
if [ -n "${AUTH_TEST_USER_PASSWORD:-}" ] && [ -n "${AUTH_TEST_ADMIN_PASSWORD:-}" ]; then
|
|
if [ -z "${AUTH_TEST_USER_EMAIL:-}" ]; then
|
|
echo "::error::AUTH_TEST_USER_EMAIL secret not set — the non-admin E2E login address has no default any more."
|
|
exit 1
|
|
fi
|
|
if [ -z "${AUTH_TEST_ADMIN_EMAIL:-}" ]; then
|
|
echo "::error::AUTH_TEST_ADMIN_EMAIL secret not set — the staff E2E login address has no default any more."
|
|
exit 1
|
|
fi
|
|
fi
|
|
bash scripts/e2e-inventory-prod.sh
|
|
|
|
# Migration drift check — applies every SQL migration in scripts/db/migrations/
|
|
# to a throwaway Postgres container. Uses pgvector image so 005-hirn-ai-rag.sql
|
|
# can CREATE EXTENSION vector. Runs on PRs and main pushes.
|
|
migrations:
|
|
name: Migration Drift Check
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg17
|
|
env:
|
|
POSTGRES_PASSWORD: ci
|
|
POSTGRES_DB: evig_drift
|
|
options: >-
|
|
--health-cmd "pg_isready -U postgres"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Apply migrations in order
|
|
env:
|
|
PGHOST: localhost
|
|
PGPORT: 5432
|
|
PGUSER: postgres
|
|
PGPASSWORD: ci
|
|
PGDATABASE: evig_drift
|
|
run: bash scripts/db/apply-migrations-ci.sh
|
|
|
|
# AccountKit on the chain just applied: the cutover import, its mirror
|
|
# triggers, and every way in through the real handlers
|
|
# (docs/ACCOUNTKIT-MIGRATION.md).
|
|
- uses: pnpm/action-setup@v6
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
- run: pnpm install --frozen-lockfile
|
|
- name: Account journeys on the shared runtime
|
|
env:
|
|
EVIG_JOURNEY_DATABASE_URL: postgres://postgres:ci@localhost:5432/evig_drift
|
|
# The rehearsal must also pass on the same chain.
|
|
DATABASE_URL: postgres://postgres:ci@localhost:5432/evig_drift
|
|
run: |
|
|
pnpm run db:rehearse-import
|
|
pnpm exec vitest run src/lib/auth/shared
|
|
|
|
e2e-local:
|
|
name: Local E2E Journeys
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
# Already proven on the pull request; a PR-merge push to main (subject has
|
|
# `(#N)`) skips it. Dispatched and non-PR main runs still run it.
|
|
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '(#')
|
|
# Deliberately NO `needs:`. This job is self-contained — it brings its own
|
|
# postgres service, applies its own migrations, seeds its own data, builds
|
|
# the app and starts its own server. It consumed no output from `quality`
|
|
# or `migrations`; both were gates expressed as dependencies, and they cost
|
|
# the full 373s of `quality` on the critical path of the second-longest job.
|
|
#
|
|
# Measured before: quality 373s → e2e 336s = 709s wall-clock.
|
|
# `needs:` is for "I use what that job produced", not "I prefer to run
|
|
# after it". Every job here remains a required check regardless of order.
|
|
#
|
|
# Trade-off, stated: a PR that fails lint now also spends the e2e minutes
|
|
# rather than being cut off early.
|
|
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg17
|
|
env:
|
|
POSTGRES_PASSWORD: ci
|
|
POSTGRES_DB: evig_e2e
|
|
options: >-
|
|
--health-cmd "pg_isready -U postgres"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
env:
|
|
AUTH_SECRET: ci-e2e-placeholder-secret-32chars
|
|
# AccountKit's origin check reads the public origin, baked in at build time.
|
|
NEXT_PUBLIC_SITE_URL: http://localhost:3001
|
|
NEXTAUTH_URL: http://localhost:3001
|
|
AUTH_URL: http://localhost:3001
|
|
PLAYWRIGHT_BASE_URL: http://localhost:3001
|
|
DB_HOST: localhost
|
|
DB_PORT: 5432
|
|
DB_NAME: evig_e2e
|
|
DB_USER: postgres
|
|
DB_PASSWORD: ci
|
|
DB_SSL: false
|
|
PGHOST: localhost
|
|
PGPORT: 5432
|
|
PGUSER: postgres
|
|
PGPASSWORD: ci
|
|
PGDATABASE: evig_e2e
|
|
AUTH_TEST_EMAIL: e2e-admin@evig.test
|
|
AUTH_TEST_PASSWORD: E2EAdmin123!
|
|
AUTH_TEST_ADMIN_EMAIL: e2e-admin@evig.test
|
|
AUTH_TEST_ADMIN_PASSWORD: E2EAdmin123!
|
|
AUTH_TEST_SECOND_ADMIN_EMAIL: e2e-admin2@evig.test
|
|
AUTH_TEST_SECOND_ADMIN_PASSWORD: E2EAdmin123!
|
|
AUTH_TEST_USER_EMAIL: e2e-user@evig.test
|
|
AUTH_TEST_USER_PASSWORD: E2EUser123!
|
|
# The account journey (tests/e2e/account-journey.spec.ts): every way in
|
|
# on AccountKit's screens. Mail is caught by scripts/ci/mail-sink.cjs, in
|
|
# a file outside the uploaded artifacts (it holds synthetic reset tokens).
|
|
# The OrangeCat and bitbaum sign-in client values exist only so their
|
|
# buttons render, and are never used to sign in.
|
|
LEGACY_EMAIL: legacy-journey@example.test
|
|
LEGACY_PASSWORD: synthetic legacy journey password
|
|
MAIL_SINK: /tmp/evig-ci-mail.jsonl
|
|
RESEND_API_KEY: re_ci_sink_only
|
|
RESEND_FROM: evig <evig@example.test>
|
|
ORANGECAT_OAUTH_CLIENT_ID: evig-ci
|
|
ORANGECAT_OAUTH_CLIENT_SECRET: ci-only
|
|
SIGNIN_ISSUER: https://morulia.orangecat.ch
|
|
SIGNIN_CLIENT_ID: evig-ci
|
|
SIGNIN_CLIENT_SECRET: ci-only
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Install Playwright browser
|
|
run: pnpm exec playwright install --with-deps chromium
|
|
|
|
- name: Apply migrations
|
|
run: bash scripts/db/apply-migrations-ci.sh
|
|
|
|
- name: Seed E2E data
|
|
run: pnpm run e2e:seed
|
|
|
|
# Every seeded account, plus one Auth.js-era account, moves to AccountKit
|
|
# the way production's did: the rehearsal (counts only), then the import
|
|
# and its mirror triggers.
|
|
- name: AccountKit import of the seeded accounts
|
|
env:
|
|
DATABASE_URL: postgres://postgres:ci@localhost:5432/evig_e2e
|
|
run: |
|
|
node scripts/ci/seed-legacy-account.mjs | psql -v ON_ERROR_STOP=1 -q -X
|
|
pnpm run db:rehearse-import
|
|
psql -v ON_ERROR_STOP=1 -q -X -1 -f scripts/db/accountkit-import.sql
|
|
|
|
# Next keeps its compiler output in .next/cache. Without restoring it every
|
|
# build in this repo is COLD — and this workflow builds twice (here and in
|
|
# the E2E job), while the deploy builds again. Measured 2026-09-07: the
|
|
# verify step alone was 9.6m. The deploy workflow already caches this; CI
|
|
# never did, which is why CI was the slower of the two.
|
|
#
|
|
# Key includes the job so the two builds do not fight over one cache entry;
|
|
# restore-keys let either warm from whichever ran last on this lockfile.
|
|
- name: Cache Next.js build
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: .next/cache
|
|
key: nextjs-${{ runner.os }}-e2e-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
nextjs-${{ runner.os }}-e2e-${{ hashFiles('pnpm-lock.yaml') }}-
|
|
nextjs-${{ runner.os }}-
|
|
|
|
- name: Build app
|
|
run: pnpm run build
|
|
|
|
- name: Start app
|
|
run: |
|
|
NODE_OPTIONS="--require ./scripts/ci/mail-sink.cjs" pnpm run start -p 3001 > evig-e2e.log 2>&1 &
|
|
for i in {1..90}; do
|
|
if curl -fsS http://localhost:3001/api/health >/dev/null; then
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
cat evig-e2e.log
|
|
exit 1
|
|
|
|
- name: Run Playwright E2E journeys
|
|
run: pnpm run test:e2e:journeys --project=chromium --reporter=line
|
|
|
|
# Specs that are not named *journey and therefore fell outside the glob
|
|
# above — so nothing ran them, anywhere, ever. Run by name, not by
|
|
# pattern, so a file cannot silently drop out of coverage again.
|
|
# security 41 assertions: no admin page renders and no admin/
|
|
# money API answers 2xx to a signed-out request
|
|
# notification-hrefs 21 assertions
|
|
# user-admin-flows 16 assertions
|
|
- name: Run Playwright E2E guards
|
|
run: pnpm run test:e2e:guards --project=chromium --reporter=line
|
|
|
|
- name: Upload E2E artifacts
|
|
if: always()
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: e2e-local-artifacts
|
|
path: |
|
|
playwright-report/
|
|
test-results/
|
|
evig-e2e.log
|
|
if-no-files-found: ignore
|
|
|
|
# Unit tests. This job ran with `continue-on-error: true` from the day it was
|
|
# added ("non-blocking while suite matures"), and the suite matured to 7,769
|
|
# tests without anyone flipping it back. The cost was not hypothetical: the
|
|
# 2026-07-28 primary-* -> success-* token sweep left 25 assertions failing in
|
|
# 15 suites, and every PR since reported this job green. A gate whose result
|
|
# is discarded is not a gate — it is a 6-minute no-op that buys confidence it
|
|
# has not earned.
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Run tests
|
|
run: pnpm run test
|
|
|
|
# Dependency advisories. Blocks a PR that INTRODUCES a critical; high and
|
|
# below are reported but do not fail, because a third party publishing an
|
|
# advisory must not be able to jam the merge train (auto-merge refuses a red
|
|
# base). Advisories that appear with no code change are caught by the
|
|
# scheduled security-audit.yml instead — this job only sees what a run touches.
|
|
security:
|
|
name: Dependency Security Audit
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
# No version input: pnpm/action-setup reads packageManager from package.json.
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# The action's default store nests inside its own bin dir; a git-dep
|
|
# prepare build then dies with TS2742. Pin the store somewhere sane.
|
|
- name: Set pnpm store dir
|
|
run: pnpm config set store-dir ~/.pnpm-store --global
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Audit runtime dependencies
|
|
env:
|
|
FAIL_ON: critical
|
|
run: bash scripts/ci/dependency-audit.sh
|
|
|
|
- name: Patched mail and browser dependency compatibility
|
|
env:
|
|
BROWSER_EXECUTABLE: /usr/bin/google-chrome
|
|
run: node --test scripts/ci/security-dependency-smoke.mjs
|
|
|
|
# Red-main alarm for the DISPATCHED path.
|
|
#
|
|
# Every merge here is an auto-merge made with GITHUB_TOKEN, which fires no
|
|
# push event — so the sweep re-arms this workflow by dispatch, and a
|
|
# dispatched run emits no `workflow_run` event for main-red-alert.yml to
|
|
# catch. That workflow is therefore silent on almost every main CI run this
|
|
# repo produces (observed 2026-08-06: main went red on a66baa55 and no issue
|
|
# was filed). A dispatched run does the handoff itself; the push path keeps
|
|
# using main-red-alert.yml. One trigger per path, one shared policy script.
|
|
post-main:
|
|
name: Main Red Alert (dispatched)
|
|
# MUST list every other job in this file. The alarm's verdict has to mean
|
|
# the same thing as the merge gate's, and the gate reads the RUN's
|
|
# conclusion — which every job contributes to. Enforced by
|
|
# src/__tests__/ci/main-red-verdict.test.ts, because this list has already
|
|
# drifted once (see the commit that added this comment).
|
|
needs: [quality, auth-smoke, inventory-smoke, migrations, e2e-local, test, security]
|
|
if: always() && github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
issues: write
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Resolve this run's verdict
|
|
id: verdict
|
|
env:
|
|
R_QUALITY: ${{ needs.quality.result }}
|
|
R_AUTH: ${{ needs.auth-smoke.result }}
|
|
R_INVENTORY: ${{ needs.inventory-smoke.result }}
|
|
R_MIGRATIONS: ${{ needs.migrations.result }}
|
|
R_E2E: ${{ needs.e2e-local.result }}
|
|
R_TEST: ${{ needs.test.result }}
|
|
R_SECURITY: ${{ needs.security.result }}
|
|
run: |
|
|
set -euo pipefail
|
|
# The question this answers is NOT "did the code break?" but "is main
|
|
# blocking the merge queue?" — because that is what the auto-merge
|
|
# green-base guard asks, and the two must agree.
|
|
#
|
|
# So anything that is not success-or-skipped counts as red, including
|
|
# `cancelled`. A cancelled job on main blocks every open PR exactly as
|
|
# hard as a failing one; treating it as a non-event is what let main
|
|
# sit red and SILENT for ~14h on 2026-08-07 while 11 PRs waited.
|
|
# (`skipped` stays green: jobs here are conditional on event type.)
|
|
results="$R_QUALITY $R_AUTH $R_INVENTORY $R_MIGRATIONS $R_E2E $R_TEST $R_SECURITY"
|
|
conclusion=success
|
|
for result in $results; do
|
|
case "$result" in
|
|
success|skipped) ;;
|
|
*) conclusion=failure ;;
|
|
esac
|
|
done
|
|
echo "conclusion=$conclusion" >> "$GITHUB_OUTPUT"
|
|
echo "verdict: $conclusion (from: $results)"
|
|
|
|
- name: File or resolve the main-red issue
|
|
env:
|
|
CONCLUSION: ${{ steps.verdict.outputs.conclusion }}
|
|
RUN_SHA: ${{ github.sha }}
|
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
run: bash scripts/ci/main-red-alert.sh
|