Skip to content

Commit 2c1c996

Browse files
committed
chore(ci): qualify safe dev root unlink and final cache policy
1 parent 3220950 commit 2c1c996

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ def case(name,old,new,pattern):
1616
case('failure','if (BUILD_CACHE) process.exitCode = 1','if (false) process.exitCode = 1','refuses a symlink|rejects a non-directory ancestor')
1717
case('external',"if (entry.isDirectory()) {\n total +=","if (entry.isDirectory() || entry.isSymbolicLink()) {\n total +=",'retains useful build state')
1818
case('mount',"await clearDirectory(CACHE_DIR)","await rm(CACHE_DIR, { recursive: true, force: true })",'clears only build contents')
19+
case('dev-root',"if (!BUILD_CACHE && lstatSync(CACHE_DIR).isSymbolicLink())", "if (false)",'unlinks a dev root symlink')
20+
1921
(out/'mutant-summary.json').write_text(json.dumps(results,indent=2));print(json.dumps(results))

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,14 @@ jobs:
102102
- uses: ./.github/actions/setup
103103
with:
104104
provider: github
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
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
114113
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
115114
if: always()
116115
with:

‎scripts/prune-turbopack-cache.mts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Dev maintenance is best effort and never blocks startup. `--build` selects
66
* `.next/cache`, preserves its mounted root, and fails on maintenance errors;
77
* run it only between compiler processes. Oversized state is discarded so the
8-
* next compiler starts cold. Symlinks are neither counted nor followed.
8+
* next compiler starts cold. Child symlinks are neither counted nor followed.
99
*
1010
* Build maintenance uses Node's bounded directory iterator and stops counting
1111
* above the cap. Dev commands keep Bun and its existing best-effort behavior.
@@ -127,6 +127,10 @@ async function main() {
127127
}
128128

129129
console.log(`[turbopack-cache] ${sizeLabel} is ${reason} — pruning; next start recompiles cold`)
130+
if (!BUILD_CACHE && lstatSync(CACHE_DIR).isSymbolicLink()) {
131+
await rm(CACHE_DIR, { force: true })
132+
return
133+
}
130134
await clearDirectory(CACHE_DIR)
131135
if (!BUILD_CACHE) await rmdir(CACHE_DIR)
132136
}

0 commit comments

Comments
 (0)