authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-04 13:04:10+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-04 13:11:45+01:00
log77031baf982ec5d1d6e3f16252298af2f0325d42
tree30e9abb0c350e605c7d9c853732b341a97c55d14
parent58241364cb09debd0effd9f7fb1d1a7eeaaae7c7

ci: Prevent some more CI failures

Many times the CI pipeline fails in the early stages because the APT repo for LLVM is being updated. Add a retry mechanism for some more APT commands.

1 files changed, 23 insertions(+), 17 deletions(-)

ci/azure/linux_script+23-17
...@@ -3,32 +3,38 @@...@@ -3,32 +3,38 @@
3set -x3set -x
4set -e4set -e
55
6# This parameters we wait at most 2mins, it should be enough to sort out any
7# transient error.
8CMD_MAX_RETRY=12
9CMD_WAIT_TIME=10s
10
11# Execute the given command and, in case of failure, try to execute it again
12# after sleeping for CMD_WAIT_TIME.
13# We give up after retrying CMD_MAX_RETRY times.
14retry() {
15 for i in $(seq 1 "$CMD_MAX_RETRY"); do
16 "$@" && return
17 echo "command \"$@\" failed, retrying..."
18 sleep ${CMD_WAIT_TIME}
19 done
20
21 echo "command \"$@\" failed, giving up..."
22 exit 1
23}
24
6BUILDDIR="$(pwd)"25BUILDDIR="$(pwd)"
726
8sudo sh -c 'echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list'27sudo sh -c 'echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list'
9wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -28retry 'wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -'
10sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test29retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
1130
12sudo apt-get remove -y llvm-*31sudo apt-get remove -y llvm-*
13sudo rm -rf /usr/local/*32sudo rm -rf /usr/local/*
1433
15# Some APT mirrors can be flaky, retry the download instead of failing right34retry sudo apt-get update -q
16# away.35retry sudo apt-get install -y \
17APT_MAX_RETRY=3
18
19for i in $(seq 1 "$APT_MAX_RETRY"); do
20 sudo apt-get update -q
21 sudo apt-get install -y \
22 libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \36 libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \
23 gcc-7 g++-7 ninja-build tidy \37 gcc-7 g++-7 ninja-build tidy \
24 && break
25 if [ "$i" -eq "$APT_MAX_RETRY" ]; then
26 echo 'apt-get failed, giving up...'
27 exit 1
28 fi
29 echo 'apt-get failed, retrying...'
30 sleep 5s
31done
3238
33QEMUBASE="qemu-linux-x86_64-5.1.0"39QEMUBASE="qemu-linux-x86_64-5.1.0"
34wget https://ziglang.org/deps/$QEMUBASE.tar.xz40wget https://ziglang.org/deps/$QEMUBASE.tar.xz