Skip to content

CI: trim fixed overhead from the sandbox create flow#35355

Draft
valentinpalkovic wants to merge 2 commits into
valentin/ci-shard-dev-e2efrom
valentin/ci-trim-sandbox-create
Draft

CI: trim fixed overhead from the sandbox create flow#35355
valentinpalkovic wants to merge 2 commits into
valentin/ci-shard-dev-e2efrom
valentin/ci-trim-sandbox-create

Conversation

@valentinpalkovic

Copy link
Copy Markdown
Contributor

Follow-up to #35353; the angular-create investigation (12 verified findings from the create-job phase decomposition + a timestamped local reproduction).

What (four independent trims, scripts/CI only)

  1. Yarn setup becomes two file writes. installYarn2 ran yarn set version berry + chained yarn config set calls: ~12 yarn boots and two network downloads (corepack bootstrap yarn, then latest Berry) per sandbox. The sandbox now vendors the repo's own pinned yarn release via yarnPath and writes .yarnrc.yml directly. packageManager is pinned to the same version - without the field, corepack auto-pins its classic bootstrap yarn and JsPackageManagerFactory misclassifies the sandbox as Yarn 1 (caught by the local E2E reproduction: installs kept working through yarnPath delegation while the CLI ran classic-syntax commands). Side effect: sandboxes now run the exact yarn version the monorepo pins instead of floating on latest Berry.
  2. No more rm -rf node_modules before the final install - the wipe forced a full re-extraction (~10-25s on CI) that yarn's incremental install makes redundant.
  3. Extra sandbox deps carry explicit version ranges (matching current npm latest majors), so addExtraDependencies stops probing the registry per package and sandbox contents stop drifting on new majors.
  4. Executor images move to cimg/node:22.22.3 (matching .nvmrc), which satisfies Angular's minimum - the ~9s node/install step disappears from every angular create/dev job. Create jobs also pre-warm the npx cache for the pinned gitpick version, so the template download skips its cold npx install.

Rejected while implementing

skip-install on the init CLI step (would fold init's install into the final one, ~15-25s): postinstallAddon resolves each addon's postinstall hook from the sandbox's node_modules and silently returns when resolution fails - with the install skipped, all addon configuration (including addon-vitest's setup) would silently disappear from sandboxes.

Measured (local timestamped E2E, angular-vite full creation)

Before After
Full yarn task sandbox (link mode) 107.3s 55.7s
Sandbox tree diff vs baseline - packageManager pin only; deps + .storybook byte-identical

Verified: .yarnrc.yml writer probed directly against both logFilter variants; yarn nx run-many -t check clean; normal + daily configs generate correctly (no node/install steps remain).

CI create-job step timings will be posted from this PR's pipeline.

@valentinpalkovic valentinpalkovic added build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). labels Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫

PR is not labeled with one of: ["qa:needed","qa:skip","qa:success"]

🚫 PR title must be in the format of "Area: Summary", With both Area and Summary starting with a capital letter Good examples: - "Docs: Describe Canvas Doc Block" - "Svelte: Support Svelte v4" Bad examples: - "add new api docs" - "fix: Svelte 4 support" - "Vue: improve docs"
🚫 PR description is missing the mandatory "#### Manual testing" section. Please add it so that reviewers know how to manually test your changes.
Warnings
⚠️

This PR targets valentin/ci-shard-dev-e2e. The default branch for contributions is next. Please make sure you are targeting the correct branch.

Generated by 🚫 dangerJS against b933d1a

@nx-cloud

nx-cloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a080575

Command Status Duration Result
nx run-many -t compile -c production --parallel=8 ✅ Succeeded 52s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-02 17:19:24 UTC

@storybook-app-bot

storybook-app-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

Package Benchmarks

Commit: a080575, ran on 2 July 2026 at 17:25:34 UTC

The following packages have significant changes to their size or dependencies:

@storybook/angular-vite

Before After Difference
Dependency count 34 34 0
Self size 22.41 MB 2.40 MB 🎉 -20.02 MB 🎉
Dependency size 22.54 MB 42.56 MB 🚨 +20.02 MB 🚨
Bundle Size Analyzer Link Link

@valentinpalkovic valentinpalkovic force-pushed the valentin/ci-trim-sandbox-create branch from 158e3c6 to 7631bf7 Compare July 2, 2026 16:49
Four independent trims, measured on a timestamped local reproduction of
angular-vite sandbox creation (107s -> 56s) and a phase decomposition of
the CI create jobs (83-106s 'Create Sandbox' step):

- Yarn setup becomes two file writes. installYarn2 ran 'yarn set version
  berry' plus chained 'yarn config set' calls: ~12 yarn boots and two
  network downloads (corepack's bootstrap yarn, then the latest Berry) per
  sandbox. The sandbox now vendors the repository's own pinned yarn release
  via yarnPath and writes .yarnrc.yml directly. packageManager is pinned in
  the sandbox package.json to the same version: without the field, corepack
  auto-pins its classic bootstrap yarn, and JsPackageManagerFactory would
  read that field and misclassify the sandbox as Yarn 1 (caught by the
  local reproduction; installs kept working through yarnPath delegation
  while the CLI ran classic-syntax commands).
- The final 'yarn install' no longer wipes node_modules first. The wipe
  forced a full re-extraction of the tree (~10-25s on CI) that yarn's
  incremental install makes redundant.
- Extra sandbox deps carry explicit version ranges, so addExtraDependencies
  does not probe the registry (a subprocess each) to resolve 'latest' for
  packages whose major we already know - and sandbox contents stop drifting
  when a new major is published.
- The executor images move to cimg/node:22.22.3, matching .nvmrc. That
  satisfies Angular's minimum Node version, so the per-job 'node/install'
  step (~9s on every angular create/dev job) is gone; the create jobs also
  pre-warm the npx cache for the pinned gitpick version the CLI spawns, so
  the template download does not pay a cold npx install.

Rejected while implementing: passing skip-install to the init CLI step
(would fold init's install into the final one, ~15-25s) silently no-ops
all addon configuration, because postinstallAddon resolves each addon's
postinstall hook from the sandbox's node_modules and returns quietly when
resolution fails - addon-vitest's setup would disappear from sandboxes.
@valentinpalkovic valentinpalkovic force-pushed the valentin/ci-trim-sandbox-create branch from 7631bf7 to a080575 Compare July 2, 2026 17:15
The readiness probe fetched /iframe.html and re-ran the dev task on any
failure. But the fetch can fail while a dev server owns the port - a cold
compile outlasting the timeout, or the server resetting connections before
its middleware is up (seen on a sveltekit shard: the probe got a reset,
the task spawned a second server, and that server crashed the job with
EADDRINUSE once its own compile finished). A held port now counts as
ready via a TCP-connect fallback; every consumer of the dev task performs
its own HTTP wait before using the server, so this cannot mask a dead
server. This also replaces the earlier CI-only 180s probe timeout with
behavior that is correct locally too.
@valentinpalkovic

Copy link
Copy Markdown
Contributor Author

Measured on this PR's pipeline (workflow b3459d3a, 82/82 green - run predates the last commit, which only touches the dev-task readiness probe):

Create job (step) Before (stack baseline) After
angular-vite create: total 237-264s ~230s
angular-vite: 'Install Node.js' step 8-9s removed (cimg image at 22.22.3)
angular-vite: Create Sandbox 106-119s 95s
react create: Create Sandbox 81-83s 71s
next-js vite create: Create Sandbox 91-107s 82s
Setup Corepack (now incl. gitpick pre-warm) ~3s 5-7s (saves the ~4s cold npx install inside Create Sandbox)

The CI delta is smaller than the local −48%: warm image-level caches on CI already absorbed part of what the local reproduction paid (corepack/npx cold installs). The structural win is the angular chain head (the workflow's critical path) plus ~10-25s on every one of the 15 create jobs.

Status note: the branch HEAD adds one more commit (b933d1a, dev-port readiness hardening - see the sveltekit EADDRINUSE analysis in #35356) that still needs a pipeline run; the last two triggered pipelines were canceled manually, so I've stopped auto-retriggering. Re-trigger via label toggle or push when ready.

@valentinpalkovic

Copy link
Copy Markdown
Contributor Author

HEAD validated via the stacked child run: 82/82 green on workflow 069b53d0 — the valentin/cli-sandbox-registry-probes branch contains this PR's HEAD (b933d1a), so every job ran with this PR's changes included.

Step timings from that run (final commits):

Job / step Baseline This run
angular-vite create (total) 237–264s 250s
angular-webpack create (total) 237–264s 231s
angular-vite Create Sandbox step 106–119s 103s
react-vite Create Sandbox step 81–83s 62s
Install Node.js step on cimg create jobs ~10–25s each removed

The node/install step remains only on Playwright-executor jobs for templates with ensureMinNodeVersion (Angular CLI requires Node ≥22.22.3, and the Playwright image ships an older one).

Note: this PR's own branch checks still point at the earlier canceled pipeline — a ci:normal label toggle or empty push will put a green check directly on the PR if the team wants one before merge. The code itself is fully validated by the run above. Ready to undraft from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant