Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Speed up CI with parallel test jobs and reusable unit caches (#3683)

Amruth Pillai24ec27e187c6
diff --git a/.agents/docs/ci-performance.md b/.agents/docs/ci-performance.md
new file mode 100644
index 000000000..3f93d0312
--- /dev/null
+++ b/.agents/docs/ci-performance.md
@@ -0,0 +1,121 @@
+# CI performance audit — 2026-10-27
+
+Scope: all six checked-in workflows plus GitHub-managed CodeQL. Baseline checkout:
+`79f51c1c21d819a9f49a1f35dd74a93ff80fdfa6`. This is a focused cost/ownership audit, not a whole-repository test purge.
+
+## Changes in this PR
+
+- Run unit and browser suites in independent matrix jobs, each with its own PostgreSQL service and Turbo cache namespace.
+- On 32-vCPU Blacksmith runners, run four package test processes (two Vitest workers each) and four Playwright workers.
+ GitHub-hosted runners and local unit scripts retain their serial limits; Vitest isolation and package-local module caches stay enabled.
+- Use fixed public credentials exclusively for disposable CI services. Turbo still hashes runtime secrets; previously,
+ freshly generated credentials invalidated every cacheable unit task on every run. API, database, server, and tooling
+ integration tasks retain their explicit cache opt-outs. Browser tests always execute against a migrated database.
+- Preserve all 21 browser tests. Consolidate repeated deployment-probe rejection loops while retaining every guard.
+
+## Measurements
+
+Hosted baseline: [E2E run 40416118497](https://github.com/reactive-resume/reactive-resume/actions/runs/40416118497),
+commit `f77121efee0dfa65eb9b70229342bae7356dc3d8`, immediately before the baseline checkout's documentation-only change.
+The combined job used a 32-vCPU Blacksmith runner: unit tests 130s, build 28s, browser tests 68s; 20 unit tasks and
+21 browser tests passed. Unit tasks had 0/20 cache hits even though the outer Actions cache restored successfully.
+Vercel artifact build took 97s; Cloudflare build/check 40s plus smoke 15s. Step durations exclude queue time.
+
+Local benchmark: macOS arm64, 10 logical CPUs, 32 GiB RAM, Node 24.22.1, pnpm 12.15.0, PostgreSQL 16 in Docker.
+Two dedicated databases, isolated local storage, and one unchanged environment were reused between commands.
+No other benchmark ran concurrently. Forced unit measurements bypass Turbo task results with `--force`; dependency
+and filesystem caches were not cleared between runs. Browser runs use the same production build, zero retries,
+and no skipped tests. These are local measurements, not promises of hosted-runner elapsed time.
+
+| Measurement | Before | After | Result |
+| ---------------------------------------------------- | ------: | ---------: | -------------------------------------------------------------------- |
+| Full unit task execution (`--force`, 1 → 4 packages) | 149.27s | 57.51s | 61.5% faster; all 20 tasks passed, 2,393 → 2,391 tests, zero skipped |
+| Warm unit run (4 packages, unchanged inputs) | — | 24.08s | 16/20 task cache hits; all four uncached integration tasks still ran |
+| Browser execution (1 → 4 workers) | 61.28s | 21.42s | 65.0% faster; all 21 tests passed on both runs |
+| Production build for both browser runs | 28.33s | Same build | Build succeeded; no application runtime change |
+
+A same-code serial control after consolidation also passed all 2,391 tests in **139.31s**; four-package execution
+was **58.7% faster** even against that warmed control. The first baseline includes the two consolidated cases.
+
+Reproduce with the disposable-service environment from `tests/e2e/README.md`, also setting
+`COVER_LETTER_TEST_DATABASE_URL`, `INTEGRATIONS_TEST_DATABASE_URL`, and a separately migrated `OAUTH_TEST_DATABASE_URL`:
+
+```sh
+pnpm exec turbo run test:ci --concurrency=1 --force
+pnpm exec turbo run test:ci --concurrency=4 --force
+pnpm exec turbo run test:ci --concurrency=4
+pnpm build
+CI=true pnpm exec playwright test --workers=1
+CI=true pnpm exec playwright test --workers=4
+```
+
+The matrix also overlaps unit work with browser build/testing. That structural benefit is not added to the local
+numbers as though it were a measured end-to-end hosted result. A second runner adds service/setup overhead and
+can increase runner minutes; compare Actions duration and billed usage after merging. New check names are
+`Unit tests` and `Browser tests`; external branch protection that requires the old combined name must be updated.
+The repository currently exposes no required-status-check protection; exact-commit promotion checks the whole
+E2E workflow conclusion, so both matrix legs remain required for promotion.
+
+## Test audit and preservation
+
+`tooling/mobile-updates.test.ts` executes the real production OTA shell guard from `docker-build.yml` with local
+HTTP-command fixtures. Previously, unhealthy status and unrelated service each repeated the same failing loop
+60 times. One rolling sequence now inserts each invalid response after two healthy matches, then requires three
+fresh matches. It asserts success at exactly 12 probes. Immediate success at 3 and permanent mismatch failure at
+60 remain. Total fixture probes: 190 → 75, removing 115 redundant shell/curl/jq invocations, with two fewer table
+cases. No production runtime code or test-only production seam changed. Test LOC increases because the combined
+sequence explicitly spells out the independent reset controls; deletion count was not the objective.
+
+Mutation proof: removing revision, status or service validation makes the rolling keeper fail with 3, 6 or 9
+probes instead of 12. Removing the reset makes it fail at 4. All four mutations failed at the intended exact-count
+assertion, and the production workflow was restored byte for byte. Full owner/sibling suites passed before and
+after consolidation. Full-suite test declarations decrease by two; runtime production LOC change is zero,
+test LOC is +16 (19 added, 3 removed), and no support files/exports are orphaned.
+
+All browser cases retain distinct transport/persistence/security/lifecycle proof: auth and guest ownership;
+failed-save navigation for separate resume/letter stores; import/export; sharing/password/redirect/statistics;
+OAuth consent and PKCE; private AI report deletion; assistant proposals/cancellation; career evidence and
+job-document snapshots; browser font loading and PDF ActualText; optional web-provider persistence. Per-test
+accounts, browser contexts and scoped cleanup, ephemeral stub ports, and intercepted OAuth callbacks permit parallelism.
+
+Inspected tooling release, cache, lint, generated-language/documentation and recovery tests also remain: they
+protect independent executable/configuration/public contracts. Preview cancellation/pixel-budget, cached auth
+fallback, and WebMCP adapter tests remain. Static or small tests were not deleted merely for looking menial.
+Independent preservation review found no lost contract or new cache/database isolation issue.
+
+## Workflow-wide recommendations
+
+| Workflow | Current evidence / caching | Next improvement |
+| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `e2e.yml` | Serial 130s unit + 28s build + 68s browser baseline; pnpm and Turbo caches already restored. | This PR fixes secret-induced cache misses and adds bounded parallelism. Profile new hosted runs before adding shards. Cloudflare currently calls web build directly without Turbo; a follow-up can route that build through Turbo with declared build inputs and its own cache namespace. Keep real runtime smoke and Vercel artifact proof. |
+| `autofix.yml` | Recent successful job: dependency install 1s, setup/cache restore 19s, Knip 3s, lint/format 7s. | Keep mutating Knip/lint/format uncached: a cached success would not reproduce edits. If setup remains dominant, benchmark a Blacksmith sticky disk for the pnpm store rather than adding more task caching. |
+| `docker-build.yml` | Native AMD64/ARM64 builds already parallel; Blacksmith persists BuildKit layers and pnpm mounts per architecture. Sample build steps 76s/144s, anonymous pulls 48s, Docker Hub mirror 273s, OTA publish 353s. | Largest follow-ups: move best-effort Docker Hub mirroring off the deployment/OTA critical path while preserving digest/signature evidence; profile OTA bundling on a larger runner or use an unsigned Metro transform cache keyed by toolchain/lockfile. GitHub fallback currently has no cross-run Docker layer cache: benchmark `type=gha` per architecture there only, without stacking it onto the Blacksmith builder. Preserve every SHA image, exact-commit CI, signing, and backend-revision gates. |
+| `mobile-release.yml` | Platforms already matrixed; pnpm and Ruby/Bundler dependencies cached. Latest Android build step 411s; store submission 72s, excluding approval waits. No explicit Gradle or CocoaPods download cache. | Benchmark dependency-only Gradle/CocoaPods caches or Blacksmith sticky disks keyed by OS/toolchain/lockfiles. Avoid signing files, generated signed output, keychains, and broad workspace caches. Keep approval boundaries and exact-commit CI; build-number/fingerprint evidence cannot be reused from another release. |
+| `mobile-forme-native.yml` | Manual macOS job installs pinned Rust toolchain, cbindgen/cargo-ndk, then builds five targets serially with four jobs each; no explicit Cargo cache. No recent hosted run available for timing. | Cache Cargo registry/git downloads and pinned installed tools first; then benchmark target build caching keyed by Rust/NDK/Xcode/Cargo.lock. Preserve clean header/notices comparison, artifact checksum verification and immutable publishing. Do not introduce five simultaneous four-thread compiles without a memory benchmark. |
+| `issue-maintenance.yml` | Already lightweight 2-vCPU jobs; no dependency installation. Stale job needs no checkout. | No build/test cache needed. Label job could use sparse checkout of its single imported script, but expected saving is small; retain form-derived labels and stale policy. |
+| GitHub-managed `CodeQL` | Default setup scans `actions`, on standard runners; recent runs about 50s including scheduling. Not a checked-in workflow. | Keep independent security analysis. No Turbo task output or dependency cache applies to its current Actions-only analysis. |
+
+Blacksmith documentation confirms `actions/cache` and `actions/setup-node` dependency caching are accelerated
+transparently on its runners; replacing working actions with extra wrappers is unnecessary. Existing observed
+pnpm archive is approximately 684 MB, while Turbo archives are about 40–79 MB. Sticky disks are an experiment
+for transfer/extraction cost, not a substitute for correct Turbo hashes. A remote Turbo service would require
+credential/trust design for fork PRs; current cache transport already works and needs no new credentials.
+Keep Vercel, browser, unit, and any future Cloudflare artifact namespaces separate until build-environment inputs
+are deliberately audited. Browser binaries are not cached here: Playwright installation was 12s including OS
+dependencies, and another archive restore may not improve that.
+
+Sources: [Blacksmith dependency caching](https://docs.blacksmith.sh/blacksmith-caching/dependencies-actions),
+[sticky disks](https://docs.blacksmith.sh/blacksmith-caching/dependencies-sticky-disks),
+[Docker caching](https://docs.blacksmith.sh/blacksmith-caching/docker-builds), installed Turbo 2.11.10 docs,
+and Playwright's current parallelism/isolation documentation. Timing samples:
+[Docker 40416118446](https://github.com/reactive-resume/reactive-resume/actions/runs/40416118446),
+[autofix 40417598213](https://github.com/reactive-resume/reactive-resume/actions/runs/40417598213),
+[mobile 40206816901](https://github.com/reactive-resume/reactive-resume/actions/runs/40206816901).
+
+## Validation
+
+Passed: production build; complete unit suites at one and four package concurrency; warm-cache run; all 21
+browser tests at one and four workers; four targeted guard mutations; tooling typecheck; repository-wide
+`pnpm lint:agent`, `pnpm format:check`, `pnpm knip`, `pnpm exec turbo boundaries`; `git diff --check`; and
+all-workflow actionlint with existing Blacksmith runner labels declared in a temporary actionlint config.
+No native release/store submission or new hosted speedup has been measured by this local validation.
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index aafdfa2d3..f078fdb28 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -23,12 +23,19 @@ env:
jobs:
e2e:
- name: Unit and browser tests
+ name: ${{ matrix.suite }} tests
if: ${{ !inputs.live_smoke }}
+ strategy:
+ fail-fast: false
+ matrix:
+ suite: [Unit, Browser]
env:
APP_URL: http://localhost:3000
PORT: "3000"
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
+ # Public fixtures for disposable CI services. Random values invalidate every Turbo test key.
+ AUTH_SECRET: isolated-ci-auth-secret-32-characters
+ ENCRYPTION_SECRET: isolated-ci-encryption-secret-32-characters
FLAG_DISABLE_SIGNUPS: "false"
FLAG_DISABLE_EMAIL_AUTH: "false"
FLAG_ENABLE_GUEST_LOGIN: "true"
@@ -65,14 +72,14 @@ jobs:
uses: actions/checkout@v7
with:
persist-credentials: false
- fetch-depth: 0
+ fetch-depth: ${{ matrix.suite == 'Unit' && '0' || '1' }}
- name: Checkout Repository (Blacksmith)
if: ${{ vars.USE_BLACKSMITH == 'true' }}
uses: useblacksmith/checkout@v1
with:
persist-credentials: false
- fetch-depth: 0
+ fetch-depth: ${{ matrix.suite == 'Unit' && '0' || '1' }}
- name: Install pnpm
uses: pnpm/action-setup@v6
@@ -87,9 +94,9 @@ jobs:
uses: actions/cache@v6
with:
path: .turbo/cache
- key: ${{ runner.os }}-${{ runner.arch }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('pnpm-lock.yaml', '.nvmrc') }}-${{ github.sha }}
+ key: ${{ runner.os }}-${{ runner.arch }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ matrix.suite }}-${{ hashFiles('pnpm-lock.yaml', '.nvmrc') }}-${{ github.sha }}
restore-keys: |
- ${{ runner.os }}-${{ runner.arch }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('pnpm-lock.yaml', '.nvmrc') }}-
+ ${{ runner.os }}-${{ runner.arch }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ matrix.suite }}-${{ hashFiles('pnpm-lock.yaml', '.nvmrc') }}-
- name: Install Dependencies
run: pnpm install --frozen-lockfile
@@ -98,20 +105,18 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y poppler-utils
- name: Check Package Boundaries
+ if: matrix.suite == 'Unit'
run: pnpm exec turbo boundaries
- name: Typecheck Affected Packages
+ if: matrix.suite == 'Unit'
run: pnpm exec turbo run typecheck --affected
- name: Install Playwright Browser
+ if: matrix.suite == 'Browser'
timeout-minutes: 10
run: pnpm exec playwright install --with-deps chromium
- - name: Generate Test Secrets
- run: |
- echo "AUTH_SECRET=$(openssl rand -hex 32)" >> "$GITHUB_ENV"
- echo "ENCRYPTION_SECRET=$(openssl rand -hex 32)" >> "$GITHUB_ENV"
-
- name: Prepare Storage
run: mkdir -p "$LOCAL_STORAGE_PATH"
@@ -119,25 +124,27 @@ jobs:
run: pnpm db:migrate
- name: Prepare OAuth Test Database
+ if: matrix.suite == 'Unit'
run: |
psql "$DATABASE_URL" -c "CREATE DATABASE oauth_test"
DATABASE_URL="$OAUTH_TEST_DATABASE_URL" pnpm db:migrate
- # Runs every workspace package, not a hand-maintained filter list, so a package
- # cannot silently lose coverage by being left out. Serial execution: the PDF
- # rasterization and API rate-limit suites time out when several packages' Vitest
- # thread pools oversubscribe the runner at once.
+ # Discover every package. Four pools of two workers fit the 32-vCPU runner;
+ # keep smaller GitHub runners serial to avoid PDF/rate-limit timeouts.
- name: Run Unit Tests
- run: pnpm exec turbo run test:ci --concurrency=1
+ if: matrix.suite == 'Unit'
+ run: pnpm exec turbo run test:ci --concurrency=${{ vars.USE_BLACKSMITH == 'true' && 4 || 1 }}
- name: Build
+ if: matrix.suite == 'Browser'
run: pnpm build
- name: Run E2E Tests
- run: pnpm exec playwright test
+ if: matrix.suite == 'Browser'
+ run: pnpm exec playwright test --workers=${{ vars.USE_BLACKSMITH == 'true' && 4 || 1 }}
- name: Upload Playwright Report
- if: always()
+ if: always() && matrix.suite == 'Browser'
uses: actions/upload-artifact@v7
with:
name: playwright-report
diff --git a/AGENTS.md b/AGENTS.md
index 25e48939e..7678a7fac 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -181,7 +181,7 @@ pnpm exec turbo boundaries
- Vitest tests live alongside source as `src/**/*.test.ts(x)` or `src/**/*.spec.ts(x)` (including integration tests). Paths under `pnpm --filter <package>` are package-relative. Pass paths directly after `test`: an extra `--` currently prevents Vitest from filtering the run. Shared settings live in `vitest.shared.mts` and setup in `vitest.setup.ts`; most packages use Node, while `packages/ui` uses `happy-dom`.
- Coverage uses V8 and writes package-local `coverage/` reports. No shared minimum coverage threshold is configured. `test:ci` writes JSON/JUnit results under package-local `reports/`.
-- Root `pnpm test`, `pnpm test:coverage`, and `pnpm typecheck` run workspace checks through Turbo. CI checks boundaries and affected-package typechecks, then runs all unit suites with `pnpm exec turbo run test:ci --concurrency=1` to avoid CPU contention in PDF/rate-limit suites. Unit/browser and Vercel workflows persist `.turbo/cache`; cached coverage and test reports restore to package-local output directories.
+- Root `pnpm test`, `pnpm test:coverage`, and `pnpm typecheck` run workspace checks through Turbo. CI runs unit and browser jobs independently. Unit CI checks boundaries and affected-package typechecks, then discovers all unit suites with Turbo: four concurrent packages on 32-vCPU Blacksmith runners, one on GitHub runners, with two Vitest workers per package. Local test scripts remain serial. Unit/browser and Vercel jobs persist separate `.turbo/cache` namespaces; cached coverage and test reports restore to package-local output directories. Public, fixed CI secrets belong only to disposable services and keep unchanged test cache keys reusable; database and workflow integration suites retain their package-level cache opt-outs.
- Real-database unit suites use `COVER_LETTER_TEST_DATABASE_URL` and `OAUTH_TEST_DATABASE_URL`; see `.github/workflows/e2e.yml` for isolated database setup. Never point test fixtures at production data.
- After changing shared contracts, exports, or imports, check affected consumers and run `pnpm exec turbo boundaries`.
@@ -200,7 +200,7 @@ pnpm test:e2e:ui
- `playwright.config.ts` starts `node apps/server/dist/index.mjs` in production mode and waits for `/api/health`; locally it can reuse an existing server. Build first. Keep the direct Node command: pnpm's script process groups can prevent Playwright from cleaning up a server started through `pnpm start`.
- Export `APP_URL`, `PORT`, `DATABASE_URL`, `AUTH_SECRET`, and `ENCRYPTION_SECRET`, and choose an absolute writable `LOCAL_STORAGE_PATH`. Auth fixtures need signups/email auth enabled; `FLAG_DISABLE_API_RATE_LIMIT=true` is appropriate for this isolated test installation.
- Assistant specs use a deterministic local AI stub and need `FLAG_ALLOW_UNSAFE_AI_BASE_URL=true`; otherwise those specs skip. See `tests/e2e/README.md` for the full environment recipe; adapt its example storage path to your machine.
-- Playwright runs Chromium with no retries. CI uses one worker and retains failure traces, screenshots, videos, and reports. PDF/DOCX rasterization and visual regression are outside this browser gate.
+- Playwright runs Chromium with no retries. CI selects four workers on Blacksmith and one on GitHub runners; the config default remains one in CI. Tests own separate accounts and browser contexts. CI retains failure traces, screenshots, videos, and reports. PDF/DOCX rasterization and visual regression are outside this browser gate.
## Code style
diff --git a/tests/e2e/README.md b/tests/e2e/README.md
index 9703faece..80ac1b0c4 100644
--- a/tests/e2e/README.md
+++ b/tests/e2e/README.md
@@ -28,6 +28,11 @@ Run tests:
`APP_URL=http://localhost:3000 PORT=3000 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres FLAG_DISABLE_SIGNUPS=false FLAG_DISABLE_EMAIL_AUTH=false FLAG_ENABLE_GUEST_LOGIN=true FLAG_DISABLE_API_RATE_LIMIT=true FLAG_ALLOW_UNSAFE_AI_BASE_URL=true LOCAL_STORAGE_PATH=/workspace/data/e2e pnpm test:e2e`
+CI runs browser tests independently from unit tests, with four Playwright workers on 32-vCPU Blacksmith runners
+and one on GitHub runners. Each test owns its account and browser context; provider fixtures use ephemeral ports.
+To compare locally, append `--workers=1` or `--workers=4` to the test command against the same disposable database
+and production build. The runner still uses zero retries, so parallelism cannot hide a failed test.
+
## Coverage
- Email/password sign-up, sign-out and sign-in through the UI.
diff --git a/tooling/mobile-updates.test.ts b/tooling/mobile-updates.test.ts
index 9f52c4244..2bd02bc3b 100644
--- a/tooling/mobile-updates.test.ts
+++ b/tooling/mobile-updates.test.ts
@@ -56,9 +56,25 @@ const previous = { ...healthy, revision: "b".repeat(40) };
it.each([
["matching healthy backend", [healthy], 0, 3],
["previous commit", [previous], 1, 60],
- ["unhealthy backend", [{ ...healthy, status: "unhealthy" }], 1, 60],
- ["unrelated service", [{ ...healthy, service: "other" }], 1, 60],
- ["rolling deployment", [previous, healthy, healthy, previous, healthy, healthy, healthy], 0, 7],
+ [
+ "rolling deployment resets stability for every rejected probe",
+ [
+ healthy,
+ healthy,
+ previous,
+ healthy,
+ healthy,
+ { ...healthy, status: "unhealthy" },
+ healthy,
+ healthy,
+ { ...healthy, service: "other" },
+ healthy,
+ healthy,
+ healthy,
+ ],
+ 0,
+ 12,
+ ],
] as const)("requires three consecutive matching production probes: %s", (_name, responses, status, probes) => {
const script = workflow.match(
/ - name: Wait for matching production backend[\s\S]*? run: \|\n([\s\S]*?)(?=\n - name:)/,