From 74935fa0ef2c7108465831f171398b49c7ff5b96 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 27 Aug 2024 21:39:15 +0200 Subject: [PATCH] Better directory naming for logs zip file --- tools/circleci-prepare-log-dir.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/circleci-prepare-log-dir.sh b/tools/circleci-prepare-log-dir.sh index 5e9347c5644..86b3ae0740e 100755 --- a/tools/circleci-prepare-log-dir.sh +++ b/tools/circleci-prepare-log-dir.sh @@ -5,6 +5,7 @@ source tools/circleci-helpers.sh set -euo pipefail IFS=$'\n\t' +# Relative directory name CT_REPORTS=$(ct_reports_dir) mkdir -p ${CT_REPORTS}/small mkdir -p ${CT_REPORTS}/big @@ -29,9 +30,16 @@ cat > ${CT_REPORTS}/index.html << EOL EOL +CT_REPORTS_FULL=$(cd "$CT_REPORTS" && pwd) + now=`date +'%Y-%m-%d_%H.%M.%S'` -LOG_DIR_ROOT=${CT_REPORTS}/logs/${now} -LOG_ZIP=${CT_REPORTS}/logs_${now}.zip +# Replace all occurrences of / with _ +PREFIX="${CT_REPORTS//\//_}" + +# Optimize naming, so it is easy to extract on MacOS just by clicking it +# and with reasonable directory names +LOG_DIR_ROOT=${CT_REPORTS}/logs/${PREFIX}_${now} +LOG_ZIP=${CT_REPORTS_FULL}/logs_${PREFIX}_${now}.zip for dev_node_logs_path in `find _build -name log -type d`; do dev_node=$(basename $(dirname $(dirname $(dirname ${dev_node_logs_path})))) LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/ @@ -42,8 +50,15 @@ done cp *.log ${LOG_DIR_ROOT} cp big_tests/*.log ${LOG_DIR_ROOT} || true +OLD_DIR=$(pwd) + +# cd so we don't include nested dirs in the archive (for example, PR/4366/236412) +cd "$LOG_DIR_ROOT/.." + # Zip to safe space -zip -9 -r "$LOG_ZIP" "$LOG_DIR_ROOT" +zip -9 -r "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")" + +cd "$OLD_DIR" # Slightly faster than removing mv "$LOG_DIR_ROOT" /tmp/