Skip to content

Commit 42adcee

Browse files
committed
ci: cache the sha1-pinned font archives across runs, and outlast a longer GUST outage
1 parent 4b01d02 commit 42adcee

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ jobs:
7474
# come out of both PDFs.
7575
- name: Install poppler-utils (pdftotext)
7676
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends poppler-utils
77+
# The pinned archives, kept across runs so the steady state never reaches
78+
# the upstream font servers at all — GUST, which serves the two Latin
79+
# Modern zips, intermittently refuses connections from the runners (see
80+
# the note in `download-fonts.sh`). Safe by construction: every archive
81+
# carries a sha1 in that script, and it re-verifies a cached file before
82+
# using it, so a restored copy is checked exactly as a freshly downloaded
83+
# one is. Keyed on the script, which is where the URLs and their
84+
# checksums live, so re-pinning a font invalidates the cache.
85+
- name: Cache the pinned font archives
86+
uses: actions/cache@v4
87+
with:
88+
path: ${{ runner.temp }}/rustyfi-fontcache
89+
key: font-archives-${{ hashFiles('download-fonts.sh') }}
7790
# The corpus docs set Japanese text in the bundled IPAex fonts, so the
7891
# sha1-pinned fonts must be present (else the port falls back to base-14
7992
# and every Japanese run is unencodable).
8093
- name: Download fonts (download-fonts.sh)
8194
run: sh download-fonts.sh
95+
env:
96+
RUSTYFI_FONTCACHE: ${{ runner.temp }}/rustyfi-fontcache
8297
# The script self-skips (green) if a prerequisite is somehow absent.
8398
- name: Layout-fidelity test (vs the vendored SATySFi references)
8499
run: cargo test -p rustyfi --test layout_fidelity -- --ignored --nocapture
@@ -118,12 +133,22 @@ jobs:
118133
repository: yasuo-ozu/satysfi-xpath
119134
path: pkgs/xpath
120135

136+
# Same cache, and deliberately the same key, as the layout-fidelity job
137+
# above: whichever run populates it first spares every later one the
138+
# download.
139+
- name: Cache the pinned font archives
140+
uses: actions/cache@v4
141+
with:
142+
path: ${{ runner.temp }}/rustyfi-fontcache
143+
key: font-archives-${{ hashFiles('download-fonts.sh') }}
121144
# The faces the standard library needs, then the standard library itself,
122145
# INTO THE ROOT THE PACKAGES INSTALL INTO — the order matters. Every font
123146
# package merges its entries into the one shared
124147
# `dist/hash/fonts.satysfi-hash`, so seeding the root afterwards would
125148
# overwrite what they contributed.
126149
- name: Seed the root with the bundled standard library
150+
env:
151+
RUSTYFI_FONTCACHE: ${{ runner.temp }}/rustyfi-fontcache
127152
run: |
128153
sh download-fonts.sh
129154
mkdir -p root/dist

‎download-fonts.sh‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ download_file () {
112112
# minutes at a time — a CI run has failed on exactly that, with curl's
113113
# exit 28 after a 133-second connect timeout.
114114
#
115+
# The outage is per-ROUTE, not host-wide, so it is invisible from anywhere
116+
# else at the same moment: on run 32593970228 the `packages` job could not
117+
# connect to www.gust.org.pl three times across 70 s while, in that same
118+
# run, the `layout-fidelity` job on another runner fetched the identical
119+
# URL in 2.5 s. So there is nothing to probe and nothing to fail fast on —
120+
# only a window to outlast. The budget below is sized against that
121+
# measurement: five attempts with a doubling backoff outlast ~175 s of
122+
# unreachability (5 x 20 s of connect timeout, plus 5+10+20+40 s of sleep),
123+
# where the original three-with-a-flat-5s reached exactly the 70 s that run
124+
# took to fail and was therefore just barely too short. CI caches this whole
125+
# directory across runs (see `.github/workflows/ci.yml`), so the steady
126+
# state does not reach GUST at all and this loop only guards a cold cache.
127+
#
115128
# Retry rather than mirror: the SHA1 below is pinned, and no mirror serves
116129
# these archives byte-identically (CTAN repackages Latin Modern under its
117130
# own layout), so a fallback URL would download successfully and then fail
@@ -127,7 +140,8 @@ download_file () {
127140
# Only widely-supported options are used, since this script also runs on
128141
# whatever curl a contributor happens to have.
129142
ATTEMPT=1
130-
MAX_ATTEMPTS=3
143+
MAX_ATTEMPTS=5
144+
BACKOFF=5
131145
while : ; do
132146
if curl -fsSL --connect-timeout 20 --max-time 600 -o "$CACHE/$NAME" "$URL"; then
133147
break
@@ -137,9 +151,10 @@ download_file () {
137151
"$MAX_ATTEMPTS attempts." >&2
138152
exit 1
139153
fi
140-
show_message "download of '$NAME' failed; retrying ($ATTEMPT/$MAX_ATTEMPTS)"
154+
show_message "download of '$NAME' failed; retrying in ${BACKOFF}s ($ATTEMPT/$MAX_ATTEMPTS)"
141155
ATTEMPT=$((ATTEMPT + 1))
142-
sleep 5
156+
sleep "$BACKOFF"
157+
BACKOFF=$((BACKOFF * 2))
143158
done
144159
if ! validate_file "$NAME" "$SHA1"; then
145160
echo "$MESSAGE_PREFIX SHA1 mismatch for '$NAME' — refusing to use it." >&2

0 commit comments

Comments
 (0)