Skip to content

chore(repo): prebuild shared e2e base workspace to skip per-file create-nx-workspace#35964

Draft
FrozenPandaz wants to merge 3 commits into
masterfrom
e2e-shared-base-workspace
Draft

chore(repo): prebuild shared e2e base workspace to skip per-file create-nx-workspace#35964
FrozenPandaz wants to merge 3 commits into
masterfrom
e2e-shared-base-workspace

Conversation

@FrozenPandaz

Copy link
Copy Markdown
Contributor

Current Behavior

The e2e suite is atomized into one task per spec file (e2e-ci--src/<file>.test.ts). Each task runs newProject() in its first beforeAll/beforeEach, which performs a create-nx-workspace cold start (~40s). On the tight hook timeout that intermittently flakes — it's the same root cause behind several Exceeded timeout of 60000 ms for a hook failures.

The existing proj-backup template that makes within-file newProject calls fast is built lazily and lives under the per-process e2e root, so it never crosses files or distributed agents. Every spec file pays the cold start again.

Expected Behavior

A new cached populate-e2e-base-workspace task builds a bare workspace template once, up front, and declares it as an Nx output (dist/local-registry/proj-backup). Because it's a cached output, Nx restores it to every distributed agent the same way the verdaccio storage already is — keyed on the nx build hash, so it rebuilds automatically when nx changes.

newProject() then seeds the workspace from that template via copySync (~0.3s) instead of running create-nx-workspace (~40s). It falls back to the original build when the template is absent (e.g. pnpm, or the task didn't run), so the change is purely additive. Each test still installs its own packages[] on top of the bare base, so what ends up installed per workspace is unchanged.

Measured locally

  • Template: ~177 MB / ~8.2k files (bare create-nx-workspace --preset=apps, npm).
  • Seed: copySync ~0.3s vs create-nx-workspace ~40s.

Note for reviewers

The remaining trade-off is the ~177 MB artifact restored per agent per run; the net win depends on files-per-agent in the e2e-ci distribution, worth confirming with an A/B before merging. npm only for now (pnpm store symlinks aren't portable) — pnpm falls back to the original path.

Related Issue(s)

N/A — e2e infrastructure / performance.


View session information ↗

@netlify

netlify Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 6fd5d03
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a2ccc0593dd5d000826565a
😎 Deploy Preview https://deploy-preview-35964--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 6fd5d03
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a2ccc056f66a00009de6ce0
😎 Deploy Preview https://deploy-preview-35964--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 6fd5d03

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 46m 26s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 59s View ↗
nx build workspace-plugin ✅ Succeeded 2m 28s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 17s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-13 04:11:53 UTC

…te-nx-workspace

Each atomized e2e-ci task pays a ~40s create-nx-workspace cold start in its first newProject hook (the proj-backup template is per-process, so it never crosses files or agents). This adds a cached populate-e2e-base-workspace task that builds a bare workspace template once and outputs it, so Nx restores it to every agent. newProject seeds from the template (~0.3s copy) instead of running create-nx-workspace, falling back to the original build when the template is absent (e.g. pnpm).
…emplate

newProject's seeding branch skipped runCreateWorkspace, which sets the module-level projName as a side effect that packageInstall -> getPackageManagerCommand relies on. Without it, the package.json read resolved to .../undefined/package.json and crashed, orphaning the seeded 'proj' dir and cascading into 'directory proj already exists' on subsequent newProject calls.
Declare the proj-backup template (a dependency output) via dependentTasksOutputFiles in e2eInputs so e2e tasks expect to read it, and use the /**/* glob for the populate task's script dir so its own script read is expected. Clears the sandbox violations introduced by the shared base workspace.
@FrozenPandaz FrozenPandaz force-pushed the e2e-shared-base-workspace branch from fe5814a to 6fd5d03 Compare June 13, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant