Skip to content

Shallow-clone preview builds to fix checkout variance.#1458

Draft
nathenharvey wants to merge 7 commits into
mainfrom
push-ttnqonkwkkyp
Draft

Shallow-clone preview builds to fix checkout variance.#1458
nathenharvey wants to merge 7 commits into
mainfrom
push-ttnqonkwkkyp

Conversation

@nathenharvey

Copy link
Copy Markdown
Collaborator

Process control analysis across 83 PR Preview runs identified the Checkout step as the dominant source of variance in build_drafts_on (σ=16.5s vs σ=2.5s for build_drafts_off). Two recent runs hit 73s runs outside XmR control limits.

The root cause is that actions/checkout fetches the full commit history by default. The build needs only the working tree at HEAD — no git history is required by Hugo, Svelte, or the Firebase deploy. With fetch-depth: 1, only the tip commit is fetched regardless of repo depth.

Without this change, checkout time will continue to grow as the repo accumulates commits, and the outlier pattern will worsen.

Expected outcome: checkout normalizes to 2–5s, σ drops below 3s for both jobs, and mean build time falls by ~10–12s (~15%).

Only the two build jobs are changed. The test and test_redirects jobs retain their existing checkout config (one uses submodules: recursive and a different action version).

Process control analysis across 83 PR Preview runs identified the Checkout step as the dominant source of variance in `build_drafts_on` (σ=16.5s vs σ=2.5s for `build_drafts_off`). Two recent runs hit 73s runs outside XmR control limits.

The root cause is that actions/checkout fetches the full commit history by default. The build needs only the working tree at HEAD — no git history is required by Hugo, Svelte, or the Firebase deploy.  With fetch-depth: 1, only the tip commit is fetched regardless of repo depth.

Without this change, checkout time will continue to grow as the repo accumulates commits, and the outlier pattern will worsen.

Expected outcome: checkout normalizes to 2–5s, σ drops below 3s for both jobs, and mean build time falls by ~10–12s (~15%).

Only the two build jobs are changed. The test and test_redirects jobs retain their existing checkout config (one uses submodules: recursive and a different action version).
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 0345fa1):

https://doradotdev--pr1458-drafts-off-6i7ovnpv.web.app

(expires Wed, 22 Jul 2026 17:10:32 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 7ad2b3cf9cceb558b493931176f998ae46924361

@nathenharvey

Copy link
Copy Markdown
Collaborator Author

After 10 builds, build_drafts_on checkout σ collapsed from 17.3s to 1.1s (94% reduction). The 152s and 73s outliers are gone. Both jobs now have near-identical, stable checkout times, and total mean dropped by ~11s (~15%) as predicted.

@nathenharvey nathenharvey marked this pull request as ready for review June 21, 2026 01:57
@nathenharvey nathenharvey requested a review from davidstanke June 21, 2026 01:57
Process control analysis identified the Svelte build step as the second-largest source of variance in preview build times (mean ~9s, σ=4.4s, with cold-start spikes to 32s). The full `npm ci` runs on every preview build even when `package-lock.json` hasn't changed, which means re-downloading and re-installing the same packages on every PR.

`actions/cache@v4` now restores `svelte/node_modules` before the build step, keyed on the workspace `package-lock.json` hash. When the cache hits, `build.sh` skips `npm ci` entirely and the four Svelte subprojects go straight to vite build. Cache invalidates automatically on any lockfile change.

Expected outcome: Svelte build step drops from ~9s to ~1-2s on cache hits, cold-start spikes are eliminated, and the cache miss path is identical to the current baseline.

`deploy.yml` is intentionally unchanged — it always runs `npm ci`, which remains correct for production deployments.
@nathenharvey nathenharvey removed the request for review from davidstanke June 21, 2026 15:10
@nathenharvey nathenharvey marked this pull request as draft June 21, 2026 15:10
@nathenharvey

Copy link
Copy Markdown
Collaborator Author

Caching svelte builds delivers ~2s savings (eliminating npm ci) and elimination of the cold-start spike pattern. The mean dropped from ~8.9s → ~6.9s, σ improved from 2.9s → 1.9s. Modest but real.

To get to 1–2s, the Vite builds themselves would need to be cached — specifically the dist/ outputs, keyed on source file hashes. That's a larger change with higher staleness risk, and is probably not worth pursuing unless the Svelte code changes infrequently relative to build frequency.

The PR is worth merging for the spike elimination alone, there is a modest (~2s) performance gain.

Explicitly set up Node.js by adding the `setup-node` action with caching before the Svelte step to eliminate overhead
Switching to `npm ci` enforces a clean, deterministic installation based strictly on your lockfile. This is significantly faster and more reliable in CI environments.
These changes didn't have a significant impact on build times and introduce additional complexity. Let's remove them.
Explicitly set up Node.js by adding the `setup-node` action with caching before the Svelte step to eliminate overhead
Cache the `svelte/node_modules` directory in the preview workflow to reduce CI execution times.

- Adds `actions/cache@v4` steps in `.github/workflows/preview.yml` keyed by the hash of
`svelte/package-lock.json`.
- Updates `svelte/build.sh` to skip running `npm ci` if `svelte/node_modules` is already present
(e.g., when successfully restored from the cache).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant