diff --git a/install/hiclaw-install.sh b/install/hiclaw-install.sh index c593ea008..3bd0500ec 100755 --- a/install/hiclaw-install.sh +++ b/install/hiclaw-install.sh @@ -1603,8 +1603,9 @@ should_skip_step() { local _env="${AGENTTEAMS_ENV_FILE:-${HOME}/agentteams-manager.env}" [ ! -f "${_env}" ] && return 0 ;; - # Keep-All upgrade mode: skip all config steps (step_volume/step_workspace handled separately) - step_llm|step_admin|step_network|step_ports|step_domains|step_github|step_skills|step_runtime|step_manager_runtime|step_e2ee|step_docker_proxy|step_idle|step_hostshare) + # Keep-All upgrade mode: skip base config steps. Steps with additional + # mode-specific rules are handled by their dedicated cases below. + step_llm|step_admin|step_network|step_ports|step_domains|step_github|step_skills|step_runtime) [ "${AGENTTEAMS_UPGRADE}" = "1" ] && [ "${AGENTTEAMS_UPGRADE_KEEP_ALL}" = "1" ] && return 0 ;; step_volume|step_workspace) @@ -1615,19 +1616,23 @@ should_skip_step() { step_e2ee|step_idle) [ "${AGENTTEAMS_NON_INTERACTIVE}" = "1" ] && return 0 [ "${AGENTTEAMS_QUICKSTART}" = "1" ] && [ "${AGENTTEAMS_UPGRADE}" != "1" ] && return 0 + [ "${AGENTTEAMS_UPGRADE}" = "1" ] && [ "${AGENTTEAMS_UPGRADE_KEEP_ALL}" = "1" ] && return 0 ;; step_docker_proxy) [ "${AGENTTEAMS_NON_INTERACTIVE}" = "1" ] && return 0 [ "${AGENTTEAMS_QUICKSTART}" = "1" ] && [ "${AGENTTEAMS_UPGRADE}" != "1" ] && return 0 # Embedded mode handles docker access natively — skip this step [ "${AGENTTEAMS_USE_EMBEDDED:-}" = "1" ] && return 0 + [ "${AGENTTEAMS_UPGRADE}" = "1" ] && [ "${AGENTTEAMS_UPGRADE_KEEP_ALL}" = "1" ] && return 0 ;; step_manager_runtime) [ "${AGENTTEAMS_NON_INTERACTIVE}" = "1" ] && return 0 + [ "${AGENTTEAMS_UPGRADE}" = "1" ] && [ "${AGENTTEAMS_UPGRADE_KEEP_ALL}" = "1" ] && return 0 ;; step_hostshare) [ "${AGENTTEAMS_NON_INTERACTIVE}" = "1" ] && return 0 [ "${AGENTTEAMS_QUICKSTART}" = "1" ] && return 0 + [ "${AGENTTEAMS_UPGRADE}" = "1" ] && [ "${AGENTTEAMS_UPGRADE_KEEP_ALL}" = "1" ] && return 0 ;; step_podman_autostart) # Only relevant for Podman with systemd diff --git a/install/tests/test-step-routing.sh b/install/tests/test-step-routing.sh new file mode 100755 index 000000000..0d282edcc --- /dev/null +++ b/install/tests/test-step-routing.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +INSTALL_SCRIPT="${INSTALL_SCRIPT:-${ROOT_DIR}/install/hiclaw-install.sh}" + +# Load only the routing helper; sourcing the full installer would start Docker. +source <(sed -n '/^should_skip_step() {/,/^}/p' "${INSTALL_SCRIPT}") + +PASS=0 +FAIL=0 + +pass() { + printf 'PASS: %s\n' "$1" + PASS=$((PASS + 1)) +} + +fail() { + printf 'FAIL: %s\n' "$1" >&2 + FAIL=$((FAIL + 1)) +} + +assert_skipped() { + local step="$1" + local context="$2" + if should_skip_step "${step}"; then + pass "${context}: ${step} is skipped" + else + fail "${context}: ${step} should be skipped" + fi +} + +assert_runs() { + local step="$1" + local context="$2" + if should_skip_step "${step}"; then + fail "${context}: ${step} should run" + else + pass "${context}: ${step} runs" + fi +} + +reset_mode() { + AGENTTEAMS_NON_INTERACTIVE=0 + AGENTTEAMS_QUICKSTART=0 + AGENTTEAMS_UPGRADE=0 + AGENTTEAMS_UPGRADE_KEEP_ALL=0 + AGENTTEAMS_USE_EMBEDDED=0 + AGENTTEAMS_ENV_FILE="${ROOT_DIR}/install/tests/nonexistent.env" + DOCKER_CMD=docker +} + +reset_mode +AGENTTEAMS_QUICKSTART=1 +for step in step_e2ee step_idle step_docker_proxy step_hostshare; do + assert_skipped "${step}" "quick start" +done +assert_runs step_manager_runtime "quick start" + +reset_mode +AGENTTEAMS_NON_INTERACTIVE=1 +for step in step_manager_runtime step_e2ee step_idle step_docker_proxy step_hostshare; do + assert_skipped "${step}" "non-interactive" +done + +reset_mode +AGENTTEAMS_USE_EMBEDDED=1 +assert_skipped step_docker_proxy "embedded" + +reset_mode +AGENTTEAMS_UPGRADE=1 +AGENTTEAMS_UPGRADE_KEEP_ALL=1 +for step in \ + step_llm step_admin step_network step_ports step_domains step_github \ + step_skills step_runtime step_manager_runtime step_e2ee step_docker_proxy \ + step_idle step_hostshare; do + assert_skipped "${step}" "keep-all upgrade" +done + +reset_mode +for step in step_manager_runtime step_e2ee step_idle step_docker_proxy step_hostshare; do + assert_runs "${step}" "manual" +done + +printf '\nResults: %d passed, %d failed\n' "${PASS}" "${FAIL}" +if [ "${FAIL}" -ne 0 ]; then + exit 1 +fi