Skip to content

Commit 48a38a1

Browse files
authored
ci(migrations): confine snapshot cache lookup to a 3-day date window (#285)
* ci(migrations): confine snapshot cache lookup to a 3-day date window An unbounded prefix restore searches the PR's own ref scope before the base branch, so one stale PR-scoped snapshot shadows fresh dev-scoped ones forever (daily CI use keeps it from evicting). PR #280 was pinned to a 2026-07-10 previewnet snapshot that predates the on-chain DeregisterAnnouncementPeriod fix and permanently failed the try_state timing invariant added in #276. Both jobs now look up snapshots only under explicit dated keys (today/yesterday/day-before, UTC), so a restored snapshot is at most two days old regardless of cache scope; the nightly 5AM refresh keeps PRs from regenerating in practice. Stale branch-scoped entries become unreachable and evict naturally. * chore: minimize the docs
1 parent 037040c commit 48a38a1

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

.github/workflows/check-runtime-migration.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,29 @@ jobs:
109109
- name: Load common environment variables via env file
110110
run: cat .github/env >> $GITHUB_ENV
111111

112-
# Snapshot lookup uses a deliberately-non-matching primary `key:` so
113-
# `restore-keys` always falls through to the most recent dated entry.
114-
# With `lookup-only` the snapshot isn't restored — we just decide whether
115-
# to regenerate. `cache-matched-key` is empty iff nothing was found, which
116-
# is also the case on the daily `schedule` (lookup skipped) so the
117-
# snapshot is force-refreshed nightly.
112+
# The lookup is date-bounded because an unbounded prefix restore would
113+
# let a stale PR-scoped snapshot shadow fresh dev-scoped ones forever.
114+
# `cache-matched-key` is empty on a miss and on the nightly `schedule`
115+
# (lookup skipped), forcing a snapshot refresh.
116+
- name: Compute snapshot date window
117+
id: dates
118+
shell: bash
119+
run: |
120+
echo "today=$(/bin/date -u '+%Y%m%d')" >> "$GITHUB_OUTPUT"
121+
echo "yesterday=$(/bin/date -u -d '1 day ago' '+%Y%m%d')" >> "$GITHUB_OUTPUT"
122+
echo "daybefore=$(/bin/date -u -d '2 days ago' '+%Y%m%d')" >> "$GITHUB_OUTPUT"
123+
118124
- name: Check if snapshot exists in cache
119125
id: cache-restore
120126
if: github.event_name != 'schedule'
121127
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
122128
with:
123129
lookup-only: true
124130
path: snapshot.raw
125-
key: try-runtime-snapshot-${{ matrix.runtime.name }}
131+
key: try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.today }}
126132
restore-keys: |
127-
try-runtime-snapshot-${{ matrix.runtime.name }}-
133+
try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.yesterday }}
134+
try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.daybefore }}
128135
fail-on-cache-miss: false
129136

130137
- name: Install just
@@ -175,18 +182,12 @@ jobs:
175182
sleep 10
176183
done
177184
178-
- name: Get Date
179-
id: get-date
180-
if: steps.cache-restore.outputs.cache-matched-key == ''
181-
run: echo "today=$(/bin/date -u "+%Y%m%d")" >> "$GITHUB_OUTPUT"
182-
shell: bash
183-
184185
- name: Save snapshot to cache
185186
if: steps.cache-restore.outputs.cache-matched-key == ''
186187
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
187188
with:
188189
path: snapshot.raw
189-
key: try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.get-date.outputs.today }}
190+
key: try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.today }}
190191

191192
check-migrations:
192193
name: check-migration (${{ matrix.runtime.name }})
@@ -231,11 +232,24 @@ jobs:
231232
if: steps.try-runtime-cache.outputs.cache-hit != 'true'
232233
run: just download-try-runtime
233234

235+
# Same 3-day window as prepare-snapshots: never restore a snapshot more
236+
# than two days old, whatever ref scope it lives in.
237+
- name: Compute snapshot date window
238+
id: dates
239+
shell: bash
240+
run: |
241+
echo "today=$(/bin/date -u '+%Y%m%d')" >> "$GITHUB_OUTPUT"
242+
echo "yesterday=$(/bin/date -u -d '1 day ago' '+%Y%m%d')" >> "$GITHUB_OUTPUT"
243+
echo "daybefore=$(/bin/date -u -d '2 days ago' '+%Y%m%d')" >> "$GITHUB_OUTPUT"
244+
234245
- name: Restore snapshot from cache
235246
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
236247
with:
237248
path: snapshot.raw
238-
key: try-runtime-snapshot-${{ matrix.runtime.name }}-
249+
key: try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.today }}
250+
restore-keys: |
251+
try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.yesterday }}
252+
try-runtime-snapshot-${{ matrix.runtime.name }}-${{ steps.dates.outputs.daybefore }}
239253
fail-on-cache-miss: true
240254

241255
- name: Run ${{ matrix.runtime.name }} Runtime Checks

0 commit comments

Comments
 (0)