Skip to content

Commit 3220950

Browse files
committed
chore(ci): reproduce dev cache root symlink regression
1 parent f9c831b commit 3220950

5 files changed

Lines changed: 30 additions & 14 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ jobs:
102102
- uses: ./.github/actions/setup
103103
with:
104104
provider: github
105-
- name: Format and lint the repository
106-
run: bun run lint
107-
- name: Prove real config and flag hash boundaries
108-
run: python3 .github/scripts/compiler-config-proof.py
109-
- name: Prove real filesystem CLI contracts
110-
run: bun run test:scripts scripts/prune-turbopack-cache.test.ts --reporter=default --reporter=json --outputFile.json="$RUNNER_TEMP/cache-policy-tests.json"
111-
- name: Revert individual ownership guards and require red
112-
run: python3 .github/scripts/compiler-policy-mutants.py
105+
- name: Require the dev root symlink regression to fail before its fix
106+
run: |
107+
python3 - <<'PYCODE'
108+
import subprocess,json,os
109+
report=os.path.join(os.environ['RUNNER_TEMP'],'cache-policy-tests.json')
110+
r=subprocess.run(['bun','run','test:scripts','scripts/prune-turbopack-cache.test.ts','-t','unlinks a dev root symlink','--reporter=json','--outputFile.json='+report])
111+
d=json.load(open(report))
112+
assert r.returncode!=0 and d['numFailedTests']==2,d
113+
PYCODE
113114
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
114115
if: always()
115116
with:

‎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": "node ../../scripts/prune-turbopack-cache.mts",
8+
"dev:cache:cap": "bun run ../../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": "node ../../scripts/prune-turbopack-cache.mts",
13+
"dev:cache:cap": "bun run ../../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",

‎scripts/prune-turbopack-cache.mts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* run it only between compiler processes. Oversized state is discarded so the
88
* next compiler starts cold. Symlinks are neither counted nor followed.
99
*
10-
* Node's directory iterator reads bounded batches; the pinned Bun compatibility
11-
* iterator materializes whole directories. Build size checks stop above the cap.
10+
* Build maintenance uses Node's bounded directory iterator and stops counting
11+
* above the cap. Dev commands keep Bun and its existing best-effort behavior.
1212
*
13-
* Run with Node 24: `node scripts/prune-turbopack-cache.mts [--build] [--force] [--dry-run]`.
13+
* CI build maintenance runs with Node 24: `node scripts/prune-turbopack-cache.mts [--build] [--force] [--dry-run]`.
1414
* `SIM_TURBOPACK_CACHE_MAX_GB` overrides the default 20 GiB cap.
1515
*/
1616
import { existsSync, lstatSync, statSync } from 'node:fs'

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function fixture() {
3636
}
3737

3838
function run(root: string, args: string[], maximum = '0.000001') {
39-
return spawnSync('node', [script, ...args], {
39+
return spawnSync(args.includes('--build') ? 'node' : 'bun', [script, ...args], {
4040
cwd: root,
4141
encoding: 'utf8',
4242
timeout: 10_000,
@@ -107,6 +107,21 @@ describe('compiler cache maintenance through the real CLI', () => {
107107
expect(existsSync(join(outside, 'state'))).toBe(true)
108108
})
109109

110+
it.each(['size', 'force'])(
111+
'unlinks a dev root symlink by %s without traversing its target',
112+
(mode) => {
113+
const { root, build, dev, outside } = fixture()
114+
rmSync(dev, { recursive: true })
115+
symlinkSync(outside, dev, process.platform === 'win32' ? 'junction' : 'dir')
116+
const outsideBytes = readFileSync(join(outside, 'state'))
117+
const result = run(root, mode === 'force' ? ['--force'] : [], mode === 'force' ? '1' : undefined)
118+
expect(result.status, result.stderr).toBe(0)
119+
expect(readFileSync(join(outside, 'state'))).toEqual(outsideBytes)
120+
expect(existsSync(dev)).toBe(false)
121+
expect(existsSync(join(build, 'state'))).toBe(true)
122+
}
123+
)
124+
110125
it('leaves both caches intact for a build dry run', () => {
111126
const { root, build, dev } = fixture()
112127
expect(run(root, ['--build', '--dry-run']).status).toBe(0)

0 commit comments

Comments
 (0)