Skip to content

Commit 8d577d7

Browse files
rahlkclaude
andcommitted
ci: make musl toolchain/zlib download resilient to musl.cc outages
The musllinux legs failed with 'Failed to connect to musl.cc port 443: Connection timed out'. musl.cc is chronically flaky. Download the musl toolchain from a GitHub-hosted mirror (musl-cc/musl.cc) first, falling back to musl.cc; do the same for zlib (madler/zlib release, then zlib.net, then zlib.net/fossils). Add curl --retry with a connect timeout. Avoids --retry-all-errors since the manylinux_2_28 container's curl 7.61 predates it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1fae7ce commit 8d577d7

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

.github/scripts/setup-musl.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,30 @@ esac
2121
PREFIX=/opt/musl
2222
mkdir -p "$PREFIX"
2323

24-
toolchain_url="https://musl.cc/${MUSL_TRIPLE}-native.tgz"
25-
echo "setup-musl: downloading toolchain $toolchain_url"
26-
curl -fsSL "$toolchain_url" | tar -xz -C "$PREFIX" --strip-components=1
24+
# Download a file, trying each mirror in turn with retries. musl.cc is chronic-
25+
# ally flaky (the first release run died on "connect to musl.cc timed out"), so
26+
# a GitHub-hosted mirror is tried first — GitHub is reliably reachable from CI.
27+
# `--retry-all-errors` is avoided on purpose: the manylinux_2_28 container ships
28+
# curl 7.61, which predates that flag. Plain `--retry` covers transient timeouts.
29+
fetch() {
30+
dest="$1"; shift
31+
for url in "$@"; do
32+
echo "setup-musl: fetching $url"
33+
if curl -fL --retry 5 --retry-delay 3 --connect-timeout 20 --max-time 600 \
34+
-o "$dest" "$url"; then
35+
return 0
36+
fi
37+
echo "setup-musl: mirror failed, trying next" >&2
38+
done
39+
echo "setup-musl: all mirrors failed for ${dest##*/}" >&2
40+
return 1
41+
}
42+
43+
toolchain_tgz="$(mktemp --suffix=.tgz)"
44+
fetch "$toolchain_tgz" \
45+
"https://github.com/musl-cc/musl.cc/releases/download/v0.0.1/${MUSL_TRIPLE}-native.tgz" \
46+
"https://musl.cc/${MUSL_TRIPLE}-native.tgz"
47+
tar -xzf "$toolchain_tgz" -C "$PREFIX" --strip-components=1
2748

2849
export PATH="$PREFIX/bin:$PATH"
2950
echo "$PREFIX/bin" >> "$GITHUB_PATH"
@@ -33,7 +54,12 @@ echo "$PREFIX/bin" >> "$GITHUB_PATH"
3354
ZLIB_VERSION=1.3.1
3455
workdir="$(mktemp -d)"
3556
echo "setup-musl: building static zlib ${ZLIB_VERSION} with ${MUSL_TRIPLE}-gcc"
36-
curl -fsSL "https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz" | tar -xz -C "$workdir" --strip-components=1
57+
zlib_tgz="$(mktemp --suffix=.tar.gz)"
58+
fetch "$zlib_tgz" \
59+
"https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz" \
60+
"https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz" \
61+
"https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz"
62+
tar -xzf "$zlib_tgz" -C "$workdir" --strip-components=1
3763
(
3864
cd "$workdir"
3965
CC="${MUSL_TRIPLE}-gcc" ./configure --static --prefix="$PREFIX"

0 commit comments

Comments
 (0)