diff --git a/scripts/e2e/codex-on-demand-docker.sh b/scripts/e2e/codex-on-demand-docker.sh index 8518962d0c4..a50f1109b8b 100755 --- a/scripts/e2e/codex-on-demand-docker.sh +++ b/scripts/e2e/codex-on-demand-docker.sh @@ -11,6 +11,17 @@ IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-codex-on-demand-e2e" OPENCLAW_C DOCKER_TARGET="${OPENCLAW_CODEX_ON_DEMAND_DOCKER_TARGET:-bare}" HOST_BUILD="${OPENCLAW_CODEX_ON_DEMAND_HOST_BUILD:-1}" PACKAGE_TGZ="${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" +run_log="" + +cleanup() { + if [ -n "${PACKAGE_TGZ:-}" ]; then + docker_e2e_cleanup_package_tgz "$PACKAGE_TGZ" + 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" @@ -89,9 +100,7 @@ node scripts/e2e/lib/codex-on-demand/assertions.mjs echo "Codex on-demand Docker E2E passed" EOF docker_e2e_print_log "$run_log" - rm -f "$run_log" exit 1 fi -rm -f "$run_log" echo "Codex on-demand Docker E2E passed" diff --git a/scripts/e2e/live-plugin-tool-docker.sh b/scripts/e2e/live-plugin-tool-docker.sh index d618436c717..b16433cee8e 100755 --- a/scripts/e2e/live-plugin-tool-docker.sh +++ b/scripts/e2e/live-plugin-tool-docker.sh @@ -13,6 +13,18 @@ HOST_BUILD="${OPENCLAW_LIVE_PLUGIN_TOOL_HOST_BUILD:-1}" PACKAGE_TGZ="${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" AGENT_TURN_TIMEOUT_SECONDS="${OPENCLAW_LIVE_PLUGIN_TOOL_TIMEOUT_SECONDS:-300}" PROFILE_FILE="${OPENCLAW_LIVE_PLUGIN_TOOL_PROFILE_FILE:-${OPENCLAW_TESTBOX_PROFILE_FILE:-$HOME/.openclaw-testbox-live.profile}}" +run_log="" + +cleanup() { + if [ -n "${PACKAGE_TGZ:-}" ]; then + docker_e2e_cleanup_package_tgz "$PACKAGE_TGZ" + fi + if [ -n "${run_log:-}" ]; then + rm -f "$run_log" + fi +} +trap cleanup EXIT + if [ ! -f "$PROFILE_FILE" ] && [ -f "$HOME/.profile" ]; then PROFILE_FILE="$HOME/.profile" fi @@ -148,9 +160,7 @@ node scripts/e2e/lib/live-plugin-tool/assertions.mjs assert-agent-turn echo "Live plugin tool Docker E2E passed" EOF docker_e2e_print_log "$run_log" - rm -f "$run_log" exit 1 fi -rm -f "$run_log" echo "Live plugin tool Docker E2E passed" diff --git a/scripts/e2e/npm-onboard-channel-agent-docker.sh b/scripts/e2e/npm-onboard-channel-agent-docker.sh index dd59373b9ab..1b0ea66c6ce 100644 --- a/scripts/e2e/npm-onboard-channel-agent-docker.sh +++ b/scripts/e2e/npm-onboard-channel-agent-docker.sh @@ -12,6 +12,17 @@ DOCKER_TARGET="${OPENCLAW_NPM_ONBOARD_DOCKER_TARGET:-bare}" HOST_BUILD="${OPENCLAW_NPM_ONBOARD_HOST_BUILD:-1}" PACKAGE_TGZ="${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" CHANNEL="${OPENCLAW_NPM_ONBOARD_CHANNEL:-telegram}" +run_log="" + +cleanup() { + if [ -n "${PACKAGE_TGZ:-}" ]; then + docker_e2e_cleanup_package_tgz "$PACKAGE_TGZ" + fi + if [ -n "${run_log:-}" ]; then + rm -f "$run_log" + fi +} +trap cleanup EXIT case "$CHANNEL" in telegram | discord | slack) ;; @@ -178,9 +189,7 @@ node scripts/e2e/lib/npm-onboard-channel-agent/assertions.mjs assert-agent-turn echo "npm tarball onboard/channel/agent Docker E2E passed for $CHANNEL" EOF docker_e2e_print_log "$run_log" - rm -f "$run_log" exit 1 fi -rm -f "$run_log" echo "npm tarball onboard/channel/agent Docker E2E passed ($CHANNEL)" diff --git a/test/scripts/docker-build-helper.test.ts b/test/scripts/docker-build-helper.test.ts index 5ea3dee82ba..8c3796b1b30 100644 --- a/test/scripts/docker-build-helper.test.ts +++ b/test/scripts/docker-build-helper.test.ts @@ -21,8 +21,12 @@ const OPENWEBUI_DOCKER_E2E_PATH = "scripts/e2e/openwebui-docker.sh"; const ONBOARD_DOCKER_E2E_PATH = "scripts/e2e/onboard-docker.sh"; const KITCHEN_SINK_PLUGIN_DOCKER_E2E_PATH = "scripts/e2e/kitchen-sink-plugin-docker.sh"; const KITCHEN_SINK_RPC_DOCKER_E2E_PATH = "scripts/e2e/kitchen-sink-rpc-docker.sh"; +const CODEX_ON_DEMAND_DOCKER_E2E_PATH = "scripts/e2e/codex-on-demand-docker.sh"; const CODEX_NPM_PLUGIN_LIVE_DOCKER_E2E_PATH = "scripts/e2e/codex-npm-plugin-live-docker.sh"; +const LIVE_PLUGIN_TOOL_DOCKER_E2E_PATH = "scripts/e2e/live-plugin-tool-docker.sh"; +const NPM_ONBOARD_CHANNEL_AGENT_DOCKER_E2E_PATH = + "scripts/e2e/npm-onboard-channel-agent-docker.sh"; const SKILL_INSTALL_DOCKER_E2E_PATH = "scripts/e2e/skill-install-docker.sh"; const PLUGIN_BINDING_COMMAND_ESCAPE_DOCKER_E2E_PATH = "scripts/e2e/plugin-binding-command-escape-docker.sh"; @@ -411,6 +415,23 @@ test -f "$TMPDIR/docker-cmd-seen" expect(runner).not.toContain('rm -f "$run_log"\n exit 1'); }); + it("cleans package-backed onboarding and plugin Docker artifacts on every exit path", () => { + for (const path of [ + CODEX_ON_DEMAND_DOCKER_E2E_PATH, + LIVE_PLUGIN_TOOL_DOCKER_E2E_PATH, + NPM_ONBOARD_CHANNEL_AGENT_DOCKER_E2E_PATH, + ]) { + const runner = readFileSync(path, "utf8"); + + expect(runner, path).toContain('run_log=""'); + expect(runner, path).toMatch( + /cleanup\(\) \{[\s\S]*docker_e2e_cleanup_package_tgz "\$PACKAGE_TGZ"[\s\S]*rm -f "\$run_log"/u, + ); + expect(runner, path).toContain("trap cleanup EXIT"); + expect(runner, path).not.toContain('rm -f "$run_log"\n exit 1'); + } + }); + it("runs skill install through the package-cleaning Docker harness", () => { const runner = readFileSync(SKILL_INSTALL_DOCKER_E2E_PATH, "utf8");