Speed up preview deploys and CI: clone payloadcms-dev + cache seeded dev.db & Playwright#1060
Closed
rchlfryn wants to merge 6 commits intochore/upgrade-next-16from
Closed
Speed up preview deploys and CI: clone payloadcms-dev + cache seeded dev.db & Playwright#1060rchlfryn wants to merge 6 commits intochore/upgrade-next-16from
rchlfryn wants to merge 6 commits intochore/upgrade-next-16from
Conversation
59f9feb to
cdf40b3
Compare
3 tasks
029a927 to
d5dcbe1
Compare
Each preview previously ran ~5 minutes of migrations + seed-from-scratch (3m 26s seed + 1m 35s migrations) on a brand-new Turso database. The existing payloadcms-dev DB is already maintained by development.yaml (every push to main) and sync-prod-to-dev.yml (nightly) — it has prod data, all migrations applied, and is always available. Cloning from it takes seconds. Changes: - preview.yaml: turso db create now passes --from-db payloadcms-dev so the new preview DB starts as a copy of dev instead of empty. - The seed step is removed (cloned DB already has data). - pnpm migrate is kept — runs idempotently on the clone, only applies migrations the PR itself adds. - pnpm ii → pnpm install --frozen-lockfile --ignore-workspace, skipping lockfile reconciliation on CI. Risk parity: previews now contain the same prod-derived data that the dev environment already exposes. Reviewers log in with their real prod accounts (the seed's bootstrap@avy.com isn't present in dev/prod). Expected: preview deploys drop from ~11 min to ~6 min. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cdf40b3 to
26e17a5
Compare
Two GitHub Actions caches that target the slowest non-build steps in the build and e2e jobs: - Seeded dev.db cache (~3 minutes saved). Cache key hashes the seed scripts, migrations, payload config, collections, globals, and the lockfile — so any change that would alter the seed output evicts the cache. Otherwise, the seed step is skipped via a conditional `if`. Applied to both `build` and `e2e` jobs (they share the same key, so whichever runs first warms the cache for the other). - Playwright browser binaries cache (~30-60s saved). Cache key includes pnpm-lock.yaml so a `@playwright/test` bump invalidates it. We still call `playwright install --with-deps` to keep apt system deps in sync. Cache misses (seed-related files changed) fall back to the original behavior — full seed and full chromium download. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cache seeded dev.db and Playwright browsers in CI
Contributor
|
Preview deployment: https://chorexpreview-deploy-speedup.preview.avy-fx.org |
…meout - Replace `pnpm ii` (= `pnpm --ignore-workspace install`) with `pnpm install --frozen-lockfile --ignore-workspace` across all remaining workflows (ci.yaml ×7, development, production, dependabot-auto-format, sync-prod-to-dev). preview.yaml was already changed earlier in this PR. Frozen-lockfile skips lockfile reconciliation on CI and prevents accidental lockfile mutations from CI runs. - playwright.config.ts: drop webServer.timeout from 300000ms (5 min) to 90000ms (90s). Was sized for slow webpack dev boots; Next 16's default Turbopack dev boots in ~340ms, so 90s is plenty and we now fail fast when the server actually has trouble booting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`vercel build` runs `next build` underneath, which uses .next/cache for webpack/SWC module caches and ISR fetch cache. Caching this between runs lets subsequent preview deploys reuse incremental compilation state, typically shrinking the build step by 30-60%. Cache key hierarchy: - Primary: nextjs-cache-<os>-<lockfile-hash>-<sha> (per-commit, always saves a fresh entry) - Fallback 1: nextjs-cache-<os>-<lockfile-hash>- (most recent cache with the same dependency tree) - Fallback 2: nextjs-cache-<os>- (any cache for this OS, when the lockfile changes) Cache size is typically 100-300 MB; well within GitHub's 10 GB repo limit. Cache misses fall back to today's behavior (cold build). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Splits the e2e job across two parallel runners using strategy.matrix on the Playwright project name. Each shard runs only its own specs via the existing `pnpm test:e2e:admin` / `pnpm test:e2e:frontend` scripts. Wall-clock for E2E is roughly halved on the test-execution side. Setup duplicates across shards, but the seed and Playwright caches (also added in this PR) cover most of it — main duplicated cost is the build (~2m) which we'd pay once before sharding anyway. `fail-fast: false` so a failure in one shard doesn't cancel the other — we want both reports. Note for merge-queue setup: both `e2e (admin)` and `e2e (frontend)` need to be added as required status checks if the old `e2e` check was required. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closing because we don't need to spend time on this at the moment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bundle of CI/deploy speedups, plus consistency cleanups.
Stacked on #1059 (Next 16 upgrade). Will retarget to
mainafter that merges.Related Issues
N/A. Investigation came out of #1059's CI timing — the preview deploy run for that PR took 11 minutes, of which:
Key Changes
1. Preview deploys clone
payloadcms-devinstead of seeding from scratch.github/workflows/preview.yaml:turso db create "${name}" --wait→turso db create "${name}" --from-db payloadcms-dev --wait.payloadcms-devis already maintained by development.yaml and sync-prod-to-dev.yml — has all migrations applied and prod-derived data. Cloning is seconds.pnpm seed:standalonestep removed entirely — clone has the data.pnpm migratekept — idempotent. No-op when the PR doesn't add migrations; applies just the new ones when it does.2. CI caches for the build & e2e jobs (was #1061, merged in)
.github/workflows/ci.yaml:dev.dbcache (~3 min saved on hit). Cache key hashes seed scripts, migrations, payload config, collections, globals, andpnpm-lock.yaml. Applied to bothbuildande2ejobs (shared key, so they warm each other). Seed step skipped viaif: steps.db-cache.outputs.cache-hit != 'true'on a hit.pnpm-lock.yaml. We still callplaywright install --with-depsso apt system deps stay in sync.3.
pnpm install --frozen-lockfile --ignore-workspaceeverywhereReplaced
pnpm ii(=pnpm --ignore-workspace install) across all 11 callsites in 6 workflow files:ci.yaml(×7),preview.yaml,development.yaml,production.yaml,dependabot-auto-format.yml,sync-prod-to-dev.yml. Frozen-lockfile skips lockfile reconciliation on CI and prevents accidental lockfile mutations from CI runs. Small per-job speedup, bigger consistency/safety win.4. Drop Playwright
webServer.timeoutfrom 5 min → 90splaywright.config.ts: was sized for slow webpack dev boots when E2E usespnpm devas its server. Next 16's default Turbopack dev boots in ~340ms (per #1059's tests), so 90s is plenty and we now fail fast when the server actually has trouble booting.5. Cache
.next/cachebetween preview deploysvercel buildrunsnext buildunderneath, which uses.next/cachefor webpack/SWC module caches and ISR fetch cache. Caching that between preview runs lets subsequent deploys reuse incremental compilation state. Typical Next.js project savings on the build step are 30-60% when the cache hits.Cache-key hierarchy:
nextjs-cache-<os>-<lockfile-hash>-<sha>(per-commit, always saves fresh)nextjs-cache-<os>-<lockfile-hash>-(most recent cache, same deps)nextjs-cache-<os>-(any cache, e.g. when lockfile changes)6. Shard E2E job by Playwright project (admin / frontend)
ci.yaml'se2ejob now usesstrategy.matrixto run admin and frontend specs on parallel runners via the existingtest:e2e:admin/test:e2e:frontendscripts. Wall-clock for E2E is roughly halved on the test-execution side.fail-fast: falseso a failure in one shard doesn't cancel the other.Important: this changes the GitHub check-run names. The single
e2echeck becomes two checks:e2e (admin)ande2e (frontend). Branch protection / merge-queue required-status-checks need updating — removee2eand add bothe2e (admin)ande2e (frontend). (One-time settings change.)Playwright report artifacts are also split:
playwright-report-adminandplaywright-report-frontend, since matrix jobs can't share the same artifact name.Expected timing
Preview deploy: ~11m → ~5m
.next/cache)CI build & e2e jobs: ~3-4m saved on cache hit, plus E2E roughly halves with sharding.
How to test
pnpm migrateruns and applies it on the cloned DB..next/cacheyet). Push a follow-up commit; the second build should be noticeably faster, and the GitHub Actions cache restore step should report a hit.build/e2ejobs in CI show the seed step asskippedafter the cache is warmed.e2erun.e2e (admin)ande2e (frontend)both appear as separate checks in the merge queue.e2ewithe2e (admin)+e2e (frontend).Tradeoffs / risks
payloadcms-devdeployment. Risk parity with dev.bootstrap@avy.comlogin: the seed creates that test user; cloning from dev/prod doesn't have it. Reviewers/QA log in with real prod accounts.development.yamlandsync-prod-to-dev.ymldodestroy + create --from-db payloadcms-prod. A preview that lands in the ~5-second destroy/recreate window will fail at--from-db. Cost: rerun the workflow.pnpm seed:standaloneproduces the same DB content for the same inputs. If hidden non-determinism (e.g.Date.now()in a field) causes flakes, the cleanest fix is making the seed deterministic; workaround is expanding the cache key..next/cachecorrectness: the cache restoration is keyed by lockfile + commit SHA with restore-keys for fallback. If a stale cache somehow produces an incorrect build (Next/webpack bugs do happen), bumping the lockfile or running a no-op rebase forces a cold build. Cache size is bounded; GitHub keeps caches up to 10 GB and evicts LRU.merge_group, not every PR push.e2e→e2e (admin)+e2e (frontend). Merges may stall until branch protection settings are updated.Migration Explanation
No application database migrations. CI/deploy-only change.
Future enhancements
runs-on: ubuntu-latest-4-cores) — would shrink thebuildjob especially. Cost: more GitHub Actions minutes.setup repo + pnpm + node + installboilerplate (duplicated 11+ times). Pure refactor, no perf change.🤖 Generated with Claude Code