ci-pr.yml e ci.yml deixam de ter jobs irmãos: 1 job 'checks' com steps em série (guards → lint → format → typecheck → knip → cycles → unit → int → build → e2e). Step vermelho interrompe o job, o run falha e o slot é liberado — sem API de cancel (Forgejo 9.0.3 não tem), sem watchdog, sem upgrade do Forgejo. Skips do ci-scope.mjs viram step id 'scope'; e2e em 1 processo com PLAYWRIGHT_WORKERS=4 (substitui 2 shards × 2 workers); 2 services Postgres por run com portas host derivadas do run_id (runs concorrentes não colidem); contexto 'CI (PR) / checks' preservado (job id checks — contrato do automerger OPS61); deploy OPS53 gated em needs checks. Plumbing morto removido (e2eShardConfig/e2e_shards). Docs: AGENT-OPS, TESTING.md, changelog. Impl: docs/plans/ops62-ci-fail-fast-forgejo-impl.md (a intenção watchdog+upgrade fica como histórico do gate).
173 lines
7.3 KiB
YAML
173 lines
7.3 KiB
YAML
# Post-merge verifier on `main`: always the FULL suite (no affected skips).
|
||
# SINGLE sequential job (OPS62, X1): one container, one checkout, one pnpm
|
||
# install, one runner slot. Fail-fast is STRUCTURAL — a failed step skips
|
||
# every step after it, the job fails, the run fails and the slot is released
|
||
# immediately. No cancel-run API (Forgejo 9.0.3 has none), no watchdog job,
|
||
# no upgrades. `deploy` (needs: [checks]) never starts on a red run.
|
||
#
|
||
# When the suite is green, the `deploy` job publishes teqo-1313 on the
|
||
# homeserver (OPS53): it streams scripts/deploy-homeserver.sh to the homeserver
|
||
# over SSH; the remote script builds the standalone image at the pushed SHA,
|
||
# pushes it to the local registry (localhost:5000), applies pending migrations
|
||
# through the compose maintenance service and rolls the container out.
|
||
#
|
||
# Forgejo port (OPS50): Postgres services publish to per-port HOST ports on
|
||
# the runner machine (act/forgejo runner semantics — the canonical 5432 is the
|
||
# workstation's own dev database), and steps reach them through the bridge
|
||
# gateway: DB_HOST = gateway IP from /proc/net/route. Host ports derive from
|
||
# the run id (OPS62 X1) so concurrent runs never collide; two isolated
|
||
# services — int and build+e2e — keep e2e from inheriting int fixture residue.
|
||
# No `permissions:` (Forgejo issues one native GITHUB_TOKEN) and no
|
||
# `concurrency:` (unsupported). `gh workflow run` requeues became
|
||
# `node scripts/forgejo-dispatch.mjs`.
|
||
name: CI
|
||
|
||
on:
|
||
push:
|
||
branches: [main]
|
||
workflow_dispatch:
|
||
|
||
env:
|
||
PAYLOAD_SECRET: test-only-secret-not-used-in-production
|
||
NEXT_PUBLIC_SITE_URL: http://localhost:3000
|
||
|
||
jobs:
|
||
checks:
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 50
|
||
services:
|
||
# Host ports derive from the run id (OPS62 X1): the single job holds
|
||
# both services for the whole run, and concurrent runs on the shared
|
||
# runner would collide on fixed ports ("port is already allocated") —
|
||
# a ~1% residual collision when two runs share run_id % 100 is loud,
|
||
# harmless and fixed by the next push.
|
||
postgres-int:
|
||
image: postgres:17-alpine
|
||
env:
|
||
POSTGRES_USER: teqo
|
||
POSTGRES_PASSWORD: teqo
|
||
POSTGRES_DB: teqo_test
|
||
ports:
|
||
- ${{ 5433 + (github.run_id % 100) }}:5432
|
||
options: >-
|
||
--health-cmd "pg_isready -U teqo"
|
||
--health-interval 5s
|
||
--health-timeout 5s
|
||
--health-retries 12
|
||
postgres-build:
|
||
image: postgres:17-alpine
|
||
env:
|
||
POSTGRES_USER: teqo
|
||
POSTGRES_PASSWORD: teqo
|
||
POSTGRES_DB: teqo_test
|
||
ports:
|
||
- ${{ 5533 + (github.run_id % 100) }}:5432
|
||
options: >-
|
||
--health-cmd "pg_isready -U teqo"
|
||
--health-interval 5s
|
||
--health-timeout 5s
|
||
--health-retries 12
|
||
steps:
|
||
- uses: actions/checkout@v5
|
||
- uses: pnpm/action-setup@v6
|
||
- uses: actions/setup-node@v5
|
||
with:
|
||
node-version: 24
|
||
cache: pnpm
|
||
- run: pnpm install --frozen-lockfile
|
||
|
||
- name: Check test file locations
|
||
run: node scripts/check-test-locations.mjs
|
||
- name: Lint
|
||
run: pnpm lint
|
||
- name: Format check
|
||
run: pnpm format:check
|
||
- name: Typecheck
|
||
run: pnpm typecheck
|
||
- name: Knip
|
||
run: pnpm knip
|
||
- name: Check cycles
|
||
run: pnpm check:cycles
|
||
- name: Unit tests (full suite)
|
||
run: pnpm test:unit
|
||
|
||
- name: Prepare database URL (int service via bridge gateway)
|
||
run: |
|
||
set -euo pipefail
|
||
DB_HOST=$(awk '$2 == "00000000" {a=$3; print strtonum("0x" substr(a,7,2)) "." strtonum("0x" substr(a,5,2)) "." strtonum("0x" substr(a,3,2)) "." strtonum("0x" substr(a,1,2)); exit}' /proc/net/route)
|
||
DB_PORT=${{ 5433 + (github.run_id % 100) }}
|
||
echo "DATABASE_URL=postgresql://teqo:teqo@${DB_HOST}:${DB_PORT}/teqo_test" >> "$GITHUB_ENV"
|
||
# vitest re-loads .env.test over the process env, so the service URL
|
||
# must win through the .env.test.local layer (same mechanism
|
||
# `pnpm worktree next` uses). OPS50.
|
||
echo "DATABASE_URL=postgresql://teqo:teqo@${DB_HOST}:${DB_PORT}/teqo_test" > .env.test.local
|
||
- name: Migrate (int database)
|
||
run: pnpm migrate
|
||
- name: Seed minimal (int database)
|
||
run: pnpm db:seed:minimal
|
||
- name: Integration tests (full suite)
|
||
env:
|
||
# Self-hosted runner has 8 CPUs; vitest forks ≈ CPUs and each fork
|
||
# holds a Payload pool (max 10) → overflows the service Postgres' 100
|
||
# clients ("too many clients already"). 4 forks stay well under. The
|
||
# unit step above stays CPU-relative (no DB).
|
||
VITEST_MAX_WORKERS: 4
|
||
run: pnpm test:int
|
||
|
||
- name: Prepare database URL (build/e2e service via bridge gateway)
|
||
run: |
|
||
set -euo pipefail
|
||
DB_HOST=$(awk '$2 == "00000000" {a=$3; print strtonum("0x" substr(a,7,2)) "." strtonum("0x" substr(a,5,2)) "." strtonum("0x" substr(a,3,2)) "." strtonum("0x" substr(a,1,2)); exit}' /proc/net/route)
|
||
DB_PORT=${{ 5533 + (github.run_id % 100) }}
|
||
echo "DATABASE_URL=postgresql://teqo:teqo@${DB_HOST}:${DB_PORT}/teqo_test" >> "$GITHUB_ENV"
|
||
echo "DATABASE_URL=postgresql://teqo:teqo@${DB_HOST}:${DB_PORT}/teqo_test" > .env.test.local
|
||
- name: Migrate (build/e2e database)
|
||
run: pnpm migrate
|
||
- name: Seed minimal (build/e2e database)
|
||
run: pnpm db:seed:minimal
|
||
|
||
- name: Build (against the service database)
|
||
run: pnpm build
|
||
|
||
- name: Cache Playwright browsers
|
||
uses: actions/cache@v4
|
||
with:
|
||
path: ~/.cache/ms-playwright
|
||
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
playwright-${{ runner.os }}-
|
||
- name: Install Playwright chromium
|
||
run: pnpm exec playwright install --with-deps chromium
|
||
- name: Build for e2e
|
||
# Same dir the Playwright webServer serves (playwright.config.ts
|
||
# falls back to '.next-e2e'; gate-ci.mjs builds there too).
|
||
run: pnpm build
|
||
env:
|
||
NEXT_DIST_DIR: .next-e2e
|
||
- name: E2E tests (full suite, single job, 4 workers)
|
||
# Explicit CI workers; the local default stays 2 (playwright.config.ts).
|
||
# 4 workers in one process replace the former 2 shards × 2 workers.
|
||
# No `--` separator: pnpm would forward it verbatim to playwright and
|
||
# the flag would be parsed as a file pattern ("No tests found").
|
||
env:
|
||
PLAYWRIGHT_WORKERS: 4
|
||
run: pnpm test:e2e
|
||
|
||
deploy:
|
||
name: deploy homeserver (teqo-1313)
|
||
# OPS53. Runs directly on the runner HOST (not a job container): the
|
||
# deploy needs the workstation's SSH key to reach the homeserver
|
||
# (`ssh homeserver`) and streams the whole remote build/migrate/rollout
|
||
# to this job's logs. Deliberately wired ONLY here — push to main +
|
||
# workflow_dispatch — never in ci-pr.yml: a host job is code execution as
|
||
# `fsolla` on the workstation, and main only ever moves through a merged
|
||
# PR whose full suite was already green.
|
||
needs: [checks]
|
||
runs-on: host
|
||
timeout-minutes: 60
|
||
steps:
|
||
- uses: actions/checkout@v5
|
||
- name: Deploy teqo-1313 on the homeserver
|
||
run: |
|
||
set -euo pipefail
|
||
ssh homeserver "bash -s -- $GITHUB_SHA" < scripts/deploy-homeserver.sh
|