From 1a39bd3480dd1efeb18fd9d27595ea7ae9169071 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 20 Nov 2026 15:44:40 +0300 Subject: [PATCH] ci: install.sh tested on each supported distribution The installer was tested by hand in containers before a release; a change to it, to what it installs or a distribution's packages could break a fresh install unseen. dev/test-installer.sh installs the committed HEAD with install.sh in a systemd container of one distribution and checks that the panel's services run, it has a secret key and an admin password, and the login page loads. The Installer workflow runs it on Ubuntu 22.04/24.04/26.04, Debian 12/13, AlmaLinux 10, openSUSE Leap 15.6 and openEuler 24.03 when the installer or conf/ changes, and weekly. --- .github/workflows/installer.yml | 46 ++++++++++++++++++++ dev/test-installer.sh | 75 +++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .github/workflows/installer.yml create mode 100755 dev/test-installer.sh diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml new file mode 100644 index 00000000..af49a644 --- /dev/null +++ b/.github/workflows/installer.yml @@ -0,0 +1,46 @@ +name: Installer + +# install.sh on each supported distribution (dev/test-installer.sh): on each +# push to master (the panel it installs changed), on a pull request that +# changes the installer or what it installs, and weekly, as the +# distributions' packages change under it +on: + push: + branches: [master] + pull_request: + paths: + - install.sh + - webvirtcloud.sh + - conf/** + - dev/test-installer.sh + - .github/workflows/installer.yml + schedule: + - cron: '0 4 * * 1' + workflow_dispatch: + +permissions: + contents: read + +jobs: + install: + name: ${{ matrix.image }} + runs-on: ubuntu-latest + timeout-minutes: 40 + strategy: + fail-fast: false + matrix: + image: + - ubuntu:22.04 + - ubuntu:24.04 + - ubuntu:26.04 + - debian:12 + - debian:13 + - almalinux:10 + - opensuse/leap:15.6 + - openeuler/openeuler:24.03-lts + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install and check the panel + run: dev/test-installer.sh "${{ matrix.image }}" diff --git a/dev/test-installer.sh b/dev/test-installer.sh new file mode 100755 index 00000000..f8bad6e5 --- /dev/null +++ b/dev/test-installer.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# Installs the panel with install.sh in a systemd container of one distribution +# and checks that it answers: its services run, it has a secret key and an +# admin password, and the login page loads. It installs the committed HEAD. +# +# Usage, from the repository root (needs docker): +# dev/test-installer.sh IMAGE e.g. debian:13, almalinux:10, opensuse/leap:15.6 +set -euo pipefail + +image=${1:?usage: dev/test-installer.sh IMAGE} +case $image in + ubuntu:* | debian:*) prepare="apt-get update && apt-get install -y systemd systemd-sysv" ;; + almalinux:* | */openeuler:*) prepare="dnf -y install systemd findutils" ;; + opensuse/*) prepare="zypper -n install systemd" ;; + *) echo "No container recipe for $image" >&2; exit 2 ;; +esac + +repo=$(mktemp -d) +# unique: runs on one docker do not remove each other's container +name=wvc-installer-test-$(tr -c 'a-z0-9' '-' <<< "$image" | sed 's/-*$//')-${repo##*.} +name=${name,,} +cleanup() { + docker rm -f "$name" >/dev/null 2>&1 || true + docker rmi "$name" >/dev/null 2>&1 || true + rm -rf "${repo:?}" +} +trap cleanup EXIT + +# the installer clones the repository: a clone of HEAD, readable by any user +git clone -q --no-hardlinks . "$repo/webvirtcloud" +chmod -R a+rX "$repo" + +docker build -q -t "$name" - > /dev/null < /dev/null + +for _ in $(seq 60); do + state=$(docker exec "$name" systemctl is-system-running 2>/dev/null || true) + [[ $state == running || $state == degraded ]] && break + sleep 1 +done +[[ $state == running || $state == degraded ]] || { echo "systemd did not start: $state"; docker logs "$name"; exit 1; } + +# the answers: no FQDN for nginx, the default noVNC port +docker exec "$name" bash -c ' + # git comes with the installer; the mounted clone is not root'"'"'s + printf "[safe]\n\tdirectory = *\n" >> /etc/gitconfig + mkdir -p /root/inst && cp /repo/install.sh /repo/webvirtcloud.sh /root/inst/ + cd /root/inst && printf "n\n\n" | APP_REPO_URL=/repo ./install.sh' || + { docker exec "$name" tail -n 50 /var/log/webvirtcloud-install.log; exit 1; } + +docker exec "$name" bash -c ' + for unit in webvirt-cloud webvirt-novncd webvirt-socketiod webvirt-worker nginx; do + systemctl is-active --quiet "$unit" || { systemctl status "$unit" --no-pager; exit 1; } + done + test -s /srv/webvirtcloud/data/secret_key || { echo "No secret key"; exit 1; } + test -s /srv/webvirtcloud/data/admin_password || { echo "No admin password"; exit 1; } + # curl is not on every distribution; the panel'"'"'s Python is + /srv/webvirtcloud/venv/bin/python3 - <