summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.buildkite/hooks/post-command3
-rwxr-xr-xtools/go_branch.sh20
2 files changed, 16 insertions, 7 deletions
diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command
index 8af1369a6..c4c6fc90c 100644
--- a/.buildkite/hooks/post-command
+++ b/.buildkite/hooks/post-command
@@ -51,6 +51,9 @@ if test "${BUILDKITE_COMMAND_EXIT_STATUS}" -ne "0"; then
# Attempt to clear the cache and shut down.
make clean || echo "make clean failed with code $?"
make bazel-shutdown || echo "make bazel-shutdown failed with code $?"
+ # Attempt to clear any Go cache.
+ sudo rm -rf "${HOME}/.cache/go-build"
+ sudo rm -rf "${HOME}/go"
fi
# Kill any running containers (clear state).
diff --git a/tools/go_branch.sh b/tools/go_branch.sh
index 026733d3c..e89a8b098 100755
--- a/tools/go_branch.sh
+++ b/tools/go_branch.sh
@@ -16,14 +16,25 @@
set -xeou pipefail
+# Remember our current directory.
+declare orig_dir
+orig_dir=$(pwd)
+readonly orig_dir
+
+# Record the current working commit.
+declare head
+head=$(git describe --always)
+readonly head
+
# Create a temporary working directory, and ensure that this directory and all
# subdirectories are cleaned up upon exit.
declare tmp_dir
tmp_dir=$(mktemp -d)
readonly tmp_dir
finish() {
- cd / # Leave tmp_dir.
- rm -rf "${tmp_dir}"
+ cd "${orig_dir}" # Leave tmp_dir.
+ rm -rf "${tmp_dir}" # Remove all contents.
+ git checkout -f "${head}" # Restore commit.
}
trap finish EXIT
@@ -70,11 +81,6 @@ declare -r go_merged="${tmp_dir}/merged"
rsync --recursive "${go_amd64}/" "${go_merged}"
rsync --recursive "${go_arm64}/" "${go_merged}"
-# Record the current working commit.
-declare head
-head=$(git describe --always)
-readonly head
-
# We expect to have an existing go branch that we will use as the basis for this
# commit. That branch may be empty, but it must exist. We search for this branch
# using the local branch, the "origin" branch, and other remotes, in order.