summaryrefslogtreecommitdiffstats
path: root/src/ci/publish_toolstate.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/ci/publish_toolstate.sh
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ci/publish_toolstate.sh')
-rwxr-xr-xsrc/ci/publish_toolstate.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/ci/publish_toolstate.sh b/src/ci/publish_toolstate.sh
new file mode 100755
index 000000000..691df04e7
--- /dev/null
+++ b/src/ci/publish_toolstate.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+set -euo pipefail
+IFS=$'\n\t'
+
+source "$(cd "$(dirname "$0")" && pwd)/shared.sh"
+
+# The following lines are also found in src/bootstrap/toolstate.rs,
+# so if updating here, please also update that file.
+
+export MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
+
+git config --global user.email '7378925+rust-toolstate-update@users.noreply.github.com'
+git config --global user.name 'Rust Toolstate Update'
+git config --global credential.helper store
+printf 'https://%s:x-oauth-basic@github.com\n' "$TOOLSTATE_REPO_ACCESS_TOKEN" \
+ > "$HOME/.git-credentials"
+git clone --depth=1 $TOOLSTATE_REPO
+
+GIT_COMMIT="$(git rev-parse HEAD)"
+GIT_COMMIT_MSG="$(git log --format=%s -n1 HEAD)"
+
+cd rust-toolstate
+FAILURE=1
+for RETRY_COUNT in 1 2 3 4 5; do
+ # The purpose of this is to publish the new "current" toolstate in the toolstate repo.
+ # This happens post-landing, on master.
+ # (Publishing the per-commit test results happens pre-landing in src/bootstrap/toolstate.rs).
+ "$(ciCheckoutPath)/src/tools/publish_toolstate.py" "$GIT_COMMIT" \
+ "$GIT_COMMIT_MSG" \
+ "$MESSAGE_FILE" \
+ "$TOOLSTATE_REPO_ACCESS_TOKEN"
+ # `git commit` failing means nothing to commit.
+ FAILURE=0
+ git commit -a -F "$MESSAGE_FILE" || break
+ # On failure randomly sleep for 0 to 3 seconds as a crude way to introduce jittering.
+ git push origin master && break || sleep $(LC_ALL=C tr -cd 0-3 < /dev/urandom | head -c 1)
+ FAILURE=1
+ git fetch origin master
+ git reset --hard origin/master
+done