xserver/.github/scripts/DragonFlyBSD/install-pkg.sh
Enrico Weigelt, metux IT consult c4252526cf ci: make BSD VM build jobs resilient to transient failures
The freebsd/netbsd/dragonfly jobs run in vmactions VMs whose boot and
image provisioning flake transiently; a single hiccup aborted the whole
run and had to be restarted by hand. The existing dragonfly retry was
ineffective: it re-ran the VM action without tearing down attempt 1's
leftover libvirt domain, so attempt 2 hit "Guest name 'dragonflybsd' is
already in use" and timed out again.

Two layers of hardening:

 - In-VM pkg installs (freebsd, dragonfly) now retry with backoff and an
   explicit catalogue refresh, so a transient mirror failure no longer
   fails the build (netbsd already had mirror fallback + curl --retry).

 - Each BSD VM step is retried up to 3x, with a new shared
   .github/actions/libvirt-cleanup composite action destroying the
   leftover domain + orphaned qemu between attempts. Only the final
   attempt can fail the job; a success short-circuits the rest. Rolled
   out to freebsd and netbsd too (previously single-attempt) and added
   timeout-minutes to bound a fully-broken job.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 15:00:36 +02:00

51 lines
1 KiB
Shell
Executable file

#!/bin/sh
set -e
# Retry a command a few times with linear backoff. pkg mirrors flake
# transiently (catalogue refresh / package fetch), and a single network
# hiccup must not abort the whole CI run.
retry() {
n=0
max=3
while true; do
n=$((n + 1))
if "$@"; then
return 0
fi
if [ "$n" -ge "$max" ]; then
echo "--> '$*' failed after $max attempts" >&2
return 1
fi
echo "--> '$*' failed (attempt $n/$max), retrying in $((n * 10))s ..." >&2
sleep $((n * 10))
done
}
echo "--> refresh package catalogue"
retry pkg update -f
echo "--> install extra dependencies"
retry pkg install -y \
curl \
libdrm \
libepoll-shim \
libX11 \
libxkbfile \
libxshmfence \
libXfont2 \
libxcvt \
libglvnd \
libepoxy \
libudev-devd \
mesa-dri \
mesa-libs \
meson \
pixman \
pkgconf \
xcb-util-image \
xcb-util-keysyms \
xcb-util-renderutil \
xcb-util-wm \
xkbcomp \
xorgproto