Skip to content

Commit 96f1fad

Browse files
committed
Retry network fetches across CI so a transient blip does not fail a job
1 parent d63c26b commit 96f1fad

24 files changed

Lines changed: 100 additions & 40 deletions

.github/scripts/git-clone-retry.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# git clone with retry; removes the target dir (last arg) between tries so a partial clone cannot block the retry.
3+
set -u
4+
target=""
5+
for target in "$@"; do :; done
6+
case "$target" in http*|git@*|ssh://*|"") target="" ;; esac
7+
tries="${RETRY_TRIES:-5}"
8+
delay="${RETRY_DELAY:-10}"
9+
i=1
10+
while true; do
11+
[ -n "$target" ] && rm -rf "$target"
12+
git clone "$@" && exit 0
13+
rc=$?
14+
if [ "$i" -ge "$tries" ]; then
15+
echo "git clone failed after $tries attempts (rc=$rc)" >&2
16+
exit "$rc"
17+
fi
18+
echo "git clone attempt $i/$tries failed (rc=$rc); retrying in ${delay}s" >&2
19+
i=$((i + 1))
20+
sleep "$delay"
21+
done

.github/scripts/retry.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Retry a re-runnable command (downloads, docker build) up to RETRY_TRIES times.
3+
set -u
4+
tries="${RETRY_TRIES:-5}"
5+
delay="${RETRY_DELAY:-10}"
6+
i=1
7+
while true; do
8+
"$@" && exit 0
9+
rc=$?
10+
if [ "$i" -ge "$tries" ]; then
11+
echo "retry: '$*' failed after $tries attempts (rc=$rc)" >&2
12+
exit "$rc"
13+
fi
14+
echo "retry: '$*' failed (rc=$rc); attempt $i/$tries, retrying in ${delay}s" >&2
15+
i=$((i + 1))
16+
sleep "$delay"
17+
done

.github/scripts/se050-run.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ mkdir -p "$WORK"
1212
cd "$WORK"
1313

1414
echo "::group::SE050Sim (Rust TCP server)"
15-
git clone -q --depth 1 https://github.com/wolfSSL/simulators sims
15+
"$ROOT/.github/scripts/git-clone-retry.sh" -q --depth 1 https://github.com/wolfSSL/simulators sims
1616
# se050-sim depends on the se050 crate at ../nxp-se050/se050 (its own repo)
17-
git clone -q --branch sim-compat --depth 1 \
17+
"$ROOT/.github/scripts/git-clone-retry.sh" -q --branch sim-compat --depth 1 \
1818
https://github.com/LinuxJedi/nxp-se050.git sims/SE050Sim/nxp-se050
1919
( cd sims/SE050Sim/se050-sim && cargo build --release --bin tcp_server )
2020
SIM="$WORK/sims/SE050Sim/wolfcrypt-test"
2121
echo "::endgroup::"
2222

2323
echo "::group::plug-and-trust SDK + wolfSSL HostCrypto patch + sim overlays"
24-
git clone -q --depth 1 --branch v04.07.01 https://github.com/NXP/plug-and-trust simw-top
25-
curl -fsSL https://raw.githubusercontent.com/wolfSSL/osp/master/nxp-se05x-middleware/simw-top-v040701.patch \
26-
| ( cd simw-top && patch -p1 -l --forward --fuzz=3 )
24+
"$ROOT/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch v04.07.01 https://github.com/NXP/plug-and-trust simw-top
25+
"$ROOT/.github/scripts/retry.sh" curl -fsSL -o "$WORK/osp-se050.patch" \
26+
https://raw.githubusercontent.com/wolfSSL/osp/master/nxp-se05x-middleware/simw-top-v040701.patch
27+
( cd simw-top && patch -p1 -l --forward --fuzz=3 < "$WORK/osp-se050.patch" )
2728
test -f simw-top/sss/src/wolfssl/fsl_sss_wolfssl_apis.c
2829
cp "$SIM/i2c_a7.c" simw-top/hostlib/hostLib/platform/linux/i2c_a7.c
2930
cp "$SIM/se05x_reset.c" simw-top/hostlib/hostLib/platform/rsp/se05x_reset.c
@@ -32,7 +33,7 @@ cp "$SIM/CMakeLists.txt" simw-top/CMakeLists.txt
3233
echo "::endgroup::"
3334

3435
echo "::group::wolfSSL pass A (no se050, so the SDK can link -lwolfssl)"
35-
git clone -q --depth 1 https://github.com/wolfSSL/wolfssl
36+
"$ROOT/.github/scripts/git-clone-retry.sh" -q --depth 1 https://github.com/wolfSSL/wolfssl wolfssl
3637
( cd wolfssl && ./autogen.sh >/dev/null 2>&1 && \
3738
./configure --enable-keygen --enable-cmac \
3839
CFLAGS="-DWOLFSSL_SE050_NO_TRNG -DSIZEOF_LONG_LONG=8" >/dev/null && \

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Build wolfSSL for ${{ matrix.mode }}
6969
run: |
7070
set -euo pipefail
71-
git clone -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
71+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
7272
cd /tmp/wolfssl
7373
./autogen.sh >/dev/null
7474
if [ "${{ matrix.mode }}" = asan ]; then

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
test -e wolfssl/.git || { echo "FAIL: wolfssl submodule not checked out"; exit 1; }
6363
# Replace the tree: fetching into the shallow submodule races on .git/modules/*/shallow
6464
rm -rf wolfssl
65-
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
65+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
6666
https://github.com/wolfSSL/wolfssl.git wolfssl
6767
echo "wolfssl now at ${{ matrix.wolfssl_ref }}: $(git -C wolfssl rev-parse --short HEAD)"
6868

.github/workflows/bsdkm.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,23 @@ jobs:
5959
if [ ! -f /usr/src/sys/conf/kmod.mk ]; then
6060
# keyed off the running kernel, so this cannot drift from the VM
6161
rel=$(uname -r | sed 's/-p[0-9]*$//')
62-
fetch -o /tmp/src.txz "https://download.freebsd.org/releases/amd64/${rel}/src.txz"
62+
f=1; while :; do
63+
fetch -o /tmp/src.txz "https://download.freebsd.org/releases/amd64/${rel}/src.txz" && break
64+
[ "$f" -ge 5 ] && { echo "FAIL: src.txz fetch failed"; exit 1; }
65+
f=$((f + 1)); sleep 10
66+
done
6367
tar -C / -xf /tmp/src.txz
6468
fi
6569
test -f /usr/src/sys/conf/kmod.mk
6670
67-
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
68-
https://github.com/wolfSSL/wolfssl /tmp/wolfssl
71+
# FreeBSD VM has no bash, so retry the clone with a POSIX sh loop
72+
n=1; while :; do
73+
rm -rf /tmp/wolfssl
74+
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
75+
https://github.com/wolfSSL/wolfssl /tmp/wolfssl && break
76+
[ "$n" -ge 5 ] && { echo "FAIL: wolfssl clone failed"; exit 1; }
77+
n=$((n + 1)); sleep 10
78+
done
6979
cd /tmp/wolfssl
7080
./autogen.sh
7181
./configure --enable-freebsdkm --enable-cryptonly \

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Fetch the wolfSSL ref under test
4747
run: |
4848
set -euo pipefail
49-
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
49+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
5050
https://github.com/wolfSSL/wolfssl cmake/wolfssl
5151
git -C cmake/wolfssl log -1 --format='wolfssl at ${{ matrix.wolfssl_ref }}: %h %s'
5252

.github/workflows/config-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- name: Build wolfSSL (${{ matrix.name }})
7373
run: |
7474
set -euo pipefail
75-
git clone -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
75+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
7676
cd /tmp/wolfssl
7777
./autogen.sh >/dev/null
7878
./configure --enable-ecc --enable-ed25519 --enable-aesgcm --enable-keygen ${{ matrix.opts }} \

.github/workflows/cross-arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Cross-build wolfSSL (${{ matrix.name }})
7070
run: |
7171
set -euo pipefail
72-
git clone -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
72+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch master https://github.com/wolfSSL/wolfssl /tmp/wolfssl
7373
cd /tmp/wolfssl
7474
./autogen.sh >/dev/null
7575
host=""

.github/workflows/csharp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Build wolfSSL with the C# wrapper's user_settings.h
5656
run: |
5757
set -euo pipefail
58-
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
58+
bash "$GITHUB_WORKSPACE/.github/scripts/git-clone-retry.sh" -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
5959
https://github.com/wolfSSL/wolfssl /tmp/wolfssl
6060
cd /tmp/wolfssl
6161
# wrapper/CSharp/user_settings.h already enables ML-KEM, ML-DSA and

0 commit comments

Comments
 (0)