Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

test(install): exercise Python provisioning against real distro repos

Juan Denis4e80d0655f5f
diff --git a/.github/workflows/scripts-ci.yml b/.github/workflows/scripts-ci.yml
index 4fe0dcd1..a0c1b1db 100644
--- a/.github/workflows/scripts-ci.yml
+++ b/.github/workflows/scripts-ci.yml
@@ -104,6 +104,12 @@ jobs:
- 'ubuntu:22.04'
- 'ubuntu:24.04'
- 'debian:12'
+ # Debian 13 (trixie) ships ONLY python3.13 — no 3.11, no 3.12. Issue
+ # #99: the installer's version gate could not be satisfied from its
+ # repos and fell through to a source build. Every list we had stopped
+ # at debian:12, which passes because bookworm still carries
+ # python3.11, so nothing caught it. Newest-stable belongs here.
+ - 'debian:13'
- 'rockylinux:9'
- 'almalinux:9'
- 'fedora:40'
@@ -184,6 +190,46 @@ jobs:
bash scripts/test/test_stage.sh
'
+ python-provisioning:
+ name: python provisioning (${{ matrix.image }})
+ runs-on: ubuntu-latest
+ timeout-minutes: 25
+ # The suites above stub every external tool, which is the right trade for
+ # logic but leaves ONE thing untested: whether the distro's real repos can
+ # actually give us a supported Python. That gap shipped issue #99 — Debian
+ # 13 carries only python3.13, the gate wanted 3.11-3.12, and the installer
+ # fell through to a source build that cannot succeed (nothing in install.sh
+ # installs a compiler). Seven distro images were green throughout.
+ #
+ # provision_python needs no systemd, no nginx and no ports, so it runs
+ # honestly in the same plain containers. This is the leg that turns "a new
+ # distro dropped our Python" from an issue report into a red build.
+ strategy:
+ fail-fast: false
+ matrix:
+ image:
+ - 'ubuntu:22.04'
+ - 'ubuntu:24.04'
+ - 'debian:12'
+ - 'debian:13'
+ - 'rockylinux:9'
+ - 'almalinux:9'
+ - 'fedora:40'
+ - 'opensuse/leap:15.5'
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: provision_python on ${{ matrix.image }}
+ run: |
+ docker run --rm -v "$PWD:/src:ro" -w /src "${{ matrix.image }}" sh -c '
+ command -v bash >/dev/null 2>&1 || {
+ { command -v apt-get >/dev/null 2>&1 && apt-get update -qq && apt-get install -y -qq bash; } ||
+ { command -v dnf >/dev/null 2>&1 && dnf install -y -q bash; } ||
+ { command -v zypper >/dev/null 2>&1 && zypper --non-interactive install bash; } || true
+ }
+ bash scripts/test/test_provision_python.sh
+ '
+
cross-arch-arm64:
name: unit (arm64 / raspberry-pi proxy)
runs-on: ubuntu-24.04-arm
diff --git a/scripts/test/full-stack-test.ps1 b/scripts/test/full-stack-test.ps1
index fcc38e07..33ea382b 100644
--- a/scripts/test/full-stack-test.ps1
+++ b/scripts/test/full-stack-test.ps1
@@ -63,6 +63,22 @@ $DistroMap = @{
'alma9' = @{ backend = 'vagrant'; image = 'generic/alma9'; user = 'vagrant' }
'debian11' = @{ backend = 'vagrant'; image = 'generic/debian11'; user = 'vagrant' }
'opensuse15' = @{ backend = 'vagrant'; image = 'generic/opensuse15'; user = 'vagrant' }
+
+ # NO debian13 (trixie) — not an oversight. As of 2026-08 no Debian 13 box
+ # publishes a Hyper-V provider, and this harness is Hyper-V only:
+ # generic/debian13 does not exist (the generic/* line stops at debian12)
+ # debian/trixie64 libvirt only
+ # bento/debian-13 parallels, virtualbox, vmware_desktop
+ # Multipass is Ubuntu images only, so it cannot cover it either. Adding a
+ # name here would just fail at launch.
+ #
+ # Trixie is covered instead by the `python-provisioning` job in
+ # .github/workflows/scripts-ci.yml, which runs provision_python against the
+ # real debian:13 repos in a container. That catches the whole class of
+ # "a new distro release dropped the Python we ask for" (issue #99) without
+ # needing a VM. What is still NOT covered on trixie is the full end-to-end
+ # install: systemd unit, nginx vhost, live API harness. Re-check box
+ # availability periodically and add it here the moment one lands.
}
if ($Only) {
diff --git a/scripts/test/test_install.sh b/scripts/test/test_install.sh
index 51caa15f..587ea1b0 100644
--- a/scripts/test/test_install.sh
+++ b/scripts/test/test_install.sh
@@ -56,10 +56,15 @@ mkpy() { # mkpy <name> <major.minor>
} > "$PY_STUB/$1"
chmod +x "$PY_STUB/$1"
}
-# python3.12 reports an out-of-range 3.13 (rejected); python3.11 is in range;
+# python3.12 reports an out-of-range 3.14 (rejected); python3.11 is in range;
# bare python3 is an old 3.10 (rejected). locate_python must therefore pick
# python3.11 — proving it no longer blindly trusts `python3`.
-mkpy python3.12 3.13
+#
+# The out-of-range stub used to report 3.13, which stopped being out of range
+# when the gate moved to cover Debian 13 (issue #99). Pick a version ABOVE
+# PYTHON_MAX, and move it whenever the ceiling moves — the point of the stub is
+# "too new", not any particular number.
+mkpy python3.12 3.14
mkpy python3.11 3.11
mkpy python3 3.10
export PATH="$STUB_BIN:$PATH"
@@ -88,15 +93,30 @@ else
fi
# --------------------------------------------------------------------------
-# T2 — ver_in_range gate (3.11/3.12 accepted, 3.10/3.13 rejected).
+# T2 — ver_in_range gate (3.11/3.12/3.13 accepted, 3.10/3.14 rejected).
+#
+# 3.13 MUST be accepted: Debian 13 ships only python3.13, and this assertion
+# previously required it to be rejected — the suite was actively pinning the
+# bug that made trixie uninstallable (issue #99).
# --------------------------------------------------------------------------
if ( set -Eeuo pipefail; ver_in_range 3.11 ) && ( set -Eeuo pipefail; ver_in_range 3.12 ) && \
- ! ( set -Eeuo pipefail; ver_in_range 3.10 ) && ! ( set -Eeuo pipefail; ver_in_range 3.13 ); then
- ok "ver_in_range accepts 3.11/3.12 and rejects 3.10/3.13"
+ ( set -Eeuo pipefail; ver_in_range 3.13 ) && \
+ ! ( set -Eeuo pipefail; ver_in_range 3.10 ) && ! ( set -Eeuo pipefail; ver_in_range 3.14 ); then
+ ok "ver_in_range accepts 3.11/3.12/3.13 and rejects 3.10/3.14"
else
bad "ver_in_range gate is wrong"
fi
+# Debian 13 carries ONLY python3.13, so the ceiling has to include it or the
+# installer can never satisfy itself from trixie's repos. Guard the constant
+# directly — the gate above would still pass if PYTHON_MAX regressed to 3.12
+# and someone "fixed" the assertion to match.
+if [ "$PYTHON_MAX" = "3.13" ] || printf '%s\n%s' "3.13" "$PYTHON_MAX" | sort -C -V; then
+ ok "PYTHON_MAX ($PYTHON_MAX) covers Debian 13's python3.13"
+else
+ bad "PYTHON_MAX is $PYTHON_MAX — Debian 13 ships only python3.13 and would fall to a source build"
+fi
+
# --------------------------------------------------------------------------
# T3 — node_ready gates on vite 8's Node floor (^20.19.0 || >=22.12.0) AND npm
# present. The frontend bundler (rolldown) can't build on older Node — npm
diff --git a/scripts/test/test_provision_python.sh b/scripts/test/test_provision_python.sh
new file mode 100644
index 00000000..6717251c
--- /dev/null
+++ b/scripts/test/test_provision_python.sh
@@ -0,0 +1,156 @@
+#!/usr/bin/env bash
+#
+# Does install.sh actually obtain a working Python ON THIS DISTRO?
+#
+# Every other suite here runs against stubs, which is the right trade for logic
+# but means the one thing that talks to the distro's real package repos was
+# never exercised. Issue #99: Debian 13 ships only python3.13, the version gate
+# accepted 3.11-3.12, so both `apt-get install python3.11` and `python3.12`
+# failed and the installer fell through to a source build that cannot work
+# (nothing in install.sh ever installs a compiler). Seven distro images in CI
+# and none of them caught it, because none of them ran this code for real.
+#
+# So: run identify_system + choose_pkg_manager + provision_python against the
+# real repos, then prove the result is usable. No systemd, no nginx, no network
+# services — this fits in the plain distro containers the matrix already pulls.
+#
+# Destructive: installs packages. Intended for a container or a throwaway VM.
+# Refuses to run on a box that looks like somebody's machine unless forced.
+#
+# Run: bash scripts/test/test_provision_python.sh
+# SERVERKIT_ALLOW_DESTRUCTIVE=1 bash scripts/test/test_provision_python.sh
+set -uo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
+INSTALL_SH="$REPO_DIR/install.sh"
+
+PASS=0
+FAIL=0
+SKIP=0
+ok() { PASS=$((PASS + 1)); printf ' \033[32m✔\033[0m %s\n' "$1"; }
+bad() { FAIL=$((FAIL + 1)); printf ' \033[31m✘\033[0m %s\n' "$1"; }
+skip() { SKIP=$((SKIP + 1)); printf ' \033[33m∼\033[0m %s (skipped)\n' "$1"; }
+
+# --------------------------------------------------------------------------
+# Guard rails. This one really does apt/dnf install.
+# --------------------------------------------------------------------------
+if [ "${SERVERKIT_ALLOW_DESTRUCTIVE:-0}" != "1" ] \
+ && [ ! -f /.dockerenv ] && [ -z "${CI:-}" ]; then
+ printf 'Refusing to run: this installs packages system-wide.\n' >&2
+ printf 'Run it in a container, or set SERVERKIT_ALLOW_DESTRUCTIVE=1.\n' >&2
+ exit 2
+fi
+if [ "$(id -u)" != "0" ]; then
+ printf 'Refusing to run: package installation needs root.\n' >&2
+ exit 2
+fi
+
+printf '\nprovision_python against real package repos\n'
+
+# shellcheck source=/dev/null
+source "$INSTALL_SH" >/dev/null 2>&1
+# install.sh runs `set -euo pipefail` at the top, and sourcing applies that to
+# THIS shell. Under -e the first probe that returns non-zero (which is the
+# normal way half of these functions report "not found") would kill the run
+# before printing a single assertion. Put it back the way a test harness needs.
+set +e
+
+# The installer's own detection, not a guess — provision_python branches on
+# OS_FAMILY and ID, and choose_pkg_manager is what makes pkg_add do anything.
+identify_system >/dev/null 2>&1 || true
+choose_pkg_manager >/dev/null 2>&1 || true
+
+printf ' distro: %s (ID=%s, family=%s, pkg=%s)\n' \
+ "${PRETTY_NAME:-unknown}" "${ID:-?}" "${OS_FAMILY:-?}" "${PKG_MGR:-?}"
+printf ' gate: Python %s-%s\n' "$PYTHON_MIN" "$PYTHON_MAX"
+
+if [ "${PKG_MGR:-}" = "" ]; then
+ skip "no package manager detected — nothing to provision with"
+ printf '\n%d passed, %d failed, %d skipped\n\n' "$PASS" "$FAIL" "$SKIP"
+ [ "$FAIL" -eq 0 ]
+ exit $?
+fi
+
+# --------------------------------------------------------------------------
+# 1. A supported interpreter must be obtainable from the distro's own repos.
+#
+# The source-build fallback is deliberately NOT accepted as a pass here. It
+# takes 20+ minutes with --enable-optimizations, needs a toolchain the
+# installer never installs, and swallows its own errors through `| tail -1`.
+# A distro that reaches it is a distro we have not really added support for.
+# --------------------------------------------------------------------------
+before_build_from_source=0
+build_python_from_source() {
+ before_build_from_source=1
+ return 1
+}
+
+# provision_python's last line is `... || halt "Could not install a supported
+# Python"`, and halt exits. Unstubbed it would take this harness down with it
+# before a single assertion printed, turning a real failure into silence.
+# Returning 1 instead lets provision_python report failure normally.
+halted=""
+halt() {
+ halted="$*"
+ return 1
+}
+
+if provision_python >/tmp/pp.log 2>&1; then
+ prov_rc=0
+else
+ prov_rc=$?
+fi
+sed 's/^/ | /' /tmp/pp.log | tail -25
+
+if [ "$before_build_from_source" = "1" ]; then
+ bad "no packaged Python in $PYTHON_MIN-$PYTHON_MAX on ${ID:-this distro} — the installer resorts to compiling one"
+ [ -n "$halted" ] && printf ' installer would abort with: %s\n' "$halted"
+elif [ "$prov_rc" != "0" ]; then
+ bad "provision_python failed (exit $prov_rc)${halted:+ — $halted}"
+else
+ ok "provision_python obtained a supported Python from the distro's packages"
+fi
+
+# --------------------------------------------------------------------------
+# 2. Whatever it picked has to actually be usable.
+# A python that cannot build a venv or run pip fails the install later, at a
+# much more confusing moment.
+# --------------------------------------------------------------------------
+if [ -z "${PYTHON_BIN:-}" ] || ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
+ bad "PYTHON_BIN is unset or not on PATH after provision_python"
+else
+ pyver="$("$PYTHON_BIN" -c 'import sys;print(".".join(map(str,sys.version_info[:2])))' 2>/dev/null || echo '?')"
+ if ver_in_range "$pyver"; then
+ ok "$PYTHON_BIN reports $pyver, inside the supported range"
+ else
+ bad "$PYTHON_BIN reports $pyver, outside $PYTHON_MIN-$PYTHON_MAX"
+ fi
+
+ if "$PYTHON_BIN" -m venv /tmp/pp-venv >/dev/null 2>&1 \
+ && [ -x /tmp/pp-venv/bin/python ]; then
+ ok "it can create a virtualenv"
+ if /tmp/pp-venv/bin/python -m pip --version >/dev/null 2>&1; then
+ ok "the virtualenv has a working pip"
+ else
+ bad "the virtualenv has no working pip (missing ensurepip?)"
+ fi
+ # ssl and sqlite3 are the two stdlib modules a hand-built or
+ # stripped-down Python most often lacks, and both fail far away from
+ # here: no ssl means every HTTPS fetch dies, no sqlite3 means the
+ # database never opens.
+ for mod in ssl sqlite3 ctypes; do
+ if /tmp/pp-venv/bin/python -c "import $mod" >/dev/null 2>&1; then
+ ok "stdlib $mod is present"
+ else
+ bad "stdlib $mod is MISSING — the panel will fail later, not here"
+ fi
+ done
+ else
+ bad "it cannot create a virtualenv"
+ fi
+ rm -rf /tmp/pp-venv
+fi
+
+printf '\n%d passed, %d failed, %d skipped\n\n' "$PASS" "$FAIL" "$SKIP"
+[ "$FAIL" -eq 0 ]