Files
computer-playbook/scripts/github/guide/host_deploy.sh
T
kevinveenbirkenbachandClaude Opus 5 dce60df815 feat(ci): replay the guide on every distro
guide_select picked the role, the mode and the distro in one draw, so a run proved the README instructions worked on exactly one randomly chosen distribution. The distro list was also a literal in the workflow, which meant the manual-CI distros input never reached the guide at all.

The distro draw is removed. guide_select still picks the role and derives the mode, while the shared loop from 1bbe7a0eb drives the distro dimension, and ci-orchestrator forwards its distros input.

The four mode-specific steps collapse into guide/one.sh, which the loop runs once per distro: it renders the pkgmgr base image for the current distro, then either execs host_deploy.sh or brings the compose server up and replays the README block against it.

one.sh releases the compose server in an EXIT trap. Without it the second distro would start against the stack the first one left behind. Rescue diagnostics gain a distro segment for the same reason the swarm collectors did.

The job timeout goes from 90 to 345 minutes because up to five rounds now have to fit; the loop's own budget still decides how many actually run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 21:06:47 +02:00

65 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install a host role inside its pkgmgr distro container against localhost.
# Env: GUIDE_ROLE, GUIDE_RUNTIME_IMAGE, INFINITO_DISTRO,
# INFINITO_RESCUE_DIAGNOSTICS_BASE.
set -euo pipefail
: "${INFINITO_RESCUE_DIAGNOSTICS_BASE:?}"
: "${INFINITO_DISTRO:?}"
# Exception: strip the clone/cd lines because the checkout is already
# mounted; running them would clone a fresh tree and lose the CI changes.
awk '/^### Production$/{p=1} p && /^```bash$/{c=1; next} c && /^```$/{exit} c' \
"roles/${GUIDE_ROLE}/README.md" |
grep -vE '^git clone |^cd core$' >/tmp/host-deploy.sh
test -s /tmp/host-deploy.sh
sed -i "s#<your-ssh-public-key>#ssh-ed25519 AAAA_TEST_DUMMY_KEY github-ci-dummy@infinito#" /tmp/host-deploy.sh
docker pull "${GUIDE_RUNTIME_IMAGE}"
# Exception: the pkgmgr base image ships no init of its own.
PREP="$(docker run -d --entrypoint sleep "${GUIDE_RUNTIME_IMAGE}" infinity)"
docker exec "${PREP}" sh -c '
set -e
if command -v apt-get >/dev/null 2>&1; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y systemd systemd-sysv libnss-myhostname
elif command -v dnf >/dev/null 2>&1; then
dnf install -y systemd
elif command -v pacman >/dev/null 2>&1; then
pacman -Sy --noconfirm systemd
fi
grep -q myhostname /etc/nsswitch.conf || sed -i "s/^hosts:.*/& myhostname/" /etc/nsswitch.conf
[ -e /sbin/init ] || ln -sf /lib/systemd/systemd /sbin/init
'
BOOT_IMAGE="guide-boot:${GUIDE_ROLE}"
docker commit "${PREP}" "${BOOT_IMAGE}" >/dev/null
docker rm -f "${PREP}" >/dev/null 2>&1 || true
CID="$(docker run -d --privileged --cgroupns=host \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
--tmpfs /run --tmpfs /run/lock \
-v "${PWD}:${PWD}" \
--entrypoint /sbin/init \
"${BOOT_IMAGE}")"
# shellcheck disable=SC2154
trap 'rc=$?; if [ "${rc}" -ne 0 ]; then INFINITO_RESCUE_DIAGNOSTICS_DIR="${INFINITO_RESCUE_DIAGNOSTICS_BASE}/${INFINITO_DISTRO}/${GUIDE_ROLE}" python3 utils/diagnostics/container.py "${GUIDE_ROLE}" "guide host boot failure" || true; fi; docker rm -f "${CID}" >/dev/null 2>&1 || true; docker rmi -f "${BOOT_IMAGE}" >/dev/null 2>&1 || true' EXIT
for _ in $(seq 1 40); do
state="$(docker exec "${CID}" systemctl is-system-running 2>/dev/null || true)"
case "${state}" in running | degraded) break ;; esac
sleep 3
done
state="$(docker exec "${CID}" systemctl is-system-running 2>/dev/null || true)"
case "${state}" in
running | degraded) ;;
*)
echo "systemd never reached a running state (last: ${state:-unknown})" >&2
docker exec "${CID}" systemctl --no-pager status 2>/dev/null | head -n 20 >&2 || true
exit 1
;;
esac
docker exec "${CID}" bash -lc 'systemctl unmask systemd-logind && systemctl start systemd-logind && loginctl enable-linger root && systemctl start user@0.service'
docker exec -i -w "${PWD}" "${CID}" bash -s </tmp/host-deploy.sh