mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
67c5a85619
* fix(release): bind prerelease plugins into package Telegram QA * fix(release): preserve registry artifact provenance
185 lines
7.4 KiB
Bash
Executable File
185 lines
7.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Installs a prepared OpenClaw npm tarball in Docker, runs OpenAI onboarding,
|
|
# and verifies the Codex plugin plus @openai/codex dependency are downloaded on demand.
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh"
|
|
source "$ROOT_DIR/scripts/lib/docker-e2e-package.sh"
|
|
|
|
IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-codex-on-demand-e2e" OPENCLAW_CODEX_ON_DEMAND_E2E_IMAGE)"
|
|
DOCKER_TARGET="${OPENCLAW_CODEX_ON_DEMAND_DOCKER_TARGET:-bare}"
|
|
HOST_BUILD="${OPENCLAW_CODEX_ON_DEMAND_HOST_BUILD:-1}"
|
|
PACKAGE_TGZ="${OPENCLAW_CURRENT_PACKAGE_TGZ:-}"
|
|
PREPUBLISH_PLUGIN_REGISTRY_ARGS=()
|
|
AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT=""
|
|
run_log=""
|
|
|
|
# This lane installs the package and then exercises a managed npm install of Codex.
|
|
# Keep the package install budget above the shared default so slow npm hosts reach
|
|
# the Codex assertions instead of failing as a silent package-install timeout.
|
|
export OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-1200s}"
|
|
|
|
configure_prepublish_plugin_registry() {
|
|
local registry_dir="$1"
|
|
local resolved_registry_dir
|
|
resolved_registry_dir="$(cd "$registry_dir" && pwd)"
|
|
local manifest="$resolved_registry_dir/prepublish-plugin-registry.json"
|
|
if [ ! -f "$manifest" ]; then
|
|
echo "Prepublish plugin registry manifest is missing." >&2
|
|
exit 1
|
|
fi
|
|
local source_sha="${OPENCLAW_DOCKER_E2E_SELECTED_SHA:-}"
|
|
local candidate_version="${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_CANDIDATE_VERSION:-}"
|
|
local manifest_sha256="${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_MANIFEST_SHA256:-}"
|
|
source_sha="${source_sha:-$(node -e 'process.stdout.write(require(process.argv[1]).sourceSha)' "$manifest")}"
|
|
candidate_version="${candidate_version:-$(node -e 'process.stdout.write(require(process.argv[1]).candidateVersion)' "$manifest")}"
|
|
if [ -z "$manifest_sha256" ]; then
|
|
manifest_sha256="$(node -e 'const fs=require("node:fs"),crypto=require("node:crypto");process.stdout.write(crypto.createHash("sha256").update(fs.readFileSync(process.argv[1])).digest("hex"))' "$manifest")"
|
|
fi
|
|
PREPUBLISH_PLUGIN_REGISTRY_ARGS=(
|
|
-e OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR=/tmp/openclaw-prepublish-plugin-registry
|
|
-e OPENCLAW_DOCKER_E2E_SELECTED_SHA="$source_sha"
|
|
-e OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_CANDIDATE_VERSION="$candidate_version"
|
|
-e OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_MANIFEST_SHA256="$manifest_sha256"
|
|
-v "$resolved_registry_dir:/tmp/openclaw-prepublish-plugin-registry:ro"
|
|
)
|
|
}
|
|
if [ -n "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ]; then
|
|
configure_prepublish_plugin_registry "$OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR"
|
|
fi
|
|
|
|
cleanup() {
|
|
if [ -n "${PACKAGE_TGZ:-}" ]; then
|
|
docker_e2e_cleanup_package_tgz "$PACKAGE_TGZ"
|
|
fi
|
|
if [ -n "$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT" ]; then
|
|
rm -rf "$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT"
|
|
fi
|
|
if [ -n "${run_log:-}" ]; then
|
|
rm -f "$run_log"
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
docker_e2e_build_or_reuse "$IMAGE_NAME" codex-on-demand "$ROOT_DIR/scripts/e2e/Dockerfile" "$ROOT_DIR" "$DOCKER_TARGET"
|
|
|
|
prepare_package_tgz() {
|
|
if [ -n "$PACKAGE_TGZ" ]; then
|
|
PACKAGE_TGZ="$(docker_e2e_prepare_package_tgz codex-on-demand "$PACKAGE_TGZ")"
|
|
return 0
|
|
fi
|
|
if [ "$HOST_BUILD" = "0" ] && [ -z "${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" ]; then
|
|
echo "OPENCLAW_CODEX_ON_DEMAND_HOST_BUILD=0 requires OPENCLAW_CURRENT_PACKAGE_TGZ" >&2
|
|
exit 1
|
|
fi
|
|
PACKAGE_TGZ="$(docker_e2e_prepare_package_tgz codex-on-demand)"
|
|
}
|
|
|
|
prepare_package_tgz
|
|
|
|
if [ -z "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ] &&
|
|
[ -z "${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" ] &&
|
|
[ "$HOST_BUILD" != "0" ]; then
|
|
AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT="$(
|
|
mktemp -d "${TMPDIR:-/tmp}/openclaw-codex-on-demand-plugin-registry.XXXXXX"
|
|
)"
|
|
OPENCLAW_DOCKER_ALL_LANES=codex-on-demand \
|
|
OPENCLAW_DOCKER_ALL_LOG_DIR="$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT" \
|
|
OPENCLAW_DOCKER_ALL_TIMINGS=0 \
|
|
node "$ROOT_DIR/scripts/test-docker-all.mjs" --prepare-plugin-registry >/dev/null
|
|
configure_prepublish_plugin_registry \
|
|
"$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT/prepublish-plugin-registry"
|
|
fi
|
|
|
|
docker_e2e_package_mount_args "$PACKAGE_TGZ"
|
|
run_log="$(docker_e2e_run_log codex-on-demand)"
|
|
OPENCLAW_TEST_STATE_SCRIPT_B64="$(docker_e2e_test_state_shell_b64 codex-on-demand empty)"
|
|
|
|
echo "Running Codex on-demand Docker E2E..."
|
|
if ! docker_e2e_run_with_harness \
|
|
-e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
|
|
-e "OPENCLAW_TEST_STATE_SCRIPT_B64=$OPENCLAW_TEST_STATE_SCRIPT_B64" \
|
|
${PREPUBLISH_PLUGIN_REGISTRY_ARGS[@]+"${PREPUBLISH_PLUGIN_REGISTRY_ARGS[@]}"} \
|
|
"${DOCKER_E2E_PACKAGE_ARGS[@]}" \
|
|
-i "$IMAGE_NAME" bash -s >"$run_log" 2>&1 <<'EOF'; then
|
|
set -euo pipefail
|
|
|
|
source scripts/lib/openclaw-e2e-instance.sh
|
|
source scripts/e2e/lib/prepublish-plugin-registry.sh
|
|
openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_SCRIPT_B64:?missing OPENCLAW_TEST_STATE_SCRIPT_B64}"
|
|
export NPM_CONFIG_PREFIX="$HOME/.npm-global"
|
|
export npm_config_prefix="$NPM_CONFIG_PREFIX"
|
|
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
|
export NPM_CONFIG_CACHE="${NPM_CONFIG_CACHE:-$XDG_CACHE_HOME/npm}"
|
|
export npm_config_cache="$NPM_CONFIG_CACHE"
|
|
export PATH="$NPM_CONFIG_PREFIX/bin:$PATH"
|
|
export OPENAI_API_KEY="sk-openclaw-codex-on-demand-e2e"
|
|
|
|
dump_debug_logs() {
|
|
local status="$1"
|
|
echo "Codex on-demand scenario failed with exit code $status" >&2
|
|
openclaw_e2e_dump_logs \
|
|
/tmp/openclaw-install.log \
|
|
/tmp/openclaw-codex-registry/server.log \
|
|
/tmp/openclaw-onboard.json \
|
|
/tmp/openclaw-plugins-list.json \
|
|
/tmp/openclaw-codex-inspect.json
|
|
}
|
|
trap 'status=$?; dump_debug_logs "$status"; exit "$status"' ERR
|
|
|
|
plugin_registry_pid=""
|
|
cleanup_inner() {
|
|
openclaw_e2e_stop_process "${plugin_registry_pid:-}"
|
|
}
|
|
trap cleanup_inner EXIT
|
|
|
|
configure_plugin_registry() {
|
|
[ -n "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ] || return 0
|
|
local registry_root="/tmp/openclaw-codex-registry"
|
|
OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_REQUIRED_PACKAGES_JSON='["@openclaw/codex"]' \
|
|
openclaw_prepublish_plugin_registry_start \
|
|
"$OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR" \
|
|
"${OPENCLAW_DOCKER_E2E_SELECTED_SHA:?missing selected SHA}" \
|
|
"${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_CANDIDATE_VERSION:?missing candidate version}" \
|
|
"${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_MANIFEST_SHA256:?missing manifest SHA-256}" \
|
|
"$registry_root" \
|
|
plugin_registry_pid
|
|
}
|
|
|
|
mkdir -p "$NPM_CONFIG_PREFIX" "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE"
|
|
chmod 700 "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE" || true
|
|
|
|
openclaw_e2e_install_package /tmp/openclaw-install.log
|
|
command -v openclaw >/dev/null
|
|
openclaw_e2e_enable_openclaw_cli_timeout
|
|
|
|
openclaw_e2e_assert_dep_absent "@openclaw/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
|
|
openclaw_e2e_assert_dep_absent "@openai/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
|
|
|
|
configure_plugin_registry
|
|
|
|
echo "Running non-interactive OpenAI onboarding; Codex should install on demand..."
|
|
openclaw onboard --non-interactive --accept-risk \
|
|
--mode local \
|
|
--auth-choice openai-api-key \
|
|
--secret-input-mode ref \
|
|
--skip-daemon \
|
|
--skip-ui \
|
|
--skip-channels \
|
|
--skip-skills \
|
|
--skip-health \
|
|
--json >/tmp/openclaw-onboard.json
|
|
|
|
openclaw plugins list --json >/tmp/openclaw-plugins-list.json
|
|
openclaw plugins inspect codex --runtime --json >/tmp/openclaw-codex-inspect.json
|
|
node scripts/e2e/lib/codex-on-demand/assertions.mjs
|
|
|
|
echo "Codex on-demand Docker E2E passed"
|
|
EOF
|
|
docker_e2e_print_log "$run_log"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Codex on-demand Docker E2E passed"
|