Files
pnpm/.github/scripts/cross-build.sh
Zoltan Kochan 949c8d3b62 ci(release): retry cross builds on transient failures (#14522)
The v12.3.2 release run died in "Package pnpm-napi darwin-x64" because
Apple clang segfaulted while linking the httparse build script. Nothing
in the tree changed; the same Blacksmith image built v12.3.1 fine the
day before. Every other packaging job was cancelled and the release had
to wait for the run to finish before "re-run failed jobs" was possible.

Route the three release cross builds through a wrapper script that
retries up to three times. Cargo keeps the crates a failed attempt
finished, so a retry only redoes the crate that died.

The Windows legs of build-rust and build-pnpr now run the build step
under bash instead of the default pwsh, as the napi packaging job
already did on both Windows targets. The clang-cl environment for
win32-arm64 is exported through GITHUB_ENV and GITHUB_PATH, so it
reaches bash the same way.
2026-09-04 03:12:51 +02:00

27 lines
852 B
Bash
Executable File

#!/usr/bin/env bash
# Runs `cross build` with the given arguments, retrying when it fails.
#
# The release runners occasionally hit transient failures that a plain rerun
# clears: the Apple linker has segfaulted mid-build, and tool downloads can
# time out. Cargo keeps every crate a failed attempt did finish, so a retry
# only redoes the crate that died. This wrapper saves the maintainer from
# waiting on the whole run, then clicking "re-run failed jobs".
set -euo pipefail
attempts=3
delay_seconds=15
for attempt in $(seq 1 "$attempts"); do
if cross build "$@"; then
exit 0
fi
if [ "$attempt" -lt "$attempts" ]; then
echo "::warning::cross build failed (attempt $attempt of $attempts), retrying in ${delay_seconds}s" >&2
sleep "$delay_seconds"
fi
done
echo "::error::cross build failed after $attempts attempts" >&2
exit 1