Files
computer-playbook/scripts/github/runner/assert_architecture.sh
T
kevinveenbirkenbachandClaude Opus 5 e44778afaa fix(ci): assert the architecture that the context actually promises
INFINITO_ARCHITECTURE means two different things. In CI it is the runner's
hardware, delivered by `runs-on`. Locally it is the platform app containers are
created for, delivered by qemu. The check asserted the first everywhere, so a
local run that honoured the assignment by emulation was reported as a mismatch,
with an error blaming RUNNERS where nothing was wrong.

Each context is now checked against its own promise. On a real runner the
uname must match, unchanged. Anywhere else the host must be able to execute the
assigned platform, which is verified by running a container of it rather than
by reading /proc/sys/fs/binfmt_misc, since that directory reads as empty from a
sandboxed shell whether or not a handler is registered.

Nothing is skipped and nothing passes quietly. A host that cannot deliver the
assigned architecture fails here, in the first second of the job, and names the
two commands that fix it. Five arm64 deploys died instead at
`exec /bin/sh: exec format error` deep inside an Ansible role, each after
fifteen to twenty minutes of setup.

This replaces the `exit 0` under act that an earlier version of this change
introduced. That version swallowed exactly what this check exists to catch: a
row assigned arm64 ran entirely on amd64 and would have reported green.

Verified, all four branches: amd64 native passes; arm64 with emulation present
passes as emulated; arm64 without it exits 1 with the remedy; a real-CI
mismatch exits 1 with the RUNNERS hint. shellcheck clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 09:29:13 +02:00

35 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Env:
# INFINITO_ARCHITECTURE the architecture the matrix assigned (required)
set -euo pipefail
: "${INFINITO_ARCHITECTURE:?Missing INFINITO_ARCHITECTURE}"
PROBE_IMAGE="alpine:3"
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "${script_dir}/../../.." && pwd)"
actual="$("${repo_root}/scripts/meta/resolve/architecture.sh")"
if [[ "${actual}" == "${INFINITO_ARCHITECTURE}" ]]; then
echo "🏗️ ${actual} runs natively here (uname -m: $(uname -m))"
exit 0
fi
if [[ -n "${GITHUB_ACTIONS:-}" && -z "${ACT:-}" ]]; then
echo "❌ architecture mismatch: the matrix assigned '${INFINITO_ARCHITECTURE}', the runner is '${actual}' (uname -m: $(uname -m))." >&2
echo " The runner label for '${INFINITO_ARCHITECTURE}' no longer resolves to that hardware; fix RUNNERS in utils/github/variant/pools.py." >&2
exit 1
fi
if ! docker run --rm --platform "linux/${INFINITO_ARCHITECTURE}" "${PROBE_IMAGE}" true >/dev/null 2>&1; then
echo "❌ the matrix assigned '${INFINITO_ARCHITECTURE}' and this '${actual}' host cannot execute it." >&2
echo " Register the emulation, then re-run:" >&2
echo " sudo systemctl restart systemd-binfmt.service" >&2
echo " docker run --privileged --rm tonistiigi/binfmt --install ${INFINITO_ARCHITECTURE}" >&2
exit 1
fi
echo "🏗️ ${INFINITO_ARCHITECTURE} runs emulated on this ${actual} host"