From 8ca6d3c767aa8817d471857b23c0d78657d815a2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 19 Nov 2026 20:19:35 +0000 Subject: [PATCH] web CI: skip wasm-opt --converge on pull requests --- .github/workflows/ci.yml | 4 ++++ packaging/web/package.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee0666206e..139e58bebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -426,6 +426,10 @@ jobs: # package.sh runs Trunk's release builds, validates relative URLs, cuts the wasm into # parts, checks the 24 MiB per-file limit and exercises the packaging step release.yml uses. - name: Build and verify browser release + env: + # Pull requests skip wasm-opt --converge (minutes slower); main keeps it, so the size + # gate on a PR measures a slightly larger wasm than main produces. + PHOTOCRAFT_WEB_WASM_OPT_CONVERGE: ${{ github.event_name == 'pull_request' && '0' || '1' }} run: packaging/web/package.sh - name: Report wasm size if: success() diff --git a/packaging/web/package.sh b/packaging/web/package.sh index ccb06aded3..3bebe72c32 100755 --- a/packaging/web/package.sh +++ b/packaging/web/package.sh @@ -17,6 +17,18 @@ HERE="$ROOT/packaging/web" if [[ "${1:-}" != "--skip-build" ]]; then command -v trunk >/dev/null || { echo "error: trunk not found (cargo install trunk --locked)" >&2; exit 1; } + # wasm-opt's --converge repeats its passes until the size stops shrinking, which adds minutes. + # PHOTOCRAFT_WEB_WASM_OPT_CONVERGE=0 (pull-request CI) builds without it: the wasm is slightly + # larger than a release build produces. Trunk reads the flag only from index.html, so the + # attribute is removed for the build and the file restored afterwards. + INDEX="$ROOT/apps/photocraft-web/index.html" + if [[ "${PHOTOCRAFT_WEB_WASM_OPT_CONVERGE:-1}" == "0" ]]; then + cp "$INDEX" "$INDEX.orig" + trap 'mv -f "$INDEX.orig" "$INDEX"' EXIT + sed -i.sed 's| data-wasm-opt-params="--converge"||' "$INDEX" + rm -f "$INDEX.sed" + grep -q -- '--converge' "$INDEX" && { echo "error: --converge still in $INDEX" >&2; exit 1; } + fi (cd "$ROOT/apps/photocraft-web" && trunk build --release) (cd "$ROOT/apps/photocraft-web-boot" && trunk build --release) fi