mirror of
https://github.com/bitbaum/solon.git
synced 2026-12-04 05:37:09 +01:00
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>
211 lines
9.7 KiB
YAML
211 lines
9.7 KiB
YAML
# Golden CI floor — see bitbaum/fleet templates/ci/README.md.
|
|
# solon: pnpm + Drizzle. Floor = verify (lint + typecheck + design:check + test) + build.
|
|
# Lint is `eslint .` — Next 16 removed `next lint`, and ESLint 9 wants flat
|
|
# config, so the rules live in eslint.config.mjs (eslint-config-next already
|
|
# exports a flat array). `.eslintrc.json` is gone.
|
|
# `next build` is hermetic: the server components that touch the database catch
|
|
# errors and render demo fallbacks, so no live DB is needed. Drizzle has no
|
|
# codegen at all — types flow from src/lib/db/schema.ts at typecheck time.
|
|
# Playwright render checks run in the `integration` job, against a built app.
|
|
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
# 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
|
|
env:
|
|
DATABASE_URL: postgres://ci:ci@localhost:5432/ci
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# Node version comes from .nvmrc, never from a literal here. The deploy
|
|
# (bitbaum/loki selfhost-deploy.yml) reads the same file and only falls
|
|
# back to its own input when a repo commits none — which is how a repo
|
|
# ends up verified on one Node major and built on another. npm/pnpm
|
|
# majors disagree about optional platform deps, so that split shows up
|
|
# as a lockfile "out of sync" failure at deploy time, after the merge.
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: pnpm
|
|
|
|
# Next keeps its compiler output in .next/cache. Without restoring it this
|
|
# job recompiles the whole app every run. Measured across the fleet on
|
|
# 2026-09-07: of eight repos, exactly one cached this.
|
|
#
|
|
# Deliberately only in `verify` — the `integration` job installs but never
|
|
# builds, so a cache there would restore an entry nothing reads.
|
|
- name: Cache Next.js build
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: .next/cache
|
|
key: nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-
|
|
nextjs-${{ runner.os }}-
|
|
|
|
- name: Install
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# SSOT: lint + typecheck, defined in package.json `verify`.
|
|
- name: Verify
|
|
run: pnpm run verify
|
|
|
|
# The kinds of collective and the tax model are OrangeCat's packages,
|
|
# vendored here byte for byte until they ship on their own. A copy that
|
|
# can drift silently is the one thing SSOT forbids, so CI compares each
|
|
# with OrangeCat's main.
|
|
- name: Vendored packages are OrangeCat's (no drift in the copies)
|
|
run: pnpm run check:vendored-drift
|
|
|
|
# Did this PR change the constitution, and was that decided? governance.ts
|
|
# says of itself that changing it IS a GOVERNANCE_RULES matter; this is the
|
|
# check behind the sentence. It records — a warning in the PR with a
|
|
# pre-filled ratification proposal — and never blocks: a rules change
|
|
# without a decision is a fact the record must show, not a build failure.
|
|
# See scripts/check-governance-ratified.ts. Needs the PR's history, hence
|
|
# the second, full-depth fetch only on pull requests.
|
|
- name: Fetch PR history for the governance check
|
|
if: github.event_name == 'pull_request'
|
|
run: git fetch --no-tags --depth=200 origin ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Governance rules ratified?
|
|
if: github.event_name == 'pull_request'
|
|
env:
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
run: pnpm exec tsx scripts/check-governance-ratified.ts
|
|
|
|
# Build gate — hermetic (DB calls fall back without a live database, see header).
|
|
- name: Build
|
|
run: pnpm run build
|
|
|
|
# The vote spine against a real database: migration replay on a fresh
|
|
# postgres (proves the baseline + seed actually apply), then the
|
|
# propose → open → vote → close → policy-activation integration spec.
|
|
integration:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: ci
|
|
POSTGRES_PASSWORD: ci
|
|
POSTGRES_DB: ci
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U ci"
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
env:
|
|
DATABASE_URL: postgres://ci:ci@localhost:5432/ci
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
|
|
# .nvmrc, as in `verify` above — one declaration for both jobs.
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: pnpm
|
|
|
|
- name: Install
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Migration replay (baseline + seed on a fresh database)
|
|
run: pnpm exec drizzle-kit migrate
|
|
|
|
# The place_* registries are projections of src/lib/config/places. Sync
|
|
# them, then prove the database agrees with config (design §5.3, §12).
|
|
# Before the specs: the Places spec adds a made-up country on purpose.
|
|
- name: Places registries agree with config
|
|
run: pnpm run places:sync-config && pnpm run places:sync-config --check
|
|
|
|
# Every *.integration.test.ts, matched by name — not a hand-kept list.
|
|
# This step used to name the vote-spine spec alone, so the membership
|
|
# spec that guards the founding seat existed and was never once run by
|
|
# CI. A list of files is how the next spec is born dead.
|
|
- name: Database integration specs
|
|
run: INTEGRATION=1 pnpm exec vitest run .integration.test.ts
|
|
|
|
# How the site actually renders — the one thing lint, typecheck and unit
|
|
# tests cannot see. A button class with no CSS behind it shipped to
|
|
# production for weeks; tests/e2e/render.spec.ts names each bug it
|
|
# guards. Runs here because this job already has a migrated database,
|
|
# so data pages render for real rather than as fallbacks.
|
|
- name: Build for the render checks
|
|
run: pnpm run build
|
|
env:
|
|
AUTH_SECRET: ci-render-check-secret-not-a-real-one
|
|
AUTH_URL: http://localhost:3000
|
|
|
|
# --with-deps runs apt-get; when the runner cannot reach Ubuntu's archive (2026-11-11:
|
|
# security.ubuntu.com unreachable, every integration job failed here before a test ran),
|
|
# install the browser alone: the runner image already carries Chrome's system libraries,
|
|
# and a missing one fails the render checks below, visibly, not silently.
|
|
- name: Install Chromium
|
|
run: |
|
|
pnpm exec playwright install --with-deps chromium \
|
|
|| { echo "::warning::apt failed; installing Chromium without system deps"; pnpm exec playwright install chromium; }
|
|
|
|
- name: Render checks (Playwright, Chromium)
|
|
env:
|
|
AUTH_SECRET: ci-render-check-secret-not-a-real-one
|
|
AUTH_URL: http://localhost:3000
|
|
BASE_URL: http://localhost:3000
|
|
run: |
|
|
pnpm exec next start -p 3000 > server.log 2>&1 &
|
|
for i in $(seq 1 60); do curl -fsS -o /dev/null http://localhost:3000/api/health && break; sleep 1; done
|
|
pnpm exec playwright test tests/e2e --project=chromium --reporter=line
|
|
|
|
# The server production runs is not `next start`: it is the standalone
|
|
# server.js, behind Caddy, which adds X-Forwarded-Proto: https. On
|
|
# 2026-09-25 that combination 500'd every English page — next-intl's
|
|
# rewrite looked external to Next under HOSTNAME=127.0.0.1 — while every
|
|
# check above stayed green, because none of them sent the header. This
|
|
# runs the app the way the box does (HOSTNAME mirrors Solon's BIND_HOST
|
|
# in /opt/solon/shared/.env) and requires 200 on pages that rewrite.
|
|
- name: Production-shaped smoke (standalone behind a TLS proxy)
|
|
env:
|
|
AUTH_SECRET: ci-render-check-secret-not-a-real-one
|
|
AUTH_URL: https://solon.orangecat.ch
|
|
run: |
|
|
cp -r .next/static .next/standalone/.next/static
|
|
cp -r public .next/standalone/public
|
|
HOSTNAME=0.0.0.0 PORT=3100 node .next/standalone/server.js > standalone.log 2>&1 &
|
|
for i in $(seq 1 60); do curl -fsS -o /dev/null http://127.0.0.1:3100/api/health && break; sleep 1; done
|
|
for p in / /hire /governance /for/network-states /de /de/hire; do
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' -H 'Host: solon.orangecat.ch' -H 'X-Forwarded-Proto: https' "http://127.0.0.1:3100$p")
|
|
echo "$p -> $code"
|
|
if [ "$code" != "200" ]; then tail -30 standalone.log; exit 1; fi
|
|
done
|