Skip to content

Commit

Permalink
Better directory naming for logs zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Aug 27, 2024
1 parent c85df48 commit 74935fa
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tools/circleci-prepare-log-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,9 +30,16 @@ cat > ${CT_REPORTS}/index.html << EOL
</html>
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}/
Expand All @@ -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/

0 comments on commit 74935fa

Please sign in to comment.