diff options
author | Adin Scannell <ascannell@google.com> | 2020-12-11 11:50:08 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-12-11 11:52:43 -0800 |
commit | 76c2f21cecf6c690aaf3aba8eccbc593eb3a6305 (patch) | |
tree | cc90159eeeb7cbe3e96c3188702a3566b9616c61 /.buildkite/hooks/post-command | |
parent | 3c673caf86c83070786a6baec0e92e109bfcbb54 (diff) |
Add local hooks for BuildKite.
PiperOrigin-RevId: 347044353
Diffstat (limited to '.buildkite/hooks/post-command')
-rw-r--r-- | .buildkite/hooks/post-command | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command new file mode 100644 index 000000000..ce3111f3c --- /dev/null +++ b/.buildkite/hooks/post-command @@ -0,0 +1,24 @@ +# Upload test logs on failure, if there are any. +if [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" -ne "0" ]]; then + declare log_count=0 + for log in $(make testlogs 2>/dev/null | sort | uniq); do + buildkite-agent artifact upload "${log}" + log_count=$((${log_count}+1)) + # N.B. If *all* tests fail due to some common cause, then we will + # end up spending way too much time uploading logs. Instead, we just + # upload the first 100 and stop. That is hopefully enough to debug. + if [[ "${log_count}" -ge 100 ]]; then + echo "Only uploaded first 100 failures; skipping the rest." + break + fi + done + # 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 $?" +fi + +# Kill any running containers (clear state). +CONTAINERS="$(docker ps -q)" +if ! [[ -z "${CONTAINERS}" ]]; then + docker container kill ${CONTAINERS} 2>/dev/null || true +fi
\ No newline at end of file |