From 5a0803c66ec4e080bbd72d1383a1ee5cc2a5d7ff Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 11 Nov 2022 00:33:51 -0800 Subject: [PATCH] builtkite: collect runtime logs PiperOrigin-RevId: 487748622 --- .buildkite/hooks/post-command | 8 ++++++-- .buildkite/hooks/pre-command | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index aa7b50e43..accc389c6 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -54,8 +54,12 @@ rm -rf "${profile_output}" # Clean the bazel cache, if there's failure. if test "${BUILDKITE_COMMAND_EXIT_STATUS}" -ne "0"; then set -x - if [ -d "/tmp/${BUILDKITE_JOB_ID}/" ]; then - tar -czf "/tmp/${BUILDKITE_JOB_ID}.tar.gz" -C /tmp/ "${BUILDKITE_JOB_ID}" + # LINT.IfChange + runtime="buildkite_runtime_${BUILDKITE_BRANCH}-${BUILDKITE_BUILD_ID}" + runtime="$(echo "$runtime" | sed -r 's~[^-_a-z0-9]+~_~g')" + # LINT.ThenChange(pre-command) + if [ -d "/tmp/${runtime}/" ]; then + tar -czf "/tmp/${BUILDKITE_JOB_ID}.tar.gz" -C /tmp/ "${runtime}" buildkite-agent artifact upload "/tmp/${BUILDKITE_JOB_ID}.tar.gz" fi # Attempt to clear the cache and shut down. diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 71ee0ebf1..b26361652 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -35,8 +35,10 @@ export TOTAL_PARTITIONS=${BUILDKITE_PARALLEL_JOB_COUNT:-1} # Set the system-wide Docker runtime name after the BuildKite branch name. # Remove any slashes and other characters that are not supported in Docker # runtime names. The runtime name must be a single valid path component. +# LINT.IfChange export RUNTIME="buildkite_runtime_${BUILDKITE_BRANCH}-${BUILDKITE_BUILD_ID}" export RUNTIME="$(echo "$RUNTIME" | sed -r 's~[^-_a-z0-9]+~_~g')" +# LINT.ThenChange(post-command) # If running in a container, set the reload command appropriately. if [[ -x /tmp/buildkite-reload-host-docker/reload ]]; then