Skip to content

Commit cb77e1e

Browse files
committed
refactor(ci): trim the cache-key comments to the load-bearing facts
Keeps the mechanism (one mutable volume per key, clone-on-mount, last-write-wins) and the two numbers, drops the restated reasoning. Both report steps collapse to a single du, dropping a second full walk of a ~5 GB tree. Cleanup workflow loses a concurrency group a once-per-PR delete never needed.
1 parent 0fc251f commit cb77e1e

2 files changed

Lines changed: 28 additions & 57 deletions

File tree

.github/workflows/ci-cache-cleanup.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
name: CI Cache Cleanup
22

3-
# The Next.js build cache sticky disk in test-build.yml is keyed per branch, so
4-
# every PR leaves a ~5 GB volume behind. Branches are short-lived; the disks
5-
# aren't. Delete a branch's disk when its PR closes so storage tracks open PRs
6-
# rather than every branch the repo has ever seen.
7-
#
8-
# Only the pull_request-event disk is deleted. The push-event disks belong to
9-
# main/staging/dev and must stay warm.
3+
# test-build.yml keys the Next.js build cache sticky disk per branch, so every PR
4+
# leaves a ~5 GB volume behind. Branches are short-lived; the disks aren't. Only
5+
# the pull_request disks are reclaimed — the push disks belong to main/staging/dev
6+
# and must stay warm.
107

118
on:
129
pull_request:
1310
types: [closed]
1411

15-
concurrency:
16-
group: ci-cache-cleanup-${{ github.head_ref }}
17-
cancel-in-progress: false
18-
1912
permissions:
2013
contents: read
2114

2215
jobs:
2316
delete-nextjs-cache:
2417
name: Delete Next.js build cache disk
25-
# Sticky disks only exist on Blacksmith; in GitHub break-glass mode the
26-
# cache-mount fallback uses actions/cache, which expires on its own.
18+
# Sticky disks only exist on Blacksmith; the GitHub break-glass path uses
19+
# actions/cache, which expires on its own.
2720
if: vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith'
2821
runs-on: blacksmith-2vcpu-ubuntu-2404
2922
timeout-minutes: 5
3023

3124
steps:
32-
# Key must stay byte-identical to the Mount Next.js build cache key in
33-
# test-build.yml, or this silently deletes nothing and the disks pile up.
25+
# Must stay byte-identical to the Mount Next.js build cache key in
26+
# test-build.yml, or this deletes nothing and the disks accumulate.
27+
# Non-blocking: PRs skipped by ci.yml's paths-ignore never made a disk.
3428
- name: Delete sticky disk
3529
uses: useblacksmith/stickydisk-delete@b41313d28b8647d72114c9ba3c96bb04061562b6 # v1
3630
continue-on-error: true

.github/workflows/test-build.yml

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -267,24 +267,14 @@ jobs:
267267
# writes ~5 GB into .next/cache — a sticky disk mounts it in ~1s where an
268268
# actions/cache round-trip would eat the warm-build win.
269269
#
270-
# Scoped per branch, not just per event. A sticky disk is a single mutable
271-
# volume per key: mounting clones the last committed snapshot and the job
272-
# commits back last-write-wins. Keyed on event alone, every open PR shared
273-
# one volume, so each run cloned a snapshot built from a *different*
274-
# branch. Measured on the same staging commit, minutes apart: the push
275-
# disk (single-writer, genuinely warm) compiled in 9.3 min while the
276-
# shared pull_request disk took 14.0 min.
277-
#
278-
# Branch scoping is also the correctness-preserving choice —
279-
# turbopackFileSystemCacheForBuild is beta, and cross-commit restore is
280-
# not a documented-supported mode (vercel/next.js#87283 reports stale HTML
281-
# from a cache built at another commit). Every other cache layer here
282-
# already isolates by branch: GitHub's cache can't read sibling branches,
283-
# and Blacksmith's own cache product branch-scopes by default. Only this
284-
# key didn't.
285-
#
286-
# Cost of per-branch disks is bounded by ci-cache-cleanup.yml, which
287-
# deletes a branch's disk when its PR closes.
270+
# Keyed per branch, not just per event. A sticky disk is one mutable volume
271+
# per key: mounting clones the last committed snapshot, job end commits back
272+
# last-write-wins. An event-only key had every open PR restoring a cache
273+
# built from a different branch — 14.0 min vs 9.3 min for the single-writer
274+
# push disk on the same commit. Branch scoping also keeps us off
275+
# cross-commit restore, which turbopackFileSystemCacheForBuild (beta) does
276+
# not document as supported (vercel/next.js#87283: stale HTML from a cache
277+
# built at another commit). ci-cache-cleanup.yml reclaims the disks.
288278
- name: Mount Next.js build cache
289279
uses: ./.github/actions/cache-mount
290280
with:
@@ -310,19 +300,12 @@ jobs:
310300
- name: Install dependencies
311301
run: bun install --frozen-lockfile --ignore-scripts
312302

313-
# Whether the Turbopack cache was warm is otherwise invisible: the disk
314-
# mounts successfully either way, and turbo buffers the build log so
315-
# compile time only surfaces at the end. Without this, "is the cache
316-
# working" can only be answered by diffing compile times across runs and
317-
# guessing. Reported, never gated — this is a measurement, not a check.
318-
- name: Report Next.js cache state (pre-build)
319-
run: |
320-
CACHE_DIR=apps/sim/.next/cache
321-
if [ -d "$CACHE_DIR" ] && [ -n "$(ls -A "$CACHE_DIR" 2>/dev/null)" ]; then
322-
echo "PRE_BUILD_CACHE=warm ($(du -sh "$CACHE_DIR" | cut -f1), $(find "$CACHE_DIR" -type f | wc -l) files)"
323-
else
324-
echo 'PRE_BUILD_CACHE=cold (empty or absent — expect a full compile)'
325-
fi
303+
# The disk mounts successfully whether or not it carried anything and turbo
304+
# buffers the build log, so cache warmth is otherwise unobservable — #5859
305+
# shipped a cache that carried almost nothing and it took a PR to notice.
306+
# Reported, never gated.
307+
- name: Report Next.js cache size (pre-build)
308+
run: du -sh apps/sim/.next/cache 2>/dev/null || echo 'cold — no cache restored'
326309

327310
- name: Build application
328311
env:
@@ -336,18 +319,12 @@ jobs:
336319
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
337320
TURBO_CACHE_DIR: .turbo
338321
# Opt into Turbopack's persistent build cache (beta) for this CI check
339-
# build only. The 105s-cold/22s-warm figures behind this were measured
340-
# locally and have never reproduced in CI, where compile has ranged
341-
# 3.5-17.8 min — treat them as local numbers, not a CI target.
322+
# build only. #5869's 105s-cold/22s-warm was measured locally and has
323+
# never reproduced in CI (compile has ranged 3.5-17.8 min) — local
324+
# numbers, not a CI target.
342325
NEXT_TURBOPACK_BUILD_CACHE: '1'
343326
run: bunx turbo run build --filter=sim
344327

345-
- name: Report Next.js cache state (post-build)
328+
- name: Report Next.js cache size (post-build)
346329
if: always()
347-
run: |
348-
CACHE_DIR=apps/sim/.next/cache
349-
if [ -d "$CACHE_DIR" ]; then
350-
echo "POST_BUILD_CACHE=$(du -sh "$CACHE_DIR" | cut -f1) committed to the sticky disk for the next run on this branch"
351-
else
352-
echo 'POST_BUILD_CACHE=absent — the build wrote no cache'
353-
fi
330+
run: du -sh apps/sim/.next/cache 2>/dev/null || echo 'no cache written'

0 commit comments

Comments
 (0)