Files
computer-playbook/scripts/image/push_all.sh
kevinveenbirkenbachandClaude Opus 5 7d8505c8c3 perf(ci): fold the matrix job into the image job and stream its output
Computing the distro list no longer justifies a runner of its own: it is
two steps, and the job that consumes them already checks the repository
out. The workflow now occupies one runner instead of seven.

The step also went silent for minutes at a time, printing five pids and
then nothing until every build had finished. Each build's output is piped
through a [distro][HH:MM:SS] stamp as it arrives, so the log shows what is
happening while it happens; tee still files the per-distro logs for the
artifact, and the replay block at the end is gone as duplication.

A pipeline hands $! the pid of tee rather than of the build, which would
have swallowed every failure, so each build runs in a subshell under
pipefail and wait reads that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 21:48:12 +02:00

74 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Argv: <distro> [<distro> ...] (falls back to INFINITO_DISTROS)
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "${script_dir}/../.." && pwd)"
distros=("$@")
if ((${#distros[@]} == 0)); then
: "${INFINITO_DISTROS:?Missing INFINITO_DISTROS and no distro arguments}"
read -r -a distros <<<"${INFINITO_DISTROS}"
fi
log_dir="${BUILD_LOG_DIR:-${repo_root}/build/image-logs}"
mkdir -p "${log_dir}"
stamp() {
local distro="$1"
local line
while IFS= read -r line; do
printf '[%s][%(%H:%M:%S)T] %s\n' "${distro}" -1 "${line}"
done
}
# shellcheck source=scripts/meta/env/load.sh
source "${repo_root}/scripts/meta/env/load.sh"
echo "🏗️ Building ${#distros[@]} image(s) concurrently: ${distros[*]}"
echo " Logs: ${log_dir}"
gap_prev=1
gap=2
pids=()
started=0
for distro in "${distros[@]}"; do
if ((started > 0)); then
sleep "${gap}"
gap_next=$((gap_prev + gap))
gap_prev="${gap}"
gap="${gap_next}"
fi
(
set -o pipefail
MATRIX_DISTRO="${distro}" bash "${script_dir}/push.sh" 2>&1 |
stamp "${distro}" |
tee "${log_dir}/${distro}.log"
) &
pids+=("$!")
started=$((started + 1))
done
failed=()
index=0
for pid in "${pids[@]}"; do
distro="${distros[${index}]}"
if wait "${pid}"; then
echo "✅ ${distro}"
else
echo "❌ ${distro}"
failed+=("${distro}")
fi
index=$((index + 1))
done
if ((${#failed[@]} > 0)); then
echo "❌ Failed distros: ${failed[*]}"
exit 1
fi
echo "🎉 All ${#distros[@]} image(s) built and pushed"