Repository navigation
[SURF-2672] fix(release): purge after jsDelivr's version list refreshes - #78
Conversation
|
|
||
| # The checks below decide the outcome; a file this purge missed is purged again. | ||
| - name: Purge jsDelivr cache | ||
| continue-on-error: true |
There was a problem hiding this comment.
[P2] Preserve a known purge failure when the local CDN sample is fresh
continue-on-error discards the first purge's failure, while the retry only runs for files the runner sees as stale. If one CDN provider reports a purge failure but the HEAD requests reach a provider already serving the expected version, stale is empty, both remaining steps skip, and the workflow succeeds even though customers on the failed provider can still receive old code. I reproduced this with stubbed purge responses reporting a provider failure and all four HEAD responses reporting the expected version. Preserve the failure unless the affected paths are successfully purged on retry; retry eligibility must account for failed purges as well as locally stale files. This differs from the accepted single-location sampling limitation because the purge failure is already known.
This message is written by Codex (GPT-6) on behalf of Gautam as part of the PR review.
Why
The purge loop merged in the first PR purges too early and too often.
x-jsd-versionand purging again 10 minutes later (jsdelivr/jsdelivr#18376).This follows up the first PR. The surface_forms PR waits on this workflow's run.
@latestserves the new version #77What changes
@latestfile reports, and purges once more 10 minutes later: every file still stale, and every file whose first purge failed.@mainis no longer purged. jsDelivr says purging works only for releases.How it works
Before: one job. It re-purged stale files every 10 seconds.
flowchart LR subgraph job["release-and-purge"] direction LR r["Cut release"] --> p["Purge @latest and @main"] --> w["Check versions every 10 s<br/>(up to 30 rounds)"] --> a["Purge again"] w -->|stale file| x["Purge that file"] --> w endAfter: two jobs. Stale files and files whose purge failed get one more purge, 10 minutes later.
flowchart LR subgraph release r["Cut release"] end subgraph purge direction LR p["Purge @latest"] --> c["Check versions"] p -->|purge failed| c c -->|any stale or failed| w["Wait 10 minutes,<br/>purge those files"] --> c2["Check again"] end release --> purgethrottledor when any CDN provider reports failure.Risk
@mainURLs are no longer purged.QA
Exercised locally:
curl: a clean response passes; a throttled response fails; one provider reporting failure fails; one failing URL fails after the other three are still purged.surface_tag.min.jswhile all four files already serve 1.1.19 puts only that file on the retry list; all clean and fresh gives an empty list; all clean and stale gives all four.Left for the reviewer: nothing before merge. Watch the first real release after merge.
Known gaps
Implementation details
Self review
The review of the first PR ran after it merged. Its fixes are in this PR.
@maindid nothing useful; the timeout message said 5 minutes for an ~8-minute loop; probes downloaded whole bundles instead of HEAD; checkout ran before cutting the release; the release log claimed@latestalready resolved; a comment narrated the steps. 3 declined: freshness is sampled from one CDN provider (one runner can't reach every provider; the second purge covers the rest); longer runs widen pending-run cancellation (needs three pushes within minutes, and Step 1 serializes publishes); the version probe is duplicated in surface_forms' verify (kept as an independent check from the publisher's side).Changes
.github/workflows/release-and-purge.yml:version. It no longer checks out the repo. Its log line states the tag and commit.release. It checks out withpersist-credentials: false.failed, the files whose purge failed, and writes them to the run summary. The step itself never fails.retry, the stale files merged withfailed, and writes the stale files to the run summary.retryis not empty. A failed purge fails the job.retryis not empty. Fails with the stale files named..github/scripts/purge-jsdelivr.shpurges@latestfor each file. It reads each response withjqand fails onthrottledor a provider flag that is false. It tries every file before it exits 1, prints the names of the files whose purge failed to stdout, and logs to stderr.curlhas--max-time 30,--retry 3and--retry-max-time 60..github/scripts/stale-jsdelivr-files.shprints each file whose@latestcopy does not report the given version. It sends a HEAD request with--max-time 20and readsx-jsd-version. It logs each file's version to stderr.Validation
bash -npasses on both scripts.stale-jsdelivr-files.shagainst the live CDN: version 1.1.19 → no files printed; version 1.1.20 → all four printed.purge-jsdelivr.shagainst a stubcurl: clean → exit 0 with 4 purged; throttled → exit 1; one provider false → exit 1; one URL failing → the other three still purged, exit 1.surface_tag.min.jsand all four HEAD probes return 1.1.19 →retryissurface_tag.min.js; all clean and fresh → empty; all clean and stale → all four.