about summary refs log tree commit diff
path: root/src/ci/docker/scripts/shared.sh
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-10 08:08:03 +0000
committerbors <bors@rust-lang.org>2023-12-10 08:08:03 +0000
commit92ab9d65bb8f3a1b167c2ccb9d22de301a7aef45 (patch)
tree0a9542f67746bf7a90b8bb4881b56de39b138cb9 /src/ci/docker/scripts/shared.sh
parentaa7afff8c619fc9c04515b7cef57d72dc3c7e51e (diff)
parent035d86594ddcaec12b59c35f8de1a99c3b8b81fb (diff)
downloadrust-92ab9d65bb8f3a1b167c2ccb9d22de301a7aef45.tar.gz
rust-92ab9d65bb8f3a1b167c2ccb9d22de301a7aef45.zip
Auto merge of #3217 - RalfJung:rustup, r=RalfJung
Rustup

Pulls in https://github.com/rust-lang/rust/pull/117953 (in preparation for implementing those intrinsics)
Diffstat (limited to 'src/ci/docker/scripts/shared.sh')
-rw-r--r--src/ci/docker/scripts/shared.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/ci/docker/scripts/shared.sh b/src/ci/docker/scripts/shared.sh
new file mode 100644
index 00000000000..9969659088d
--- /dev/null
+++ b/src/ci/docker/scripts/shared.sh
@@ -0,0 +1,42 @@
+#!/bin/false
+# shellcheck shell=bash
+
+# This file is intended to be sourced with `. shared.sh` or
+# `source shared.sh`, hence the invalid shebang and not being
+# marked as an executable file in git.
+
+function hide_output {
+  { set +x; } 2>/dev/null
+  on_err="
+echo ERROR: An error was encountered with the build.
+cat /tmp/build.log
+exit 1
+"
+  trap "$on_err" ERR
+  bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
+  PING_LOOP_PID=$!
+  "$@" &> /tmp/build.log
+  trap - ERR
+  kill $PING_LOOP_PID
+  set -x
+}
+
+# See https://unix.stackexchange.com/questions/82598
+# Duplicated in src/ci/shared.sh
+function retry {
+  echo "Attempting with retry:" "$@"
+  local n=1
+  local max=5
+  while true; do
+    "$@" && break || {
+      if [[ $n -lt $max ]]; then
+        sleep $n  # don't retry immediately
+        ((n++))
+        echo "Command failed. Attempt $n/$max:"
+      else
+        echo "The command has failed after $n attempts."
+        return 1
+      fi
+    }
+  done
+}