Skip to content

Commit ab59ae1

Browse files
zsoerenmclaude
andcommitted
fix: add rolldown shim, native rebuild, and A2UI bundle to test build
Cherry-picked from openclaw#63: - Move STDENV_SETUP validation before pnpm install - Add chmod -R u+w node_modules for writable deps - Add pnpm rebuild step for native dependencies - Add rolldown PATH shim (same as gateway-build.sh) - Add A2UI bundle build for canvas auth test paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bfdae71 commit ab59ae1

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

nix/scripts/gateway-tests-build.sh

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ if [ -z "${GATEWAY_PREBUILD_SH:-}" ]; then
2222
exit 1
2323
fi
2424
. "$GATEWAY_PREBUILD_SH"
25+
if [ -z "${STDENV_SETUP:-}" ]; then
26+
echo "STDENV_SETUP is not set" >&2
27+
exit 1
28+
fi
29+
if [ ! -f "$STDENV_SETUP" ]; then
30+
echo "STDENV_SETUP not found: $STDENV_SETUP" >&2
31+
exit 1
32+
fi
2533

2634
store_path_file="${PNPM_STORE_PATH_FILE:-.pnpm-store-path}"
2735
if [ ! -f "$store_path_file" ]; then
@@ -37,13 +45,42 @@ export HOME="$(mktemp -d)"
3745

3846
log_step "pnpm install (tests/config)" pnpm install --offline --frozen-lockfile --ignore-scripts --store-dir "$store_path"
3947

40-
if [ -z "${STDENV_SETUP:-}" ]; then
41-
echo "STDENV_SETUP is not set" >&2
42-
exit 1
43-
fi
44-
if [ ! -f "$STDENV_SETUP" ]; then
45-
echo "STDENV_SETUP not found: $STDENV_SETUP" >&2
46-
exit 1
48+
log_step "chmod node_modules writable" chmod -R u+w node_modules
49+
50+
# Rebuild native deps so rolldown (and other native modules) work.
51+
rebuild_list="$(jq -r '.pnpm.onlyBuiltDependencies // [] | .[]' package.json 2>/dev/null || true)"
52+
if [ -n "$rebuild_list" ]; then
53+
log_step "pnpm rebuild (onlyBuiltDependencies)" env \
54+
NODE_LLAMA_CPP_SKIP_DOWNLOAD=1 \
55+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \
56+
PUPPETEER_SKIP_DOWNLOAD=1 \
57+
ELECTRON_SKIP_BINARY_DOWNLOAD=1 \
58+
pnpm rebuild $rebuild_list
59+
else
60+
log_step "pnpm rebuild (all)" env \
61+
NODE_LLAMA_CPP_SKIP_DOWNLOAD=1 \
62+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \
63+
PUPPETEER_SKIP_DOWNLOAD=1 \
64+
ELECTRON_SKIP_BINARY_DOWNLOAD=1 \
65+
pnpm rebuild
4766
fi
4867

4968
log_step "patchShebangs node_modules/.bin" bash -e -c ". \"$STDENV_SETUP\"; patchShebangs node_modules/.bin"
69+
70+
# rolldown was removed from upstream direct dependencies (v2026.2.21+) but
71+
# remains in the pnpm store as a transitive dep (via rolldown-plugin-dts).
72+
# Upstream's bundle-a2ui.sh falls back to `pnpm dlx` which needs network.
73+
# Put rolldown on PATH so the script finds it directly.
74+
if ! command -v rolldown >/dev/null 2>&1; then
75+
_rolldown_pkg="$(find node_modules/.pnpm -maxdepth 4 -path '*/rolldown@*/node_modules/rolldown' -print -quit 2>/dev/null || true)"
76+
if [ -n "$_rolldown_pkg" ] && [ -f "$_rolldown_pkg/bin/cli.mjs" ]; then
77+
_rolldown_shim="$(mktemp -d)"
78+
printf '#!/bin/sh\nexec node "%s/bin/cli.mjs" "$@"\n' "$_rolldown_pkg" > "$_rolldown_shim/rolldown"
79+
chmod +x "$_rolldown_shim/rolldown"
80+
export PATH="$_rolldown_shim:$PATH"
81+
fi
82+
fi
83+
84+
# Build A2UI bundle so gateway tests that exercise canvas auth paths
85+
# can serve real assets instead of returning 503.
86+
log_step "build: canvas:a2ui:bundle" pnpm canvas:a2ui:bundle

0 commit comments

Comments
 (0)