9e8f1bbeed
Dashboard / frontend (push) Failing after 0s
Dashboard / api (push) Failing after 0s
Lint PowerShell / powershell-lint (ubuntu-latest) (push) Failing after 1s
Python Lint / Lint Python with Ruff (push) Failing after 1s
ShellCheck / Lint shell scripts (push) Failing after 1s
Matrix Smoke / linux-smoke (push) Failing after 1s
Matrix Smoke / distro: cachyos (push) Failing after 15s
Matrix Smoke / distro: linux-mint-21.3 (push) Failing after 15s
Matrix Smoke / distro: debian-12 (push) Failing after 5m21s
Matrix Smoke / distro: fedora-41 (push) Failing after 4m56s
Matrix Smoke / distro: ubuntu-24.04 (push) Failing after 2m13s
Matrix Smoke / distro: rocky-9 (push) Failing after 10m39s
Matrix Smoke / distro: manjaro (push) Failing after 12m11s
Matrix Smoke / distro: opensuse-tw (push) Failing after 11m53s
Matrix Smoke / distro: archlinux (push) Failing after 20m3s
Matrix Smoke / distro: ubuntu-22.04 (push) Failing after 13m49s
Validate .env Schema / tier-1-env-validation (push) Successful in 52s
Validate .env Schema / tier-2-env-validation (push) Successful in 44s
Validate .env Schema / tier-3-env-validation (push) Successful in 52s
Validate .env Schema / tier-4-env-validation (push) Successful in 51s
Validate Extensions Catalog / Check catalog is up-to-date (push) Failing after 9m47s
Secret Scan / Scan for secrets (push) Failing after 21m4s
Validate Docker Compose / Validate Docker Compose files (push) Has been cancelled
Python Type Check / Type check with mypy (push) Has been cancelled
Validate .env Schema / tier-0-env-validation (push) Has been cancelled
Test Linux / integration-smoke (push) Has been cancelled
Lint PowerShell / powershell-lint (windows-latest) (push) Has been cancelled
Matrix Smoke / macos-smoke (push) Has been cancelled
143 lines
4.2 KiB
Bash
143 lines
4.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Regression checks for ODS uninstall compose cleanup.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
TARGET="$ROOT_DIR/ods-uninstall.sh"
|
|
TMP_DIR=""
|
|
|
|
fail() {
|
|
echo "[FAIL] $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
pass() {
|
|
echo "[PASS] $*"
|
|
}
|
|
|
|
make_stub_bin() {
|
|
local stub_dir="$1"
|
|
|
|
cat > "$stub_dir/docker" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
printf '%s\n' "$*" >> "${DOCKER_LOG:?}"
|
|
if [[ "${1:-}" == "ps" ]]; then
|
|
exit 0
|
|
fi
|
|
if [[ "${1:-}" == "volume" && "${2:-}" == "ls" ]]; then
|
|
exit 0
|
|
fi
|
|
exit 0
|
|
EOF
|
|
chmod +x "$stub_dir/docker"
|
|
|
|
cat > "$stub_dir/systemctl" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
if [[ "${1:-}" == "is-enabled" ]]; then
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
EOF
|
|
chmod +x "$stub_dir/systemctl"
|
|
|
|
cat > "$stub_dir/sudo" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
exit 0
|
|
EOF
|
|
chmod +x "$stub_dir/sudo"
|
|
|
|
cat > "$stub_dir/pgrep" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
exit 1
|
|
EOF
|
|
chmod +x "$stub_dir/pgrep"
|
|
}
|
|
|
|
make_install() {
|
|
local install_dir="$1"
|
|
|
|
mkdir -p "$install_dir/data" "$install_dir/lib"
|
|
cp "$TARGET" "$install_dir/ods-uninstall.sh"
|
|
cp "$ROOT_DIR/lib/safe-env.sh" "$install_dir/lib/safe-env.sh"
|
|
touch "$install_dir/ods-cli"
|
|
touch "$install_dir/docker-compose.base.yml"
|
|
touch "$install_dir/docker-compose.cpu.yml"
|
|
printf '%s\n' '-f docker-compose.base.yml -f docker-compose.cpu.yml' > "$install_dir/.compose-flags"
|
|
printf '%s\n' 'GPU_BACKEND=cpu' > "$install_dir/.env"
|
|
}
|
|
|
|
run_uninstall() {
|
|
local install_dir="$1"
|
|
local home_dir="$2"
|
|
local stub_dir="$3"
|
|
shift 3
|
|
|
|
HOME="$home_dir" \
|
|
INSTALL_DIR="$install_dir" \
|
|
PATH="$stub_dir:$PATH" \
|
|
DOCKER_LOG="${DOCKER_LOG:?}" \
|
|
bash "$install_dir/ods-uninstall.sh" --force "$@" >/dev/null
|
|
}
|
|
|
|
main() {
|
|
[[ -f "$TARGET" ]] || fail "missing $TARGET"
|
|
if grep -qF 'source "$INSTALL_DIR/.env"' "$TARGET"; then
|
|
fail "uninstall must load .env through lib/safe-env.sh, not source it"
|
|
fi
|
|
|
|
TMP_DIR="$(mktemp -d -t ods-uninstall-test-XXXXXX)"
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
local stub_dir="$TMP_DIR/bin"
|
|
mkdir -p "$stub_dir"
|
|
make_stub_bin "$stub_dir"
|
|
|
|
local install_keep="$TMP_DIR/install-keep"
|
|
local home_keep="$TMP_DIR/home-keep"
|
|
local log_keep="$TMP_DIR/docker-keep.log"
|
|
mkdir -p "$home_keep"
|
|
make_install "$install_keep"
|
|
mkdir -p "$home_keep/.local/bin"
|
|
ln -s "$install_keep/ods-cli" "$home_keep/.local/bin/ods"
|
|
DOCKER_LOG="$log_keep" run_uninstall "$install_keep" "$home_keep" "$stub_dir" --keep-data
|
|
|
|
grep -qF 'compose -f docker-compose.base.yml -f docker-compose.cpu.yml down --remove-orphans' "$log_keep" \
|
|
|| fail "uninstall must use saved .compose-flags for docker compose down"
|
|
if grep -qF 'down -v --remove-orphans' "$log_keep"; then
|
|
fail "--keep-data must not remove compose volumes with -v"
|
|
fi
|
|
pass "uninstall uses saved compose flags and preserves volumes with --keep-data"
|
|
[[ ! -L "$home_keep/.local/bin/ods" ]] \
|
|
|| fail "uninstall must remove the user-level ods CLI symlink"
|
|
pass "uninstall removes user-level ods CLI symlink"
|
|
|
|
local install_purge="$TMP_DIR/install-purge"
|
|
local home_purge="$TMP_DIR/home-purge"
|
|
local log_purge="$TMP_DIR/docker-purge.log"
|
|
mkdir -p "$home_purge"
|
|
make_install "$install_purge"
|
|
DOCKER_LOG="$log_purge" run_uninstall "$install_purge" "$home_purge" "$stub_dir"
|
|
|
|
grep -qF 'compose -f docker-compose.base.yml -f docker-compose.cpu.yml down -v --remove-orphans' "$log_purge" \
|
|
|| fail "normal uninstall must remove compose volumes with -v"
|
|
pass "normal uninstall removes compose volumes"
|
|
|
|
local install_safe="$TMP_DIR/install-safe-env"
|
|
local home_safe="$TMP_DIR/home-safe-env"
|
|
local log_safe="$TMP_DIR/docker-safe-env.log"
|
|
mkdir -p "$home_safe"
|
|
make_install "$install_safe"
|
|
cat > "$install_safe/.env" <<'EOF'
|
|
GPU_BACKEND=$(touch "$HOME/uninstall-env-sourced")
|
|
EOF
|
|
DOCKER_LOG="$log_safe" run_uninstall "$install_safe" "$home_safe" "$stub_dir" --keep-data
|
|
|
|
if [[ -e "$home_safe/uninstall-env-sourced" ]]; then
|
|
fail "uninstall must not execute command substitutions from .env"
|
|
fi
|
|
pass "uninstall loads .env without executing shell substitutions"
|
|
}
|
|
|
|
main "$@"
|