Skip to content

Commit c5695ce

Browse files
committed
chore(ci): diagnose nonempty snapshot replacement in isolation
1 parent a976528 commit c5695ce

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
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: verify
11+
LIFECYCLE_PHASE: replace
1212
steps:
1313
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
1414
- uses: ./.github/actions/cache
@@ -20,15 +20,23 @@ jobs:
2020
run: |
2121
python3 - <<'PYCODE'
2222
from pathlib import Path
23-
import json,os
24-
p=Path('apps/sim/.next/cache');marker=p/'lifecycle-marker';phase=os.environ['LIFECYCLE_PHASE'];entries=list(p.iterdir());report={'phase':phase,'entriesBefore':len(entries),'markerBefore':marker.exists()}
23+
import json,os,hashlib
24+
p=Path('apps/sim/.next/cache');marker=p/'lifecycle-marker';phase=os.environ['LIFECYCLE_PHASE'];entries=list(p.iterdir());report={'phase':phase,'entriesBefore':len(entries),'markerBefore':marker.exists(),'regionHash':hashlib.sha256(os.environ.get('BLACKSMITH_REGION','unset').encode()).hexdigest()}
2525
try:
2626
if phase=='write':
2727
assert not entries,'Prior completed run did not publish an empty cache'
2828
marker.write_text('owned-cache-lifecycle-proof')
2929
elif phase=='delete':
3030
assert marker.read_text()=='owned-cache-lifecycle-proof','Previous completed run did not publish the marker'
3131
marker.unlink()
32+
elif phase=='replace':
33+
assert marker.read_text()=='owned-cache-lifecycle-proof'
34+
marker.unlink()
35+
(p/'retained-state').write_text('owned replacement snapshot\n'*200)
36+
elif phase=='verify-replacement':
37+
assert not marker.exists(),'Old marker returned after nonempty replacement'
38+
assert (p/'retained-state').read_text()=='owned replacement snapshot\n'*200
39+
assert len(entries)==1
3240
elif phase=='verify':
3341
assert not entries,'Deleted marker returned across completed workflow runs'
3442
else:raise AssertionError('Unknown lifecycle phase')

0 commit comments

Comments
 (0)