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.
This commit is contained in:
Stenzek 2023-01-13 17:47:41 +10:00 committed by refractionpcsx2
parent 8c21765c0f
commit 771d3c3c9d
3 changed files with 28 additions and 6 deletions

View File

@ -25,6 +25,9 @@
#
# For more information, please refer to <http://unlicense.org/>
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
source "$SCRIPTDIR/functions.sh"
if [ "$#" -ne 4 ]; then
echo "Syntax: $0 <path to pcsx2 directory> <path to build directory> <deps prefix> <output name>"
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

16
.github/workflows/scripts/linux/functions.sh vendored Executable file
View File

@ -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
}

View File

@ -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[@]}"