Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
ci: shard the server suite across parallel jobs (#494)
Leo98ed01cbf7da
diff --git a/.changeset/ci-server-shards.md b/.changeset/ci-server-shards.mdnew file mode 100644index 000000000..a845151cc--- /dev/null+++ b/.changeset/ci-server-shards.md@@ -0,0 +1,2 @@+---+---diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex fd28372d5..090139c6c 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1,4 +1,6 @@-# Tenki CI validates pull requests before they reach main.+# Tenki CI validates pull requests before they reach main. Static checks,+# package tests, and four server-test shards run in parallel; the+# `Repository checks` job reports their combined result.name: CI@@ -21,11 +23,11 @@ concurrency:cancel-in-progress: truejobs:- check:- name: Repository checks+ static:+ name: Static checks and buildsif: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}runs-on: tenki-standard-medium-4c-8g- timeout-minutes: 45+ timeout-minutes: 30steps:- name: Checkoutuses: actions/checkout@v6@@ -140,14 +142,6 @@ jobs:- name: Build marketing siterun: vp run build:marketing- - name: Test shipped desktop and shared packages- run: vp run --parallel --concurrency-limit 4 --filter '!akeru-bot' --filter '!@akeru/monorepo' --filter '!@akeru/mobile' test-- - name: Test isolated server suite- run: >-- vp run --filter akeru-bot test- --exclude integration/orchestrationEngine.integration.test.ts-- name: Setup Rustuses: dtolnay/rust-toolchain@stablewith:@@ -161,3 +155,83 @@ jobs:- name: Exercise release-only configurationrun: vp run release:smoke++ packages:+ name: Package tests+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}+ runs-on: tenki-standard-medium-4c-8g+ timeout-minutes: 20+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ inputs.expected_sha || github.sha }}++ - name: Setup Vite++ uses: voidzero-dev/setup-vp@v1+ with:+ node-version-file: package.json+ cache: true+ run-install: false++ - name: Install from the committed lockfile+ run: vp install --frozen-lockfile++ - name: Ensure Electron runtime is installed+ run: vp run --filter @akeru/desktop ensure:electron++ - name: Test shipped desktop and shared packages+ run: vp run --parallel --concurrency-limit 4 --filter '!akeru-bot' --filter '!@akeru/monorepo' --filter '!@akeru/mobile' test++ # The server suite runs its files one at a time (fileParallelism: false) to+ # avoid load-sensitive flakes. Each shard keeps that, on its own runner.+ server:+ name: Server tests (${{ matrix.shard }}/4)+ if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}+ runs-on: tenki-standard-medium-4c-8g+ timeout-minutes: 20+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ inputs.expected_sha || github.sha }}++ - name: Setup Vite++ uses: voidzero-dev/setup-vp@v1+ with:+ node-version-file: package.json+ cache: true+ run-install: false++ - name: Install from the committed lockfile+ run: vp install --frozen-lockfile++ - name: Test isolated server suite+ run: >-+ vp run --filter akeru-bot test+ --exclude integration/orchestrationEngine.integration.test.ts+ --shard=${{ matrix.shard }}/4++ # The repository ruleset requires this job. It passes only when every job+ # above passed, so the required check name stays stable as jobs change.+ check:+ name: Repository checks+ needs: [static, packages, server]+ if: ${{ always() && (github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false) }}+ runs-on: tenki-standard-medium-4c-8g+ timeout-minutes: 5+ steps:+ - name: Require every job to pass+ env:+ STATIC: ${{ needs.static.result }}+ PACKAGES: ${{ needs.packages.result }}+ SERVER: ${{ needs.server.result }}+ run: |+ printf 'static=%s packages=%s server=%s\n' "$STATIC" "$PACKAGES" "$SERVER"+ test "$STATIC" = success+ test "$PACKAGES" = success+ test "$SERVER" = successdiff --git a/docs/internals/ci.md b/docs/internals/ci.mdindex 64b7aa225..d72f27755 100644--- a/docs/internals/ci.md+++ b/docs/internals/ci.md@@ -4,18 +4,23 @@[`.github/workflows/ci.yml`](../../.github/workflows/ci.yml) runs on each ready pull request revision.Draft pull requests do not use a runner. A new revision cancels the older run for that pull request.-Maintainers can also dispatch the workflow manually for diagnostics. The workflow uses one 4-vCPU-`tenki-standard-medium-4c-8g` Linux runner.+Maintainers can also dispatch the workflow manually for diagnostics. Every job uses a 4-vCPU+`tenki-standard-medium-4c-8g` Linux runner, billed per second, and the jobs run in parallel.Issue-label, PR-vouch, and PR-size jobs also use Tenki Linux runners through GitHub Actions.-- **Repository checks.** The job rejects external local dependencies, installs the committed- lockfile once, checks lint and formatting, runs workspace type checks,- validates the plugin directory and contribution policy, builds the desktop pipeline, checks the- preload output, builds the marketing site, tests shipped packages and the resource monitor, and- checks release-only configuration. Relay and mobile-production packages are excluded. The same- job runs the complete server suite. It excludes+- **Static checks and builds.** The job rejects external local dependencies, installs the+ committed lockfile, checks lint and formatting, runs workspace type checks, validates the plugin+ directory and contribution policy, builds the desktop pipeline, checks the preload output, builds+ the marketing site, tests the resource monitor, and checks release-only configuration. On a+ dispatched run it also authorizes the version-branch revision.+- **Package tests.** Tests the shipped desktop and shared packages. Relay and mobile-production+ packages are excluded.+- **Server tests (1/4 to 4/4).** Four Vitest shards split the complete server suite by file. Each+ shard still runs its files one at a time (`fileParallelism: false`), because running server+ files in parallel on one machine causes load-sensitive flakes. The suite excludes`orchestrationEngine.integration.test.ts` until the executor stackrestores its test adapter and stops the fixture from calling OpenAI with a test credential.+- **Repository checks.** Waits for the jobs above and passes only when all of them passed.The repository ruleset requires the `Repository checks` result before a pull request canmerge. Direct pushes to `main` cannot bypass this gate. Release workflows start after the validateddiff --git a/scripts/ci-workflow-policy.test.ts b/scripts/ci-workflow-policy.test.tsindex 48718920d..404a790fc 100644--- a/scripts/ci-workflow-policy.test.ts+++ b/scripts/ci-workflow-policy.test.ts@@ -11,11 +11,17 @@ type Step = {readonly run?: string;readonly uses?: string;readonly with?: Readonly<Record<string, string | boolean>>;+ readonly env?: Readonly<Record<string, string>>;};type Job = {readonly if?: string;+ readonly needs?: ReadonlyArray<string>;readonly "runs-on": string;+ readonly strategy?: {+ readonly "fail-fast"?: boolean;+ readonly matrix?: Readonly<Record<string, ReadonlyArray<number | string>>>;+ };readonly steps: ReadonlyArray<Step>;};@@ -34,7 +40,7 @@ function workflow(path: string): Workflow {}describe("CI workflow budget", () => {- it("validates ready pull requests in one 4-vCPU job", () => {+ it("validates ready pull requests in parallel 4-vCPU jobs behind one required check", () => {const ci = workflow(".github/workflows/ci.yml");const commands = Object.values(ci.jobs).flatMap((job) =>@@ -63,16 +69,42 @@ describe("CI workflow budget", () => {expect(ci.on).not.toHaveProperty("merge_group");expect(ci.concurrency?.group).toBe("ci-${{ github.event.pull_request.number || github.ref }}");expect(ci.concurrency?.["cancel-in-progress"]).toBe(true);- expect(Object.keys(ci.jobs)).toEqual(["check"]);- expect(ci.jobs.check?.if).toBe(- "${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}",- );- expect(ci.jobs.check?.["runs-on"]).toBe("tenki-standard-medium-4c-8g");- expect(ci.jobs.check?.steps.find((step) => step.name === "Checkout")?.with?.ref).toBe(- "${{ inputs.expected_sha || github.sha }}",+ expect(Object.keys(ci.jobs)).toEqual(["static", "packages", "server", "check"]);++ const readyOnly =+ "${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false }}";++ for (const name of ["static", "packages", "server"]) {+ const job = ci.jobs[name];+ expect(job?.if).toBe(readyOnly);+ expect(job?.["runs-on"]).toBe("tenki-standard-medium-4c-8g");+ expect(job?.steps.find((step) => step.name === "Checkout")?.with?.ref).toBe(+ "${{ inputs.expected_sha || github.sha }}",+ );+ }++ // The ruleset requires `Repository checks`, so that job must fail unless every job passed,+ // and still report for ready pull requests when a job it needs failed.+ const gate = ci.jobs.check;+ expect(gate?.needs).toEqual(["static", "packages", "server"]);+ expect(gate?.if).toBe(+ "${{ always() && (github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false) }}",);+ expect(gate?.["runs-on"]).toBe("tenki-standard-medium-4c-8g");- const dispatchAuthorization = ci.jobs.check?.steps.find(+ const gateCommand = gate?.steps.map((step) => step.run ?? "").join("\n") ?? "";++ for (const result of ["STATIC", "PACKAGES", "SERVER"]) {+ expect(gateCommand).toContain(`test "$${result}" = success`);+ }++ expect(gate?.steps.find((step) => step.run?.includes("= success"))?.env).toEqual({+ STATIC: "${{ needs.static.result }}",+ PACKAGES: "${{ needs.packages.result }}",+ SERVER: "${{ needs.server.result }}",+ });++ const dispatchAuthorization = ci.jobs.static?.steps.find((step) => step.name === "Authorize version-branch dispatch",);@@ -84,11 +116,11 @@ describe("CI workflow budget", () => {expect(dispatchAuthorization?.run).toContain("github-actions[bot]");expect(dispatchAuthorization?.run).toContain('test "$(git rev-parse HEAD)" = "$EXPECTED_SHA"');- const stableVersionGuard = ci.jobs.check?.steps.find(+ const stableVersionGuard = ci.jobs.static?.steps.find((step) => step.name === "Protect stable release versions",);- const changesetGuard = ci.jobs.check?.steps.find(+ const changesetGuard = ci.jobs.static?.steps.find((step) => step.name === "Require a changeset decision",);@@ -132,16 +164,21 @@ describe("CI workflow budget", () => {expect(commands.some((candidate) => candidate.includes(command))).toBe(true);}- expect(ci.jobs.check).not.toHaveProperty("strategy");+ expect(ci.jobs.static).not.toHaveProperty("strategy");++ // Each shard runs its files serially (fileParallelism: false) on its own runner.+ const server = ci.jobs.server;+ expect(server?.strategy?.["fail-fast"]).toBe(false);+ expect(server?.strategy?.matrix?.shard).toEqual([1, 2, 3, 4]);const serverCommand =- commands.find((command) => command.includes("vp run --filter akeru-bot test")) ?? "";+ server?.steps.find((step) => step.run?.includes("vp run --filter akeru-bot test"))?.run ?? "";expect(serverCommand).toContain("vp run --filter akeru-bot test");expect(serverCommand).toContain("--exclude integration/orchestrationEngine.integration.test.ts",);- expect(serverCommand).not.toContain("--shard");+ expect(serverCommand).toContain("--shard=${{ matrix.shard }}/4");});it("coalesces version updates on a 4-vCPU runner", () => {