Optimize backend CI build: skip frontend, parallelize jobs#7435
Optimize backend CI build: skip frontend, parallelize jobs#7435
Conversation
Add cache mounts for npm, turbo, Next.js, and uv caches so incremental frontend and Python dependency builds can reuse previously compiled artifacts. Also consolidate two apt-get install calls in compile_image into one. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Move admin-ui build out of Docker into a separate Build-Frontend job that runs in parallel with Collect-Tests. The pre-built output is uploaded as an artifact and injected into the Docker build via --build-context, causing BuildKit to skip the frontend stages entirely. Co-authored-by: Cursor <cursoragent@cursor.com>
Backend tests don't need real admin-ui files -- the runtime code returns a placeholder when files are missing, and all UI tests mock the file-resolution functions. A single index.html satisfies the Dockerfile COPY while eliminating the ~4 min npm ci + export step. Co-authored-by: Cursor <cursoragent@cursor.com>
Collect-Tests is a syntax/import sanity check that produces no artifacts Build needs. Running them in parallel shaves ~2-3 min off the critical path while still failing the workflow on errors. Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThis PR optimizes the backend CI build pipeline by eliminating unnecessary frontend compilation and adding BuildKit cache mounts. The changes reduce the Build job duration from ~15 minutes to ~5 minutes through three key optimizations:
The implementation is clean and well-architected. All changes are localized to CI configuration with no impact on production deployments. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: cf9822a |
Ticket ENG-2734
Description Of Changes
Optimize the
Buildjob inbackend_checks.ymlwhich previously took ~15 minutes. The bottleneck was building the frontend (admin-ui + privacy-center) inside Docker with no caching across CI runs.Three key changes:
Skip the real frontend build entirely for backend CI. Backend tests don't need actual admin-ui files -- the runtime code returns a placeholder when files are missing, and all UI-related tests mock the file-resolution functions. A tiny placeholder
index.htmlsatisfies the Dockerfile'sCOPY --from=built_frontendwhile eliminating ~10 min of npm/turbo/Next.js compilation.Inject the placeholder via
--build-contextoverride. TheBuildjob uploads a placeholder artifact and passesbuild-contexts: built_frontend=prebuilttodocker/build-push-action. This causes BuildKit to resolveCOPY --from=built_frontendfrom the pre-built directory and skip thefrontendandbuilt_frontendDockerfile stages entirely. No Dockerfile changes needed for this -- local builds andpublish_docker.yamlare unaffected.Run
Collect-Testsin parallel withBuildinstead of gating it.Collect-Testsis a syntax/import sanity check (pytest --collect-only) that produces no artifacts the Build job needs. Decoupling it from Build'sneedssaves ~2-3 min on the critical path while still failing the workflow independently on errors.Additionally, the Dockerfile gets BuildKit cache mounts for local build speed (
uv,npm, turbo, Next.js caches) and consolidatedapt-getcalls.CI Performance
Code Changes
.github/workflows/backend_checks.yml- AddBuild-Frontend-Placeholderjob that creates a minimalindex.htmland uploads it as an artifact (~5 seconds).github/workflows/backend_checks.yml- ModifyBuildjob to download the placeholder artifact and passbuild-contexts: built_frontend=prebuiltto skip frontend Dockerfile stages.github/workflows/backend_checks.yml- RemoveCollect-TestsfromBuild'sneedsso they run in parallelDockerfile- Add--mount=type=cachedirectives foruv,npm, turbo, and Next.js caches (benefits local builds)Dockerfile- Consolidate twoapt-get update && apt-get installcalls into one (fewer layers)Steps to Confirm
Build-Frontend-Placeholderjob completes in secondsBuildjob completes in ~5 min (down from ~15 min)Collect-Testsruns in parallel withBuild, not blocking itpublish_docker.yamland local builds (nox -s "build(slim)") are unaffectedPre-Merge Checklist
CHANGELOG.mdupdated