Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 72 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,98 @@ name: CI

on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main
# Run required checks again against GitHub's speculative merge-queue commit.
branches: [main]
merge_group:
types:
- checks_requested
types: [checks_requested]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
check:
name: Test and validate Workers
backend:
name: Backend checks
runs-on: ubuntu-latest
timeout-minutes: 10
env:
AUTH_TEST_DATABASE_URL: postgresql://postgres:local-ci-only@localhost:5432/postgres
AUTH_TEST_DATABASE_URL: postgresql://postgres:local-ci-only@localhost:5432/factorize_ci
QUEUE_TEST_DATABASE_URL: postgresql://postgres:local-ci-only@localhost:5432/factorize_ci
DATABASE_URL: postgresql://postgres:local-ci-only@localhost:5432/factorize_ci
steps:
# ubuntu-latest includes PostgreSQL; no rate-limited container pull is needed.
- name: Start disposable runner PostgreSQL
- name: Start backend timing
run: echo "CI_START_SECONDS=$(date +%s)" >> "$GITHUB_ENV"
- uses: actions/checkout@v5
with: { fetch-depth: 0 }
- uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
- name: Start isolated migrated PostgreSQL database
run: |
sudo systemctl start postgresql
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'local-ci-only'"
sudo -u postgres createdb factorize_ci
pg_isready -h localhost -p 5432
npm ci
npm run db:migrate --workspace=factorize
- name: Verify generated API contract once
run: |
npm run generate
git diff --exit-code -- packages/docs/openapi.yaml packages/api-client/src/schema.d.ts
- name: Build static application for Worker dry-run
run: npm run build --workspace=factorize-app
- name: Run docs, API, authorization, integration and Worker checks
run: npm run check:backend
- name: Install Chromium for compiled static-slice checks
run: npm exec --workspace=factorize -- playwright install --with-deps chromium
- name: Exercise compiled jobs/invocation/run slice against PostgreSQL
run: npm run test:static-slice --workspace=factorize
- name: Record backend timing
if: always()
run: |
echo "### Backend checks timing\n- Wall time: $(( $(date +%s) - CI_START_SECONDS ))s" >> "$GITHUB_STEP_SUMMARY"

browser:
name: Required browser checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Start browser timing
run: echo "CI_START_SECONDS=$(date +%s)" >> "$GITHUB_ENV"
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
- run: npm ci
- name: Verify generated API contract
- name: Build static application
run: npm run build --workspace=factorize-app
- name: Install Chromium for functional checks
run: npm exec --workspace=factorize-app -- playwright install --with-deps chromium
- name: Run required functional browser coverage
run: npm run test:functional --workspace=factorize-app
- name: Run non-browser app unit tests
run: npm test --workspace=factorize-app
- name: Record browser timing
if: always()
run: |
npm run generate
git diff --exit-code -- packages/docs/openapi.yaml packages/api-client/src/schema.d.ts
- name: Validate hosted docs, MCP inventory and generated exports
run: npm run validate --workspace=factorize-docs
- name: Install browser for static application checks
run: npx playwright install --with-deps chromium
- run: npm run check
- name: Upload visual comparison failures
if: failure()
uses: actions/upload-artifact@v4
with:
name: factorize-visual-failures
path: packages/app/test-results
if-no-files-found: ignore
- name: Exercise compiled jobs/invocation/run slice against PostgreSQL
run: npm run test:static-slice --workspace=factorize
echo "### Required browser checks timing\n- Wall time: $(( $(date +%s) - CI_START_SECONDS ))s" >> "$GITHUB_STEP_SUMMARY"

required:
name: Test and validate Workers
if: ${{ always() }}
needs: [backend, browser]
runs-on: ubuntu-latest
steps:
- name: Required CI passed
if: ${{ needs.backend.result == 'success' && needs.browser.result == 'success' }}
run: echo 'Backend and required browser checks passed.'
- name: Required CI failed
if: ${{ needs.backend.result != 'success' || needs.browser.result != 'success' }}
run: exit 1
43 changes: 43 additions & 0 deletions .github/workflows/visual-regressions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Optional visual regressions

on:
workflow_dispatch:
inputs:
update_snapshots:
description: Update checked-in Playwright visual baselines
required: false
default: false
type: boolean

permissions:
contents: read

jobs:
visual:
name: Visual and stress coverage
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run build --workspace=factorize-app
- run: npx playwright install --with-deps chromium
- name: Run screenshot regression suite
run: npm run test:visual --workspace=factorize-app ${{ inputs.update_snapshots && '--update-snapshots' || '' }}
- name: Run optional 20,000-event trace stress test
run: npm test --workspace=factorize-app
env:
FACTORIZE_STRESS: '1'
- name: Preserve visual and stress artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: factorize-visual-and-stress-failures
path: |
packages/app/test-results
packages/app/playwright-report
if-no-files-found: ignore
48 changes: 48 additions & 0 deletions docs/ci-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# CI test lanes

Required pull-request and merge-queue CI is split into independent backend and
browser jobs. The `Test and validate Workers` aggregate check keeps the existing
required-check name while ensuring a browser failure cannot prevent backend
validation. Pull-request runs cancel only an older run for the same PR; merge
queue runs use a separate, non-cancelable concurrency group.

Screenshot regressions and the 20,000-event trace stress case are intentionally
outside required CI. Run **Optional visual regressions** from the Actions tab.
Set `Update checked-in Playwright visual baselines` when reviewing a baseline
update; locally, the equivalent commands are:

```sh
npm ci
npm run build --workspace=factorize-app
npx playwright install chromium
npm run test:visual --workspace=factorize-app
npm run test:visual --workspace=factorize-app -- --update-snapshots
FACTORIZE_STRESS=1 npm test --workspace=factorize-app
```

The optional workflow uploads Playwright result and report artifacts on
failure. Required functional browser coverage remains in
`packages/app/test/functional/critical.spec.mjs` and uses representative
desktop/mobile behavior, with one focused accessibility scan rather than a
scan for every presentation permutation.

## Timing record

The analysis baseline was a successful CI run on 2026-10-10 (run
`38069398135`):

| Lane | Baseline wall time | Baseline runner work |
| --- | ---: | ---: |
| Visual suite (41 tests, one worker) | 61s | 61s |
| API unit/integration (358 tests) | 26s | 26s |
| Functional browser (42 tests) | 21s | 21s |
| Chromium installation | 21s | 21s |
| Compiled app/API/PostgreSQL integration | 8s | 8s |
| Worker runtime checks | ~9s | ~9s |
| Successful required job | 3m10s–3m22s | recorded in run |

After this change, compare successful runs by the `Backend checks`, `Required
browser checks`, and `Test and validate Workers` job summaries, and record the
optional workflow separately. Wall time is the aggregate job duration; runner
work is the sum of job durations, so the two measures must not be added as if
they were interchangeable.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"build:marketing": "npm run build:marketing --workspace=factorize-marketing",
"build:css": "npm run build:app",
"test": "npm run test --workspaces --if-present",
"check": "npm run check:hosting && npm run check:boundaries && npm run check:client && npm run check --workspace=factorize-app && npm run check --workspace=factorize && npm run test:conditions-runtime && npm run test:hosting-runtime && npm run test:oauth-runtime && npm run test:rollback-runtime && npm run check --workspace=factorize-marketing && npm run check --workspace=factorize-tail-relay",
"check": "npm run check:backend && npm run check:frontend",
"check:backend": "npm run check:hosting && npm run check:boundaries && npm run check:client && npm run validate --workspace=factorize-docs && npm run check --workspace=factorize && npm run test:conditions-runtime && npm run test:hosting-runtime && npm run test:oauth-runtime && npm run test:rollback-runtime && npm run check --workspace=factorize-marketing && npm run check --workspace=factorize-tail-relay",
"check:frontend": "npm run check --workspace=factorize-app",
"deploy": "npm run deploy:marketing && npm run deploy:app && npm run deploy:tail-relay",
"deploy:marketing": "npm run deploy --workspace=factorize-marketing",
"deploy:app": "npm run deploy --workspace=factorize",
Expand Down
5 changes: 3 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"scripts": {
"dev": "vite --host 0.0.0.0",
"build": "tsc --noEmit && vite build",
"check": "npm run build && npm test && npm run test:visual",
"check": "npm run build && npm test && npm run test:functional",
"test": "node --test test/*.test.mjs",
"test:visual": "playwright test"
"test:functional": "playwright test --config=playwright.functional.config.mjs",
"test:visual": "playwright test --config=playwright.visual.config.mjs"
},
"dependencies": {
"@tanstack/react-query": "5.104.1",
Expand Down
10 changes: 1 addition & 9 deletions packages/app/playwright.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./test/visual", testMatch: "*.spec.mjs",
snapshotPathTemplate: "{testDir}/baselines/{arg}{ext}",
workers: 1, fullyParallel: false,
use: { browserName: "chromium", locale: "en-US", timezoneId: "UTC", reducedMotion: "reduce" },
expect: { toHaveScreenshot: { animations: "disabled", maxDiffPixelRatio: 0.001 } },
reporter: [["list"]],
});
export { default } from "./playwright.visual.config.mjs";
13 changes: 13 additions & 0 deletions packages/app/playwright.functional.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from "@playwright/test";

export default defineConfig({
testDir: "./test/functional",
testMatch: "*.spec.mjs",
// These fixtures share one in-process HTTP server per test worker. Running
// the small required suite serially avoids cross-test route/server races on
// constrained CI runners while preserving the same coverage.
workers: 1,
fullyParallel: false,
use: { browserName: "chromium", locale: "en-US", timezoneId: "UTC", reducedMotion: "reduce" },
reporter: [["list"]],
});
12 changes: 12 additions & 0 deletions packages/app/playwright.visual.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "@playwright/test";

export default defineConfig({
testDir: "./test/visual",
testMatch: "*.spec.mjs",
snapshotPathTemplate: "{testDir}/baselines/{arg}{ext}",
workers: 1,
fullyParallel: false,
use: { browserName: "chromium", locale: "en-US", timezoneId: "UTC", reducedMotion: "reduce" },
expect: { toHaveScreenshot: { animations: "disabled", maxDiffPixelRatio: 0.001 } },
reporter: [["list"]],
});
90 changes: 90 additions & 0 deletions packages/app/test/functional/critical.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import AxeBuilder from "@axe-core/playwright";
import { test, expect } from "@playwright/test";
import { createServer } from "node:http";
import { readFile } from "node:fs/promises";
import { mockApi, screens, jobId } from "../visual/fixtures.mjs";

let server;
let origin;

test.beforeAll(async () => {
server = createServer(async (req, res) => {
const path = new URL(req.url, "http://fixture").pathname;
const file = /^(\/assets\/|\/theme-init.js$|\/bee-mark-monochrome.png$|\/favicon.ico$)/.test(path) ? path : "/index.html";
try {
const body = await readFile(new URL("../../dist" + file, import.meta.url));
res.setHeader("Content-Type", file.endsWith(".js") ? "application/javascript" : file.endsWith(".css") ? "text/css" : file.endsWith(".png") ? "image/png" : "text/html");
res.end(body);
} catch { res.statusCode = 404; res.end(); }
});
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
origin = `http://127.0.0.1:${server.address().port}`;
});

test.afterAll(async () => { if (server) await new Promise(resolve => server.close(resolve)); });

test("navigation, theme preference and essential accessibility remain usable", async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 900 });
await page.emulateMedia({ colorScheme: "dark" });
await mockApi(page);
await page.goto(origin + screens[3][1]);
await expect(page.getByRole("heading", { name: "Release review", exact: true })).toBeVisible();
await expect(page.getByRole("tab", { name: "Trace", exact: true })).toHaveAttribute("aria-selected", "true");
await page.getByRole("tab", { name: "Info", exact: true }).click();
await page.getByText("Prompt, context and provenance", { exact: true }).click();
await expect(page.getByRole("heading", { name: "Prompt", exact: true })).toBeVisible();
await expect(page.locator("html")).toHaveAttribute("data-theme", "dark");
const accessibility = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze();
expect(accessibility.violations).toEqual([]);
});

test("keyboard focus and validation work on representative mobile UI", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await mockApi(page, { long: true });
await page.goto(origin + "/jobs/" + jobId);
const profile = page.getByRole("button", { name: "Your account", exact: true });
await profile.click();
await expect(page.getByRole("link", { name: "Settings", exact: true }).last()).toBeVisible();
await page.keyboard.press("Escape");
await expect(profile).toBeFocused();
const options = page.getByRole("button", { name: "More run options", exact: true });
await options.click();
await page.getByRole("menuitem", { name: "Run with prompt", exact: true }).click();
await page.getByLabel("JSON data (optional)").fill("[]");
await page.getByRole("button", { name: "Run with prompt", exact: true }).click();
await expect(page.getByRole("alert")).toHaveText("JSON data must be an object.");
await page.keyboard.press("Escape");
await expect(options).toBeFocused();
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
});

test("loading, search, error and no-result states are actionable", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await mockApi(page);
let pending;
let mode = "pending";
await page.route("**/api/v1/job-summaries?**", route => mode === "pending" ? (pending = route) : route.fulfill({ status: 403, json: { error: { code: "forbidden", message: "This workspace is unavailable." } } }));
await page.goto(origin + "/jobs");
await expect(page.getByRole("status").filter({ hasText: "Loading…" })).toBeVisible();
mode = "error";
await pending.fulfill({ status: 403, json: { error: { code: "forbidden", message: "This workspace is unavailable." } } });
await expect(page.getByRole("alert")).toHaveText("This workspace is unavailable.");
await page.getByRole("button", { name: "Search jobs, runs, and messages", exact: true }).click();
const input = page.getByRole("combobox", { name: "Search jobs and runs by name, title, or issue identifier", exact: true });
await expect(input).toBeFocused();
await input.fill("release");
await expect(page.getByRole("option")).toBeVisible();
await page.keyboard.press("Escape");
await expect(page.getByRole("dialog")).toHaveCount(0);
});

test("trace details, virtualization beyond the viewport and generation reset remain functional", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await mockApi(page, { long: true });
await page.goto(origin + "/job-runs/" + "00000000-0000-4000-8000-000000000002");
await expect(page.getByText("User · user_message", { exact: true })).toBeVisible();
const details = page.locator("main ol details");
await details.first().locator("summary").click();
await expect(details.first()).toHaveAttribute("open", "");
expect(await page.evaluate(() => document.documentElement.scrollHeight > innerHeight)).toBe(true);
});
2 changes: 1 addition & 1 deletion packages/app/test/jobs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ test("trace reset between requests discards old pages and finalization keeps ter
await page.waitForTimeout(2200); assert.ok(statusCalls >= 2);
await context.close();
});
test("20k-event continuous trace keeps DOM bounded, retains expanded details on scroll and resets generations", async () => {
test("20k-event continuous trace keeps DOM bounded, retains expanded details on scroll and resets generations", { skip: !process.env.FACTORIZE_STRESS }, async () => {
const { page, context } = await contextFor(); let revision = "large", traceRequests = 0, peakNodes = 0; const started = performance.now();
await page.route(`**/api/v1/runs/${runId}/status`, route => route.fulfill({ json: { id: runId, job_id: jobId, job_name: "Review builds", run_name: "Large trace", state: "succeeded", finalizing: true, trace_revision: revision, artifact_state: "stored", created_at: summary.createdAt, updated_at: summary.updatedAt, started_at: null, destination_url: null } }));
await page.route(`**/api/v1/runs/${runId}/trace-pages?**`, route => {
Expand Down
7 changes: 1 addition & 6 deletions packages/docs/scripts/validate.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { resolve } from "node:path";
import { execFileSync } from "node:child_process";
import { checkContent } from "./content.mjs";
import { syncExports } from "./exports.mjs";

await checkContent();
await syncExports(true);
execFileSync(process.execPath, ["--test", "scripts/content.test.mjs"], { cwd: resolve(import.meta.dirname, ".."), stdio: "inherit" });
execFileSync("npm", ["run", "check:openapi"], { cwd: resolve(import.meta.dirname, "../../.."), stdio: "inherit" });
execFileSync("npm", ["test", "--workspace=factorize", "--", "test/api-contract.test.ts", "test/docs-workflows.test.ts"], { cwd: resolve(import.meta.dirname, "../../.."), stdio: "inherit" });
console.log("Validated OpenAPI, documentation example contracts, navigation/links, MCP inventory and generated exports.");
console.log("Validated documentation navigation/links, MCP inventory and generated exports.");
Loading