feat(ci): warm Next.js builds via Turbopack persistent cache on a sticky disk (#5869)

* feat(ci): warm Next.js builds via Turbopack persistent cache on a sticky disk

- enable experimental.turbopackFileSystemCacheForBuild behind
  NEXT_TURBOPACK_BUILD_CACHE so only the CI check build opts in; production
  image builds stay on the default cold path until the feature stabilizes
- mount ./apps/sim/.next/cache as a Blacksmith sticky disk (cache-mount)
  instead of actions/cache: the turbopack cache is ~5 GB, which a sticky disk
  mounts in ~1s while an actions/cache round-trip would eat the win
- measured locally: 105s cold compile vs 22s warm (4.8x)

* chore(ci): drop the superseded actions/cache comment and restore trailing newline
This commit is contained in:
Waleed
2026-07-22 17:10:24 -07:00
committed by GitHub
parent 2b5a92a3c8
commit 02bc8f1828
2 changed files with 19 additions and 14 deletions
+13 -14
View File
@@ -236,21 +236,17 @@ jobs:
key: ${{ github.repository }}-turbo-cache-build-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}
path: ./.turbo
# Keyed per commit so EVERY run saves its refreshed cache — a key without
# a unique suffix is written once and then frozen (GitHub caches are
# immutable per key; a primary-key hit skips the save), which left builds
# compiling against a cache stale since the last lockfile change. The
# restore-keys prefix match picks the most recently saved cache for this
# lockfile, falling back across lockfile changes.
- name: Restore Next.js build cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
# Turbopack's persistent build cache (NEXT_TURBOPACK_BUILD_CACHE below)
# writes ~5 GB into .next/cache — a sticky disk mounts it in ~1s where an
# actions/cache round-trip would eat the warm-build win. Same event/fork
# namespacing as the other mounts; the GitHub fallback inside cache-mount
# still uses actions/cache with a run_id-suffixed key.
- name: Mount Next.js build cache
uses: ./.github/actions/cache-mount
with:
provider: ${{ vars.CI_PROVIDER }}
key: ${{ github.repository }}-nextjs-cache-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}
path: ./apps/sim/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-${{ github.sha }}-
${{ runner.os }}-nextjs-${{ hashFiles('bun.lock') }}-
${{ runner.os }}-nextjs-
- name: Install dependencies
run: bun install --frozen-lockfile
@@ -266,4 +262,7 @@ jobs:
AWS_REGION: 'us-west-2'
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
TURBO_CACHE_DIR: .turbo
run: bunx turbo run build --filter=sim
# Opt into Turbopack's persistent build cache (beta) for this CI
# check build only — measured 105s cold vs 22s warm locally.
NEXT_TURBOPACK_BUILD_CACHE: '1'
run: bunx turbo run build --filter=sim
+6
View File
@@ -144,6 +144,12 @@ const nextConfig: NextConfig = {
experimental: {
optimizeCss: !isDev,
turbopackFileSystemCacheForDev: false,
/**
* Turbopack's persistent build cache (beta) — opt-in via env so only the
* CI check build uses it; production image builds stay on the default
* cold-build path until the feature stabilizes.
*/
turbopackFileSystemCacheForBuild: process.env.NEXT_TURBOPACK_BUILD_CACHE === '1',
preloadEntriesOnStart: false,
optimizePackageImports: [
'lodash',