Skip to content

Commit 5e0cc20

Browse files
committed
chore(ci): prove cache opt-in before implementation and rejected writes
1 parent eeb8ed9 commit 5e0cc20

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os,json,subprocess
2+
from pathlib import Path
3+
root=Path.cwd()
4+
report={'config':[]}
5+
def config(value):
6+
env=dict(os.environ)
7+
if value is None:env.pop('NEXT_BUILD_PERSISTENT_CACHE',None)
8+
else:env['NEXT_BUILD_PERSISTENT_CACHE']=value
9+
code="import config from './next.config.ts'; process.stdout.write(JSON.stringify({cache:config.experimental?.turbopackFileSystemCacheForBuild}));"
10+
r=subprocess.run(['bun','--no-env-file','-e',code],cwd=root/'apps/sim',env=env,capture_output=True,text=True,check=True)
11+
return json.loads(r.stdout)['cache']
12+
try:
13+
for value,expected in [(None,False),('false',False),('true',True)]:
14+
actual=config(value);report['config'].append({'flag':value,'expected':expected,'actual':actual});assert actual==expected,'Explicit compiler cache opt-in did not enable the cache'
15+
def task_hash(value):
16+
env={**os.environ,'NEXT_BUILD_PERSISTENT_CACHE':value}
17+
r=subprocess.run(['bunx','turbo','run','build','--filter=@sim/app','--dry=json'],env=env,capture_output=True,text=True,check=True)
18+
tasks=json.loads(r.stdout)['tasks'];return next(t['hash'] for t in tasks if t['taskId']=='@sim/app#build')
19+
report['hashes']={v:task_hash(v) for v in ['true','false']};assert len(set(report['hashes'].values()))==2,'Compiler cache modes share a build cache key'
20+
p=root/'apps/sim/turbo.json';original=p.read_bytes()
21+
try:
22+
d=json.loads(original);d['tasks']['build']['env'].remove('NEXT_BUILD_PERSISTENT_CACHE');p.write_text(json.dumps(d))
23+
report['missingGuardHashes']={v:task_hash(v) for v in ['true','false']};assert len(set(report['missingGuardHashes'].values()))==1,'Expected removed cache guard to lose flag distinction'
24+
finally:p.write_bytes(original)
25+
finally:
26+
Path(os.environ['RUNNER_TEMP'],'compiler-config-report.json').write_text(json.dumps(report,indent=2))
27+
print(json.dumps(report,indent=2))

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
lifecycle:
99
runs-on: blacksmith-2vcpu-ubuntu-2404
1010
env:
11-
LIFECYCLE_PHASE: fail
11+
LIFECYCLE_PHASE: verify-rejection
1212
steps:
1313
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
1414
- uses: ./.github/actions/cache
@@ -71,3 +71,22 @@ jobs:
7171
with:
7272
name: cross-run-lifecycle
7373
path: ${{ runner.temp }}/cross-run-lifecycle.json
74+
config:
75+
runs-on: ubuntu-24.04
76+
timeout-minutes: 15
77+
env:
78+
NEXT_PUBLIC_APP_URL: http://localhost:3000
79+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/sim_test
80+
NEXT_BUILD_SKIP_TYPE_CHECK: 'true'
81+
NEXT_BUILD_SKIP_SOURCE_MAPS: 'true'
82+
steps:
83+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
84+
- uses: ./.github/actions/setup
85+
with:
86+
provider: github
87+
- run: python3 .github/scripts/compiler-config-proof.py
88+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
89+
if: always()
90+
with:
91+
name: compiler-config-proof
92+
path: ${{ runner.temp }}/compiler-config-report.json

0 commit comments

Comments
 (0)