From 0ee8d9cde9d4f7f43fef760bb6b38d0df09327e3 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 19 Jul 2026 02:35:32 +0200 Subject: [PATCH] fix(ci): extract the guide host-deploy step into a script The inline run: block for the host-mode deploy exceeded the 11-line inline-script-block cap. Move the body to scripts/github/guide/host_deploy.sh and reduce the workflow step to a single bash invocation. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/test-guide.yml | 27 +------------------------ scripts/github/guide/host_deploy.sh | 31 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-) create mode 100755 scripts/github/guide/host_deploy.sh diff --git a/.github/workflows/test-guide.yml b/.github/workflows/test-guide.yml index c7e8a30574..5558872de7 100644 --- a/.github/workflows/test-guide.yml +++ b/.github/workflows/test-guide.yml @@ -70,32 +70,7 @@ jobs: - name: 🖥️ Install a host role inside its pkgmgr distro container if: ${{ env.GUIDE_MODE == 'host' }} shell: bash - run: | - set -euo pipefail - # 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 - docker pull "$GUIDE_RUNTIME_IMAGE" - # Exception: boot systemd as PID 1 because the host role manages user - # timers/units; enable-linger below gives root a --user manager. - 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 \ - "$GUIDE_RUNTIME_IMAGE") - trap 'docker rm -f "$CID" >/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 - docker exec "$CID" systemctl is-system-running 2>/dev/null | grep -qE 'running|degraded' - docker exec "$CID" bash -lc 'loginctl enable-linger root && systemctl start user@0.service' - docker exec -i -w "$PWD" "$CID" bash -s < /tmp/host-deploy.sh + run: bash scripts/github/guide/host_deploy.sh - name: 🖥️ Boot the systemd server for a compose role if: ${{ env.GUIDE_MODE == 'compose' }} diff --git a/scripts/github/guide/host_deploy.sh b/scripts/github/guide/host_deploy.sh new file mode 100755 index 0000000000..f21ff0a32e --- /dev/null +++ b/scripts/github/guide/host_deploy.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Install a host role inside its pkgmgr distro container against localhost. +# Env: GUIDE_ROLE, GUIDE_RUNTIME_IMAGE. +set -euo pipefail + +# 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 +docker pull "${GUIDE_RUNTIME_IMAGE}" + +# Exception: boot systemd as PID 1 because the host role manages user +# timers/units; enable-linger below gives root a --user manager. +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 \ + "${GUIDE_RUNTIME_IMAGE}")" +trap 'docker rm -f "${CID}" >/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 +docker exec "${CID}" systemctl is-system-running 2>/dev/null | grep -qE 'running|degraded' +docker exec "${CID}" bash -lc 'loginctl enable-linger root && systemctl start user@0.service' +docker exec -i -w "${PWD}" "${CID}" bash -s