openclaw/scripts/e2e/bun-only-runtime-smoke.sh
Peter Steinberger b9a2236578
fix(install): skip unavailable Node probes in Bun-only installs (#161512)
Preinstall probed absent or non-executable PATH Node candidates, creating Node spawn attempts during Bun-only installs. The smoke also omitted the documented Bun launcher marker and masked the resulting failure with an install-time Node fallback.

Check execute permission before probing persistent Node candidates, preserve Node engine enforcement and Bun lifecycle-shim exclusion, and make the smoke install through the documented Bun 1.4+ launcher without a Node fallback. Remove the resolved expected blocker.

Proof: 132 focused preinstall, spawn-ledger, and install-smoke workflow tests pass after a patch-identical rebase. The reviewed Linux Bun-only smoke passes all ten steps with zero preinstall Node attempts and no fallback; both classifier negative controls reject invalid blocker inventories.
2026-09-29 19:57:48 -07:00

62 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Bash 5.3+ can deadlock writing heredoc pipes on macOS before the reader starts.
if [[ ${OSTYPE:-} == darwin* && $BASH != /bin/bash ]] && ((BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3))); then
exec /bin/bash "$0" "$@"
fi
set -Eeuo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$ROOT_DIR/scripts/e2e/lib/bun-global-install/ai-candidate.sh"
PACKAGE_TGZ="${OPENCLAW_BUN_ONLY_SMOKE_PACKAGE_TGZ:?set OPENCLAW_BUN_ONLY_SMOKE_PACKAGE_TGZ}"
ARTIFACT_DIR="${OPENCLAW_BUN_ONLY_SMOKE_ARTIFACT_DIR:-$(mktemp -d "${TMPDIR:-/tmp}/openclaw-bun-only.XXXXXX")}"
mkdir -p "$ARTIFACT_DIR"
ARTIFACT_DIR="$(cd "$ARTIFACT_DIR" && pwd)"
echo "Bun-only smoke artifacts: $ARTIFACT_DIR"
BUN_BIN="$(command -v "${BUN_BIN:-bun}")"
BUN_BIN="$(node -e 'console.log(require("node:fs").realpathSync(process.argv[1]))' "$BUN_BIN")"
PACKAGE_TGZ="$(node -e 'console.log(require("node:fs").realpathSync(process.argv[1]))' "$PACKAGE_TGZ")"
AI_PACKAGE_TGZ=""
REQUIRED_REGISTRY_PACKAGES='[]'
cd "$ROOT_DIR"
mkdir -p "$ARTIFACT_DIR/pack"
prepare_ai_candidate "$PACKAGE_TGZ" "$ARTIFACT_DIR/pack"
if [[ "$REQUIRED_REGISTRY_PACKAGES" != '[]' ]]; then
echo 'Bun-only smoke requires a candidate containing bundled @openclaw/ai.' >&2
exit 1
fi
printf '' >"$ARTIFACT_DIR/sentinel-ledger.jsonl"
"$BUN_BIN" "$ROOT_DIR/scripts/e2e/lib/bun-only-runtime/sentinel.mjs" \
"$ARTIFACT_DIR/sentinel-bin" "$ARTIFACT_DIR/sentinel-ledger.jsonl"
if [[ "${OPENCLAW_BUN_ONLY_SMOKE_HIDE_SYSTEM_NODE:-0}" == 1 ]]; then
command -v unshare setpriv >/dev/null
fi
summary_env=()
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
summary_env=("GITHUB_STEP_SUMMARY=$GITHUB_STEP_SUMMARY")
fi
harness_command=(env -i \
HOME="$HOME" TMPDIR="${TMPDIR:-/tmp}" LANG="${LANG:-C.UTF-8}" CI="${CI:-1}" \
"${summary_env[@]}" \
PATH="$(dirname "$BUN_BIN"):/usr/sbin:/usr/bin:/sbin:/bin" \
BUN_BIN="$BUN_BIN" \
OPENCLAW_BUN_ONLY_SMOKE_PACKAGE_TGZ="$PACKAGE_TGZ" \
OPENCLAW_BUN_ONLY_SMOKE_ARTIFACT_DIR="$ARTIFACT_DIR" \
OPENCLAW_BUN_ONLY_SMOKE_AI_PACKAGE_TGZ="$AI_PACKAGE_TGZ" \
"$BUN_BIN" "$ROOT_DIR/scripts/e2e/lib/bun-only-runtime/harness.mjs")
if [[ "${OPENCLAW_BUN_ONLY_SMOKE_HIDE_SYSTEM_NODE:-0}" == 1 ]]; then
exec sudo -n unshare --mount --propagation private -- bash -c '
set -euo pipefail
invoking_uid=$1
invoking_gid=$2
sentinel_node=$3
shift 3
for entry in /usr/local/bin/node /usr/bin/node; do
if [[ -e "$entry" ]]; then
mount --bind "$sentinel_node" "$entry"
fi
done
exec setpriv --reuid="$invoking_uid" --regid="$invoking_gid" --init-groups -- "$@"
' bash "$(id -u)" "$(id -g)" \
"$ARTIFACT_DIR/sentinel-bin/node" "${harness_command[@]}"
fi
exec "${harness_command[@]}"