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 @@
33set -x
44set -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
625BUILDDIR="$(pwd)"
726
827sudo 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 -
10sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
28retry 'wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -'
29retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
1130
1231sudo apt-get remove -y llvm-*
1332sudo rm -rf /usr/local/*
1433
15# Some APT mirrors can be flaky, retry the download instead of failing right
16# away.
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 \
34retry sudo apt-get update -q
35retry sudo apt-get install -y \
2236 libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \
2337 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
3339QEMUBASE="qemu-linux-x86_64-5.1.0"
3440wget https://ziglang.org/deps/$QEMUBASE.tar.xz