From 771d3c3c9da00b620878cd57697b867e42d9cd3d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 13 Jan 2023 17:47:41 +1000 Subject: [PATCH] CI: Retry downloading commands on Linux The Azure Ubuntu package server, in particular, seems to be very unreliable. Hopefully within 10 attempts it'll complete the package download in such cases. --- .github/workflows/scripts/linux/appimage-qt.sh | 5 ++++- .github/workflows/scripts/linux/functions.sh | 16 ++++++++++++++++ .../scripts/linux/install-packages-qt.sh | 13 ++++++++----- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 .github/workflows/scripts/linux/functions.sh diff --git a/.github/workflows/scripts/linux/appimage-qt.sh b/.github/workflows/scripts/linux/appimage-qt.sh index 729c8d6372..f5d6c1dbb5 100755 --- a/.github/workflows/scripts/linux/appimage-qt.sh +++ b/.github/workflows/scripts/linux/appimage-qt.sh @@ -25,6 +25,9 @@ # # For more information, please refer to +SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") +source "$SCRIPTDIR/functions.sh" + if [ "$#" -ne 4 ]; then echo "Syntax: $0 " exit 1 @@ -190,7 +193,7 @@ declare -a QTPLUGINS=( set -e if [ ! -f appimagetool-x86_64.AppImage ]; then - wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + retry_command wget -O appimagetool-x86_64.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage chmod +x appimagetool-x86_64.AppImage fi diff --git a/.github/workflows/scripts/linux/functions.sh b/.github/workflows/scripts/linux/functions.sh new file mode 100755 index 0000000000..63b7dd9568 --- /dev/null +++ b/.github/workflows/scripts/linux/functions.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function retry_command { + # Package servers tend to be unreliable at times.. + # Retry a bunch of times. + local RETRIES=10 + + for i in $(seq 1 "$RETRIES"); do + "$@" && break + if [ "$i" == "$RETRIES" ]; then + echo "Command \"$@\" failed after ${RETRIES} retries." + exit 1 + fi + done +} + diff --git a/.github/workflows/scripts/linux/install-packages-qt.sh b/.github/workflows/scripts/linux/install-packages-qt.sh index fee482f187..8a82065a5e 100755 --- a/.github/workflows/scripts/linux/install-packages-qt.sh +++ b/.github/workflows/scripts/linux/install-packages-qt.sh @@ -1,5 +1,8 @@ #!/bin/bash +SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") +source "$SCRIPTDIR/functions.sh" + set -e # Packages - Build and Qt @@ -57,18 +60,18 @@ declare -a PCSX2_PACKAGES=( ) if [ "${COMPILER}" = "gcc" ]; then - BUILD_PACKAGES+=("g++-10") + BUILD_PACKAGES+=("g++-10") else - BUILD_PACKAGES+=("llvm-12" "lld-12" "clang-12") + BUILD_PACKAGES+=("llvm-12" "lld-12" "clang-12") fi -sudo apt-get -qq update +retry_command sudo apt-get -qq update && break # Install packages needed for building echo "Will install the following packages for building - ${BUILD_PACKAGES[*]}" -sudo apt-get -y install "${BUILD_PACKAGES[@]}" +retry_command sudo apt-get -y install "${BUILD_PACKAGES[@]}" # Install packages needed by pcsx2 PCSX2_PACKAGES=("${PCSX2_PACKAGES[@]}") echo "Will install the following packages for pcsx2 - ${PCSX2_PACKAGES[*]}" -sudo apt-get -y install "${PCSX2_PACKAGES[@]}" +retry_command sudo apt-get -y install "${PCSX2_PACKAGES[@]}"