diff --git a/helpers.sh b/helpers.sh index 8f0bfc4..3a63184 100644 --- a/helpers.sh +++ b/helpers.sh @@ -37,6 +37,22 @@ print_notice() { __print notice $1 $2 } +# $1 - number of attempts +# $2... - command to run +retry() { + local attempts=$1 delay=15 i + shift + for ((i = 1; i <= attempts; i++)); do + "$@" && return 0 + if ((i < attempts)); then + echo "::warning::'$*' failed (attempt $i/$attempts), retrying in ${delay}s" + sleep $delay + delay=$((delay * 2)) + fi + done + return 1 +} + # No arguments llvm_default_version() { echo "17" diff --git a/setup-build-env/build_pahole.sh b/setup-build-env/build_pahole.sh index 8f403d8..0b88da1 100755 --- a/setup-build-env/build_pahole.sh +++ b/setup-build-env/build_pahole.sh @@ -23,7 +23,7 @@ mkdir -p pahole cd pahole git init git remote add origin ${PAHOLE_ORIGIN} -git fetch --depth=1 origin "${PAHOLE_BRANCH}" +retry 3 git fetch --depth=1 origin "${PAHOLE_BRANCH}" git checkout "${PAHOLE_BRANCH}" cmake -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr