Files
CatoandClaude Opus 5.5 8c1107fb9a chore(ci): one check per change — remove the merge sweep, check on PRs only (#413)
Removes the fleet auto-merge sweep caller (and wake chain where present);
checks run on pull requests only, not again after merging; a deploy that
waited for CI on main now deploys on push. The forge merge check
(forge/verify) verifies each PR on its merge result and merges it.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 02:49:46 +01:00

102 lines
4.2 KiB
YAML

name: CI
# WHY THIS FILE EXISTS, AND WHY IT IS NOT OPTIONAL
#
# loki's ci-gate.sh treats "CI green" and "no CI at all" identically —
# both exit 0 and let the deploy proceed. That is a sane default for a repo
# that has not set CI up yet, and it means a site WITHOUT this file deploys
# every push completely unverified while looking exactly like one that passed.
#
# Substrata shipped to production that way. So the scaffold emits this file with
# every new site: the gate has something real to wait for from the first commit.
#
# Runs the same bundle as `pnpm run verify` locally — one definition of verified.
on:
pull_request:
branches: [main]
workflow_dispatch: {}
# A newer push supersedes an older run. ci-gate.sh understands cancelled-and-
# superseded as a clean skip rather than a failure.
# On a branch the newest push is the only one that matters, so cancel the rest.
#
# On main the group is keyed per COMMIT. A commit cancelling a DIFFERENT
# commit's run breaks deployment, because every deploy path keys off that run:
# one that waits for CI to pass on the commit finds a cancelled run and stops,
# and one chained on `workflow_run` sees conclusion=cancelled and skips.
# auto-merge also re-arms CI with a dispatch, which under a single
# group-per-branch cancels the push run for the SAME commit.
#
# Measured 2026-09-11 across the fleet: 28 of 39 ci.yml files had this shape.
# loki stranded four merges silently (main green, nothing red, the box
# serving the previous build); hirnli failed its deploy loudly at the wait step.
concurrency:
group: ci-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || 'branch' }}
cancel-in-progress: true
jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 15
# A scratch PostgreSQL for test/data-layer-pg.test.ts: the migration runner is
# proven against a real database on every pull request, not by reading it.
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: scratch
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s
--health-retries 10
env:
SUBSTRATA_TEST_PG_URL: postgresql://postgres:scratch@127.0.0.1:5432/postgres
steps:
- uses: actions/checkout@v7
# pnpm before setup-node so `cache: pnpm` can find the store.
- uses: pnpm/action-setup@v6
# action-setup's pnpm defaults its store to <pnpm bin dir>/store, i.e.
# INSIDE setup-pnpm/node_modules/.bin — and preparing a git-hosted dep
# (sitekit) in a tmp dir nested under a foreign node_modules makes its
# tsc emit TS2742 "not portable" declaration errors. Park the store
# outside any node_modules, like a normal machine.
- run: pnpm config set store-dir ~/.pnpm-store --global
- uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: pnpm
# `--frozen-lockfile` not plain install: the lockfile is the contract, and
# a resolution that drifts from it is exactly how a dependency silently
# disappears.
- run: pnpm install --frozen-lockfile
# Next keeps its compiler output in .next/cache. Without restoring it,
# every CI run recompiles the whole app from scratch — and the deploy
# then compiles it a second time. Measured across the fleet on
# 2026-09-07: of eight repos, exactly one cached this.
#
# Keyed on the lockfile so a dependency change invalidates it. The bare
# restore-key is last on purpose: a stale cache still beats no cache,
# and Next validates its own entries rather than trusting them.
- name: Cache Next.js build
uses: actions/cache@v6
with:
path: .next/cache
key: nextjs-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nextjs-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-
nextjs-${{ runner.os }}-
- name: Verify
run: pnpm run verify
# The build is the real test for a content site: a broken import or a bad
# config surfaces here and nowhere earlier.
- name: Build
run: pnpm run build