feat(web-app-docs): replay the published instructions in its CLI test

The replay of a role's "### Production" block moves out of the CI guide
scripts and into the documentation role itself. The block is read off the
rendered page over HTTP, so what runs is what a reader copies, and the role
that publishes the page is also the role that proves it.

scripts/github/guide/{one,compose_deploy,host_deploy}.sh and
cli/build/docs/readme/production.py are gone with the workflow step that
called them. The instructions marker now only adds web-app-docs to the row's
apps; test-e2e-cli discovers the role through its new templates/test.env.j2
and runs files/test/test.sh.

The block runs in a throwaway machine, never on the stack host. compose.yml
starts one service built from files/test/Dockerfile, whose base is
INFINITO_PARENT_IMAGE out of the mounted checkout's .env, so the machine is
the stack host's own distribution and the replay exercises the installation
instead of a prebuilt image. files/test/init.sh adds an init when the base
carries none and keeps the full -Syu that ef0f03ea98 established for arch.
scripts/tests/workspace/base/01_install.sh then prepares the machine before
the block runs.

Nothing is skipped any more. The previous host-install branch exited 0 and
passed silently over 65 of the 178 invokable roles; a block without a
"docker run" is now replayed against systemd in that same machine, with the
git clone dropped in favour of the mounted tree under test.

The target role comes from the new guide_role lookup, which reads
list_invokable_app_ids() rather than matching role-name prefixes, and falls
back to the asking role when the round deploys nothing else. deployment.py
grows running_apps() so both lookups share one definition of what the round
deploys. required_by_coverage.role_is_invokable drops its own walk over
categories.yml and delegates to the same SPOT; measured equal across all 280
roles.

Carried in the same index, because the refactor pass ran over this change
set: library.py splits into sites.py and build_queue.py mixins, builder.py
hands translated_languages to catalogs.py and folds three repeated log-tail
and state writes, and placeholders.py becomes a facade over spans.py,
repairs.py and damage.py. No test changed for those splits, and the two
ref-resolution dicts builder.py carried are replaced by _wanted_ref, which
also stops hashing the deployed tree on every tag build.

Verified: 7132 unit and lint tests pass over the whole tree, the guide_role
lookup renders through a real Templar, the base image resolves from .env,
and compose config validates the service. The replay itself has never been
executed; that needs a deploy of web-app-docs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-26 04:39:48 +02:00
1 parent 3e2a21af2b
commit c39f3ec9ee
36 files changed
+1747 -925

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
#!/usr/bin/env bash
# Render the role's "### Production" bash block and replay it against the
# running compose server, exactly as the guide instructs a human to.
# Env: GUIDE_ROLE; INFINITO_CONTAINER comes from scripts/meta/env/load.sh.
set -euo pipefail
: "${GUIDE_ROLE:?}"
python3 -m cli.build.docs.readme.production "${GUIDE_ROLE}" >/tmp/deploy.sh
sed -n '1,/docker run/p' /tmp/deploy.sh | grep -E '^[A-Z_]+=' |
sed 's#^HOST=.*#HOST=localhost#' >/tmp/run.sh
perl -0777 -ne "print \$1 if /bash -c '(.*)'/s" /tmp/deploy.sh >>/tmp/run.sh
test -s /tmp/run.sh
# shellcheck source=/dev/null
source scripts/meta/env/load.sh
sed -i "s#<your-ssh-public-key>#ssh-ed25519 AAAA_TEST_DUMMY_KEY github-ci-dummy@infinito#" /tmp/run.sh
sed -i "s#<your-domain>#${INFINITO_DOMAIN}#" /tmp/run.sh
sed -i "s#<your-clearnet-resolver>#${INFINITO_DNS_IP}#" /tmp/run.sh
docker exec -i "${INFINITO_CONTAINER}" bash -s </tmp/run.sh
-76
View File
@@ -1,76 +0,0 @@
#!/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.
python3 -m cli.build.docs.readme.production "${GUIDE_ROLE}" |
grep -vE '^git clone |^cd core$' >/tmp/host-deploy.sh
test -s /tmp/host-deploy.sh
# shellcheck source=/dev/null
source scripts/meta/env/load.sh
sed -i "s#<your-ssh-public-key>#ssh-ed25519 AAAA_TEST_DUMMY_KEY github-ci-dummy@infinito#" /tmp/host-deploy.sh
sed -i "s#<your-domain>#${INFINITO_DOMAIN}#" /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_TIMEOUT=10m
APT_OPTS="-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30"
timeout -k 30 "$APT_TIMEOUT" apt-get $APT_OPTS update
DEBIAN_FRONTEND=noninteractive timeout -k 30 "$APT_TIMEOUT" apt-get $APT_OPTS 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 --needed archlinux-keyring
pacman -Syu --noconfirm --needed systemd
rm -rf /var/cache/pacman/pkg/*
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 # nocheck: shell-or-true -- cleanup of a possibly already-removed container
python3 -c 'from pathlib import Path; from cli.administration.deploy.development.coredns import CoreDNSCorefileRenderer; CoreDNSCorefileRenderer(repo_root=Path(".")).render(show_preview=False)'
docker compose up -d coredns
GUIDE_NET="$(docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}' "${INFINITO_RUNNER_PREFIX}-coredns")"
CID="$(docker run -d --privileged --cgroupns=host \
--network "${GUIDE_NET}" --ip "${INFINITO_IP4}" --dns "${INFINITO_DNS_IP}" \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
--tmpfs /run --tmpfs /run/lock \
-v /srv \
-v "${PWD}:${PWD}" \
--entrypoint /sbin/init \
"${BOOT_IMAGE}")"
# shellcheck disable=SC2154
trap 'rc=$?; if [ "${rc}" -ne 0 ]; then _rescue="${INFINITO_RESCUE_DIAGNOSTICS_BASE}/${INFINITO_DISTRO}/${GUIDE_ROLE}"; INFINITO_RESCUE_DIAGNOSTICS_DIR="${_rescue}" python3 utils/diagnostics/container.py "${GUIDE_ROLE}" "guide host boot failure" || true; bash scripts/tests/deploy/utils/rescue_index.sh "${_rescue}"; fi; docker rm -f -v "${CID}" >/dev/null 2>&1 || true; docker compose down >/dev/null 2>&1 || true; docker rmi -f "${BOOT_IMAGE}" >/dev/null 2>&1 || true' EXIT # nocheck: shell-or-true -- best-effort diagnostics + teardown in the EXIT trap
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 # nocheck: shell-or-true -- diagnostics dump on the failure path
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
-60
View File
@@ -1,60 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Replay one role's README "Production" block on the distro the loop is
# currently on, in the mode the role dictates, then release the compose server.
#
# Param:
# GUIDE_ROLE role under test
# GUIDE_MODE host | compose
# INFINITO_DISTRO distro under test (exported by distros.sh)
# INFINITO_IMAGE_TAG tag the CI environment images were pushed under
# INFINITO_PARENT_IMAGE_OWNER owner of the pkgmgr base images
# INFINITO_PARENT_IMAGE_TAG tag of the pkgmgr base images
# INFINITO_RESCUE_DIAGNOSTICS_BASE host dir the rescue snapshots land under
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
cd "${REPO_ROOT}"
: "${GUIDE_ROLE:?GUIDE_ROLE is required (cli.meta.ci.guide_select)}"
: "${GUIDE_MODE:?GUIDE_MODE is required (cli.meta.ci.guide_select)}"
: "${INFINITO_DISTRO:?INFINITO_DISTRO is required (exported by scripts/tests/deploy/distros.sh)}"
: "${INFINITO_PARENT_IMAGE_OWNER:?INFINITO_PARENT_IMAGE_OWNER is required (default.env)}"
: "${INFINITO_PARENT_IMAGE_TAG:?INFINITO_PARENT_IMAGE_TAG is required (default.env)}"
: "${INFINITO_RESCUE_DIAGNOSTICS_BASE:?INFINITO_RESCUE_DIAGNOSTICS_BASE is required (default.env)}"
GUIDE_RUNTIME_IMAGE="$(python3 -m cli.meta.ci.image_ref --kind pkgmgr \
--distro "${INFINITO_DISTRO}" \
--owner "${INFINITO_PARENT_IMAGE_OWNER}" \
--tag "${INFINITO_PARENT_IMAGE_TAG}")"
export GUIDE_RUNTIME_IMAGE
echo "=== Guide: role=${GUIDE_ROLE} mode=${GUIDE_MODE} distro=${INFINITO_DISTRO} ==="
if [ "${GUIDE_MODE}" = "host" ]; then
exec bash "${SCRIPT_DIR}/host_deploy.sh"
fi
INFINITO_IMAGE="$(bash "${REPO_ROOT}/scripts/meta/resolve/image/ci.sh")"
export INFINITO_IMAGE
release() {
rc=$?
if [ "${rc}" -ne 0 ]; then
guide_rescue_dir="${INFINITO_RESCUE_DIAGNOSTICS_BASE}/${INFINITO_DISTRO}/${GUIDE_ROLE}"
INFINITO_RESCUE_DIAGNOSTICS_DIR="${guide_rescue_dir}" \
timeout 1500 python3 utils/diagnostics/container.py \
"${GUIDE_ROLE}" "guide compose post-deploy failure" || true # nocheck: shell-or-true -- best-effort diagnostics + teardown in the EXIT trap
bash scripts/tests/deploy/utils/rescue_index.sh "${guide_rescue_dir}"
fi
make compose-down || true # nocheck: shell-or-true -- best-effort diagnostics + teardown in the EXIT trap
return "${rc}"
}
trap release EXIT
make compose-up
bash "${SCRIPT_DIR}/compose_deploy.sh"