# 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 live on the job network and are # reached by NAME (postgres-int / postgres-build on 5432) — no host publish, # so concurrent runs never collide on host ports (OPS62 X1). 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: # Services are reached by NAME on the job network (no host publish — # OPS62 X1): concurrent runs never collide on host ports, which the # single long-lived job would hold for the whole run. Two isolated # services — int and build+e2e — keep e2e from inheriting int fixture # residue. Forgejo 9 does not expand expressions in `services.ports`, # so a per-run port scheme was dropped in favour of the job-network DNS. postgres-int: image: postgres:17-alpine env: POSTGRES_USER: teqo POSTGRES_PASSWORD: teqo POSTGRES_DB: teqo_test 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 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) run: | set -euo pipefail echo "DATABASE_URL=postgresql://teqo:teqo@postgres-int:5432/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@postgres-int:5432/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) run: | set -euo pipefail echo "DATABASE_URL=postgresql://teqo:teqo@postgres-build:5432/teqo_test" >> "$GITHUB_ENV" echo "DATABASE_URL=postgresql://teqo:teqo@postgres-build:5432/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