]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/host-x86_64/dist-various-2/shared.sh
move an `assert!` to the right place
[rust.git] / src / ci / docker / host-x86_64 / dist-various-2 / shared.sh
1 #!/usr/bin/env bash
2 hide_output() {
3   { set +x; } 2>/dev/null
4   on_err="
5 echo ERROR: An error was encountered with the build.
6 cat /tmp/build.log
7 exit 1
8 "
9   trap "$on_err" ERR
10   bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
11   PING_LOOP_PID=$!
12   "$@" &> /tmp/build.log
13   trap - ERR
14   kill $PING_LOOP_PID
15   set -x
16 }
17
18 # Copied from ../../shared.sh
19 function retry {
20   echo "Attempting with retry:" "$@"
21   local n=1
22   local max=5
23   while true; do
24     "$@" && break || {
25       if [[ $n -lt $max ]]; then
26         sleep $n  # don't retry immediately
27         ((n++))
28         echo "Command failed. Attempt $n/$max:"
29       else
30         echo "The command has failed after $n attempts."
31         return 1
32       fi
33     }
34   done
35 }