Skip to content

Commit 4769891

Browse files
thefallentreeclaude
andcommitted
pages: smoke-test what was actually repacked; index shows last-changed commit, source link, admin account
The boot smoke test was hardcoded to always boot dongfanggushi2, which provides no regression coverage on the common case where that lib wasn't touched this run. It now boot-checks the libs build_site.sh actually repacked (all of them up to 10; an even sample of 10 with the skipped set logged for a full rebuild; a known-good fallback lib on a pure cache hit). The index page now shows, per lib: the last commit that changed it (linked to GitHub, tracked durably in lib-commits.json via the GitHub commits API since the shallow CI clone has no usable history), a link to the lib's source directory, and the pre-seeded admin account parsed from each lib's own README (the AGENTS.md §1.5 convention is fluffos/Mud@2026, but a few libs use a variant id or have no seeded account). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VyQCUoTo1Z93Py9aVFHQi1
1 parent a9255ae commit 4769891

4 files changed

Lines changed: 369 additions & 29 deletions

File tree

.github/workflows/pages.yml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
# via emscripten's file_packager, config rewritten to the in-memory
1010
# mount, per-lib page patched to load the driver from ONE shared copy
1111
# at site/_driver/ instead of duplicating ~3.5MB x 90 libs).
12-
# 3. scripts/gen_site_index.py renders the index (game names from each
13-
# lib's README.md, playable/limited/noboot status derived from
14-
# the checked-in scripts/wasm_status.json status mapping).
15-
# 4. Upload site/ as the Pages artifact and deploy.
12+
# 3. scripts/gen_site_index.py renders the index (game names, admin
13+
# credentials from each lib's README.md, playable/limited/noboot
14+
# status derived from the checked-in scripts/wasm_status.json status
15+
# mapping, per-lib last-changed commit links from lib-commits.json --
16+
# maintained by scripts/update_lib_commits.py via the GitHub commits
17+
# API, because this shallow clone has no history to derive it from).
18+
# 4. Boot-check the bundles this run actually repacked (see that step's
19+
# comment for the sampling policy), upload site/ as the Pages
20+
# artifact, and deploy.
1621
#
1722
# INCREMENTAL packing -- two mechanisms with distinct roles:
1823
#
@@ -147,18 +152,60 @@ jobs:
147152
id: build
148153
env:
149154
LAST_PUBLISHED_SHA: ${{ steps.marker.outputs.sha }}
155+
# for update_lib_commits.py's GitHub commits API queries
156+
# (per-lib last-changed info on the index cards)
157+
GH_TOKEN: ${{ github.token }}
150158
run: |
151159
scripts/build_site.sh "$RUNNER_TEMP/wasm-release/rel" \
152160
"${{ steps.driver.outputs.tag }}" \
153161
"$RUNNER_TEMP/packed-cache" site
154162
155-
# Boot one packed bundle inside the WASM driver under node -- proves
156-
# the trimmed, packed image + release driver actually start a game
163+
# Boot packed bundles inside the WASM driver under node -- proves the
164+
# trimmed, packed images + release driver actually start a game
157165
# (catches over-trimming and packer/driver drift before deploying).
158-
- name: Boot smoke test (packed image under node)
166+
# Tested set = the libs THIS run actually repacked (a hardcoded lib
167+
# proves nothing on the typical run where it was reused from cache):
168+
# - 1..10 repacked: boot-check every one of them.
169+
# - >10 (e.g. full rebuild after a driver/packer bump): boot-check
170+
# an even sample of 10 across the sorted list (first and last
171+
# always included) -- the regressions a full rebuild risks are
172+
# global (driver/packer drift), so any sample catches them, and
173+
# 97 serial boots would cost up to ~1.5h of CI. The skipped
174+
# slugs are logged explicitly (no silent caps).
175+
# - 0 repacked (pure cache reuse): nothing NEW to verify, but boot
176+
# one known-good lib anyway as a cheap sanity check that the
177+
# restored cached bundles still run under the freshly downloaded
178+
# driver (the driver is re-fetched every run even when no lib
179+
# changed).
180+
- name: Boot smoke test (repacked images under node)
181+
env:
182+
REPACKED_SLUGS: ${{ steps.build.outputs.repacked_slugs }}
159183
run: |
160-
node scripts/wasm_boot_check.js site/dongfanggushi2 site/_driver \
161-
--timeout 60
184+
set -euo pipefail
185+
read -r -a all <<< "$REPACKED_SLUGS"
186+
if [ "${#all[@]}" -eq 0 ]; then
187+
fallback=dongfanggushi2
188+
if [ ! -d "site/$fallback" ]; then
189+
fallback=$(basename "$(ls -d site/*/ | grep -v /_driver/ | head -1)")
190+
fi
191+
echo "nothing repacked this run; sanity-booting known-good $fallback"
192+
pick=("$fallback")
193+
elif [ "${#all[@]}" -le 10 ]; then
194+
echo "boot-checking all ${#all[@]} repacked libs: ${all[*]}"
195+
pick=("${all[@]}")
196+
else
197+
mapfile -t pick < <(printf '%s\n' "${all[@]}" | python3 -c 'import sys; s = [l.strip() for l in sys.stdin if l.strip()]; n = len(s); k = 10; idx = sorted({round(i * (n - 1) / (k - 1)) for i in range(k)}); print("\n".join(s[i] for i in idx))')
198+
skipped=$(comm -13 <(printf '%s\n' "${pick[@]}" | sort) \
199+
<(printf '%s\n' "${all[@]}" | sort) | tr '\n' ' ')
200+
echo "boot-checking an even sample of ${#pick[@]} of the" \
201+
"${#all[@]} repacked libs: ${pick[*]}"
202+
echo "NOT boot-checked this run: $skipped"
203+
fi
204+
for s in "${pick[@]}"; do
205+
echo "== boot check: $s"
206+
node scripts/wasm_boot_check.js "site/$s" site/_driver \
207+
--timeout 60
208+
done
162209
163210
- name: Save packed-lib cache
164211
if: steps.build.outputs.changed != '0'

scripts/build_site.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,21 @@
5151
# repacked. Bundles for slugs that no longer exist (or turned noboot)
5252
# are pruned.
5353
#
54-
# Outputs (for CI): appends "repacked=<n>" and "changed=<n>" to
55-
# $GITHUB_OUTPUT when set (changed = repacked + pruned, i.e. whether the
56-
# cache is worth re-saving).
54+
# The cache dir also carries lib-commits.json -- slug -> the last commit
55+
# that actually changed libs/<slug> (shown on the index cards), maintained
56+
# by scripts/update_lib_commits.py via the GitHub commits API because the
57+
# shallow CI clone has no usable history. Same durable-anchor/disposable-
58+
# cache split as above: entries self-validate against the slug's current
59+
# tree hash, so a lost or evicted cache only costs API re-queries, never
60+
# wrong data (see that script's header for the full model).
61+
#
62+
# Outputs (for CI): appends "repacked=<n>", "changed=<n>" and
63+
# "repacked_slugs=<space-separated slugs>" to $GITHUB_OUTPUT when set
64+
# (changed = repacked + pruned, i.e. whether the cache is worth re-saving;
65+
# a lib-commits.json refresh alone deliberately does NOT count -- re-saving
66+
# the ~2GB cache to persist a ~10KB mapping costs more than the API
67+
# re-queries it would save. repacked_slugs drives the boot smoke test:
68+
# CI boot-checks what was actually repacked this run, not a fixed lib).
5769

5870
set -euo pipefail
5971

@@ -78,6 +90,9 @@ mkdir -p "$CACHE_DIR/packed"
7890
MANIFEST="$CACHE_DIR/manifest.json"
7991

8092
# --- 1. derive per-lib WASM status (also writes scripts/wasm_status.json) ---
93+
# (this early run exists for the status JSON, which the slug list below
94+
# needs; the index it renders is provisional -- step 7 re-renders it with
95+
# the freshly updated per-lib last-changed mapping)
8196
python3 "$SELF_DIR/gen_site_index.py" --out "$CACHE_DIR/index-staging"
8297

8398
# Packable slugs: everything except noboot (a noboot lib gets no link on the
@@ -150,6 +165,7 @@ fi
150165

151166
# --- 4. repack libs changed since last publish (or lacking a valid bundle) --
152167
REPACKED=0
168+
REPACKED_SLUGS=""
153169
REUSED=0
154170
NEW_MANIFEST_LIBS=$(mktemp)
155171
trap 'rm -f "$NEW_MANIFEST_LIBS"' EXIT
@@ -179,6 +195,7 @@ for slug in $SLUGS; do
179195
"$SELF_DIR/pack_lib_for_web.sh" "$slug" "$RELEASE_DIR" "$RELEASE_DIR" \
180196
"$CACHE_DIR/packed/$slug"
181197
REPACKED=$((REPACKED + 1))
198+
REPACKED_SLUGS="$REPACKED_SLUGS$slug "
182199
done
183200

184201
# --- 5. prune bundles whose slug is gone / no longer packable ---------------
@@ -206,7 +223,20 @@ out = {'driver_tag': sys.argv[2], 'packer': sys.argv[3], 'libs': libs}
206223
json.dump(out, open(sys.argv[1], 'w'), indent=1, sort_keys=True)
207224
PYEOF
208225

209-
# --- 7. assemble the site ----------------------------------------------------
226+
# --- 7. per-lib "last changed" mapping + final index render -----------------
227+
# Refresh lib-commits.json (slug -> last commit that changed libs/<slug>,
228+
# via the GitHub commits API pinned to HEAD -- see update_lib_commits.py's
229+
# header for why the shallow clone forces this and why a lost cache is
230+
# harmless), then re-render the index with that info on the cards. The
231+
# update never fails the build: last-changed info is cosmetic, and a card
232+
# without it beats a blocked deploy.
233+
python3 "$SELF_DIR/update_lib_commits.py" \
234+
--mapping "$CACHE_DIR/lib-commits.json" \
235+
--head "$(git -C "$REPO" rev-parse HEAD)"
236+
python3 "$SELF_DIR/gen_site_index.py" --out "$CACHE_DIR/index-staging" \
237+
--commits "$CACHE_DIR/lib-commits.json"
238+
239+
# --- 8. assemble the site ----------------------------------------------------
210240
rm -rf "$SITE_DIR"
211241
mkdir -p "$SITE_DIR/_driver"
212242
cp "$RELEASE_DIR/fluffos.js" "$RELEASE_DIR/fluffos.wasm" \
@@ -220,7 +250,7 @@ done
220250
cp "$CACHE_DIR/index-staging/index.html" "$SITE_DIR/index.html"
221251
touch "$SITE_DIR/.nojekyll"
222252

223-
# --- 8. summary --------------------------------------------------------------
253+
# --- 9. summary --------------------------------------------------------------
224254
echo
225255
echo "== per-lib packed sizes =="
226256
du -sm "$SITE_DIR"/*/ | sort -n
@@ -231,5 +261,6 @@ if [ -n "${GITHUB_OUTPUT:-}" ]; then
231261
{
232262
echo "repacked=$REPACKED"
233263
echo "changed=$((REPACKED + PRUNED))"
264+
echo "repacked_slugs=${REPACKED_SLUGS% }"
234265
} >> "$GITHUB_OUTPUT"
235266
fi

0 commit comments

Comments
 (0)