mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-20 12:08:01 +08:00
* ci: shard integration and unit tests, run e2e groups in parallel, add a ci gate
The PR critical path was the PostgreSQL integration suite (~15 min), run in full on an
8 vCPU runner once per provisioning path. Its files run one at a time, so the runner sat
mostly idle.
- integration: each provisioning path (push, migrate) is split into 4 Vitest shards on
4 vCPU runners. Both paths keep the full suite: migrations add triggers, checks and
NOT VALID constraints that db:push does not, so the schemas differ.
- e2e: the four next-dev groups (scim, cli, stop-after, desktop-inbox) run as a matrix,
each on its own database. The boot/wait/stop shell lives once in http-e2e.sh.
- lint: lint, audits, type-check and schema sync split off from the tests.
- test: apps/sim unit tests sharded 2 ways; shard 1 also runs root scripts and the other
workspaces. Each shard has its own Turbo cache disk.
- ci: one aggregate job that fails unless every check passed (skipped is allowed), so a
ruleset can require a single stable check.
Deploy gating is unchanged: migrate still requires the whole Test and Build workflow.
* ci: short names, one setup action, aligned pins, explicit secrets
Naming
- Workflow files: test-build -> checks, migrations -> migrate, deploy-trigger-dev ->
trigger-dev, docs-embeddings -> docs, companion-pr-check -> companion, stickydisk-gc
-> disk-gc. ci.yml, helm.yml and codeql.yml keep their paths: they sign or analyze, and
the path is part of the signer identity and code-scanning key.
- Composite actions: setup-workspace -> setup, cache-mount -> cache, docker-build -> image.
- Every workflow and job display name is a short lowercase id, matching the job id, with
any matrix value in parentheses: ci / checks / integration (push, 1/4), image-amd64 (app).
Duplicates
- Nine hand-written Setup Bun + actions/cache + bun install blocks use the setup action.
It gains node-version (empty keeps the runner's Node, as those jobs had) and registry-url
(npm publishing). This also ends restoring node_modules from another lockfile through the
`${runner.os}-bun-` prefix restore key.
- The runner expression is anchored once per file and aliased after.
Consistency
- One SHA per action: checkout v6 (helm was on v4, codeql on v5), setup-node v6 (desktop
on v4), cache v5 (desktop-release on v4), softprops/action-gh-release v3.0.3 (was v1,
Node 16). Redis 8.2 everywhere.
- secrets: inherit replaced by the secrets each callee reads; the checks workflow reads none.
The dev migration gets only DEV_DATABASE_URL, and staging/production never see it.
- Timeouts on the three macOS desktop-e2e jobs (none before, so a hang billed 6 hours),
and a cache for their Electron, electron-builder and Playwright downloads.
- Publish workflows: values moved from ${{ }} in run blocks to env, concurrency on the
npm/PyPI publishers, persist-credentials: false on checkouts that never push.
- Dependabot for github-actions (one grouped weekly PR), and actionlint in the lint job.
Fixes
- PyPI version check matched substrings (0.1.1 "existed" once 0.1.10 did) and treated a
PyPI outage as "not published". It now asks PyPI for the exact version and fails on
anything but 200 or 404.
Job wiring (runner, if, needs, permissions, timeout, outputs) is unchanged: verified by
loading the old and new ci.yml, checks.yml and helm.yml and comparing every job.
* ci: run the ci gate on cancelled runs so a cancelled head never passes
* docs(desktop): point the release notes at the renamed workflow and jobs
83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
import { spawnSync } from 'node:child_process'
|
|
import { readFileSync } from 'node:fs'
|
|
import { runInNewContext } from 'node:vm'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const ci = readFileSync(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8')
|
|
const tasks = readFileSync(new URL('../.github/workflows/trigger-dev.yml', import.meta.url), 'utf8')
|
|
|
|
/** Evaluate the checked-in job condition for concrete GitHub job outcomes. */
|
|
function eligible(job: string, branch: string, results: Record<string, string> = {}) {
|
|
const body = ci.split(`\n ${job}:\n`)[1]?.split(/^ {2}[\w-]+:/m)[0]
|
|
const expression = body?.match(/ {4}if: >-\n((?: {6}.*\n)+)/)?.[1]
|
|
if (!expression) throw new Error(`Missing job condition: ${job}`)
|
|
const needs = Object.fromEntries(
|
|
Object.entries({
|
|
migrate: 'success',
|
|
'image-amd64': 'success',
|
|
'migrate-dev': 'success',
|
|
'image-dev': 'success',
|
|
'trigger-upload': 'success',
|
|
promote: 'success',
|
|
...results,
|
|
}).map(([name, result]) => [name, { result, outputs: { promoted: 'true' } }])
|
|
)
|
|
return runInNewContext(expression.replace(/needs\.([\w-]+)/g, 'needs["$1"]'), {
|
|
github: { event_name: 'push', ref: `refs/heads/${branch}` },
|
|
needs,
|
|
cancelled: () => false,
|
|
})
|
|
}
|
|
|
|
const promotion = tasks.split(' - name: Promote current dev preview')[1]
|
|
const shell = promotion?.match(/ {8}run: \|\n((?: {10}.*\n)+)/)?.[1]
|
|
if (!shell) throw new Error('Missing dev task promotion step')
|
|
const script = shell.replace(/^ {10}/gm, '')
|
|
|
|
/** Run the real promotion shell with fake GitHub and Trigger commands. */
|
|
function promote(env: Record<string, string> = {}) {
|
|
return spawnSync(
|
|
'bash',
|
|
[
|
|
'-e',
|
|
'-c',
|
|
`gh() { printf '%s\\n' "$HEAD_SHA"; return "$GH_EXIT"; }
|
|
bunx() { printf 'PROMOTE %s\\n' "$*"; return "$TRIGGER_EXIT"; }
|
|
${script}`,
|
|
],
|
|
{
|
|
encoding: 'utf8',
|
|
env: {
|
|
PATH: process.env.PATH,
|
|
GITHUB_REPOSITORY: 'example/sim',
|
|
GITHUB_SHA: 'current',
|
|
HEAD_SHA: 'current',
|
|
VERSION: '20260922.1',
|
|
GH_EXIT: '0',
|
|
TRIGGER_EXIT: '0',
|
|
...env,
|
|
},
|
|
}
|
|
)
|
|
}
|
|
|
|
describe('dev deployment independence', () => {
|
|
it('promotes dev images with the skipped Trigger jobs and no cutover waiter', () => {
|
|
expect(eligible('trigger-upload', 'dev')).toBe(false)
|
|
expect(eligible('trigger-promote', 'dev')).toBe(false)
|
|
expect(eligible('promote', 'dev', { 'trigger-upload': 'skipped' })).toBe(true)
|
|
})
|
|
|
|
it('does not roll tasks back when an older push is retried', () => {
|
|
const result = promote({ HEAD_SHA: 'newer' })
|
|
expect(result.status).toBe(0)
|
|
expect(result.stdout).not.toContain('PROMOTE ')
|
|
})
|
|
|
|
it('fails closed if the current branch cannot be read', () => {
|
|
const result = promote({ GH_EXIT: '42' })
|
|
expect(result.status).toBe(42)
|
|
expect(result.stdout).not.toContain('PROMOTE ')
|
|
})
|
|
})
|