Skip to content

Commit 04845b6

Browse files
committed
chore(ci): qualify bounded directory streaming on Node 24
1 parent b8ab8f4 commit 04845b6

6 files changed

Lines changed: 52 additions & 34 deletions

File tree

‎.github/scripts/compiler-policy-mutants.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
22
import subprocess,os,json
3-
p=Path('scripts/prune-turbopack-cache.ts');original=p.read_text();out=Path(os.environ['RUNNER_TEMP']);results=[]
3+
p=Path('scripts/prune-turbopack-cache.mts');original=p.read_text();out=Path(os.environ['RUNNER_TEMP']);results=[]
44
def case(name,old,new,pattern):
55
assert original.count(old)==1,(name,old)
66
try:

‎.github/workflows/ci-cache-policy-proof.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
2020
with:
2121
bun-version: 1.4.4
22+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
23+
with:
24+
node-version: '24'
2225
- name: Qualify lifecycle across completed workflow runs
2326
run: |
2427
python3 - <<'PYCODE'
@@ -62,7 +65,7 @@ jobs:
6265
SIM_TURBOPACK_CACHE_MAX_GB: '0.000001'
6366
run: |
6467
before=$(stat -c '%i' .next/cache)
65-
bun run ../../scripts/prune-turbopack-cache.ts --build
68+
node ../../scripts/prune-turbopack-cache.mts --build
6669
test "$before" = "$(stat -c '%i' .next/cache)"
6770
test -z "$(find .next/cache -mindepth 1 -print -quit)"
6871
- name: Hold partial producer for controlled cancellation
@@ -113,8 +116,10 @@ jobs:
113116
${{ runner.temp }}/cache-policy-tests.json
114117
${{ runner.temp }}/mutant-*.json
115118
${{ runner.temp }}/mutant-summary.json
116-
scripts/prune-turbopack-cache.ts
119+
scripts/prune-turbopack-cache.mts
117120
scripts/prune-turbopack-cache.test.ts
118121
apps/sim/lib/core/config/env.ts
119122
apps/sim/next.config.ts
120123
apps/sim/turbo.json
124+
apps/sim/package.json
125+
apps/docs/package.json

‎apps/docs/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "Apache-2.0",
66
"scripts": {
77
"dev": "bun run dev:cache:cap && bun run content:generate && bunx concurrently --kill-others --names Next,Content \"next dev --port 3001\" \"bun scripts/compile-content.ts --watch\"",
8-
"dev:cache:cap": "bun run ../../scripts/prune-turbopack-cache.ts",
8+
"dev:cache:cap": "node ../../scripts/prune-turbopack-cache.mts",
99
"dev:clean": "rm -rf .next/dev/cache",
1010
"build": "bun scripts/fetch-git-history.ts && bun run content:generate --prune && NODE_OPTIONS='--max-old-space-size=8192' next build",
1111
"start": "next start",

‎apps/sim/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"dev": "bun run build:cli-runtime && bun run dev:cache:cap && next dev --port 3000",
1212
"dev:capped": "bun run build:cli-runtime && bun run dev:cache:cap && NODE_OPTIONS='--max-old-space-size=4096' next dev --port 3000",
13-
"dev:cache:cap": "bun run ../../scripts/prune-turbopack-cache.ts",
13+
"dev:cache:cap": "node ../../scripts/prune-turbopack-cache.mts",
1414
"dev:clean": "rm -rf .next/dev/cache",
1515
"dev:webpack": "bun run build:cli-runtime && next dev --webpack",
1616
"load:workflow": "bun run load:workflow:baseline",
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bun
1+
#!/usr/bin/env node
22
/**
33
* Caps Turbopack's dev and CI build filesystem caches.
44
*
@@ -18,10 +18,13 @@
1818
* partial write and rebuilds silently.)
1919
*
2020
* Runs automatically before every `dev` script. Also invokable directly:
21-
* bun run scripts/prune-turbopack-cache.ts # prune if over the cap
22-
* bun run scripts/prune-turbopack-cache.ts --force # always prune
23-
* bun run scripts/prune-turbopack-cache.ts --dry-run # report only
24-
* bun run scripts/prune-turbopack-cache.ts --build # production cache, only between builds
21+
* node scripts/prune-turbopack-cache.mts # prune if over the cap
22+
* node scripts/prune-turbopack-cache.mts --force # always prune
23+
* node scripts/prune-turbopack-cache.mts --dry-run # report only
24+
* node scripts/prune-turbopack-cache.mts --build # production cache, only between builds
25+
*
26+
* Node's directory iterator reads bounded batches; Bun's compatibility iterator
27+
* materializes whole directories.
2528
*
2629
* Build mode retains the mounted cache root and fails maintenance errors; dev
2730
* maintenance stays nonblocking. Size checks stream entries and stop once the

‎scripts/prune-turbopack-cache.test.ts‎

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { tmpdir } from 'node:os'
1515
import { join, resolve } from 'node:path'
1616
import { afterEach, describe, expect, it } from 'vitest'
1717

18-
const script = resolve(import.meta.dirname, 'prune-turbopack-cache.ts')
18+
const script = resolve(import.meta.dirname, 'prune-turbopack-cache.mts')
1919
const fixtures: string[] = []
2020

2121
function fixture() {
@@ -33,7 +33,7 @@ function fixture() {
3333
}
3434

3535
function run(root: string, args: string[], maximum = '0.000001') {
36-
return spawnSync('bun', [script, ...args], {
36+
return spawnSync('node', [script, ...args], {
3737
cwd: root,
3838
encoding: 'utf8',
3939
timeout: 10_000,
@@ -46,17 +46,24 @@ afterEach(() => {
4646
})
4747

4848
describe('compiler cache maintenance through the real CLI', () => {
49-
it.each(['size', 'force'])('clears only build contents by %s while preserving its mount', (mode) => {
50-
const { root, build, dev, outside } = fixture()
51-
const inode = statSync(build).ino
52-
const result = run(root, mode === 'force' ? ['--build', '--force'] : ['--build'], mode === 'force' ? '1' : undefined)
53-
expect(result.status, result.stderr).toBe(0)
54-
expect(existsSync(build)).toBe(true)
55-
expect(statSync(build).ino).toBe(inode)
56-
expect(readdirSync(build)).toEqual([])
57-
expect(existsSync(join(dev, 'state'))).toBe(true)
58-
expect(existsSync(join(outside, 'state'))).toBe(true)
59-
})
49+
it.each(['size', 'force'])(
50+
'clears only build contents by %s while preserving its mount',
51+
(mode) => {
52+
const { root, build, dev, outside } = fixture()
53+
const inode = statSync(build).ino
54+
const result = run(
55+
root,
56+
mode === 'force' ? ['--build', '--force'] : ['--build'],
57+
mode === 'force' ? '1' : undefined
58+
)
59+
expect(result.status, result.stderr).toBe(0)
60+
expect(existsSync(build)).toBe(true)
61+
expect(statSync(build).ino).toBe(inode)
62+
expect(readdirSync(build)).toEqual([])
63+
expect(existsSync(join(dev, 'state'))).toBe(true)
64+
expect(existsSync(join(outside, 'state'))).toBe(true)
65+
}
66+
)
6067

6168
it('retains useful build state without counting external symlink targets', () => {
6269
const { root, build, dev, outside } = fixture()
@@ -104,15 +111,18 @@ describe('compiler cache maintenance through the real CLI', () => {
104111
expect(existsSync(join(dev, 'state'))).toBe(true)
105112
})
106113

107-
it.each([true, false])('refuses a symlink build root when target existence is %s', (targetExists) => {
108-
const { root, build, dev, outside } = fixture()
109-
rmSync(build, { recursive: true })
110-
symlinkSync(outside, build, process.platform === 'win32' ? 'junction' : 'dir')
111-
if (!targetExists) rmSync(outside, { recursive: true })
112-
const result = run(root, ['--build', '--force'])
113-
expect(result.status, result.stderr).not.toBe(0)
114-
expect(lstatSync(build).isSymbolicLink()).toBe(true)
115-
expect(existsSync(join(outside, 'state'))).toBe(targetExists)
116-
expect(existsSync(join(dev, 'state'))).toBe(true)
117-
})
114+
it.each([true, false])(
115+
'refuses a symlink build root when target existence is %s',
116+
(targetExists) => {
117+
const { root, build, dev, outside } = fixture()
118+
rmSync(build, { recursive: true })
119+
symlinkSync(outside, build, process.platform === 'win32' ? 'junction' : 'dir')
120+
if (!targetExists) rmSync(outside, { recursive: true })
121+
const result = run(root, ['--build', '--force'])
122+
expect(result.status, result.stderr).not.toBe(0)
123+
expect(lstatSync(build).isSymbolicLink()).toBe(true)
124+
expect(existsSync(join(outside, 'state'))).toBe(targetExists)
125+
expect(existsSync(join(dev, 'state'))).toBe(true)
126+
}
127+
)
118128
})

0 commit comments

Comments
 (0)