Skip to content

Commit

Permalink
Merge pull request #4366 from esl/compress-logs-on-s3
Browse files Browse the repository at this point in the history
Zip MIM logs before uploading to S3
  • Loading branch information
gustawlippa authored Aug 29, 2024
2 parents ee1d5e4 + 3ae6c54 commit 03107db
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 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,14 +30,35 @@ 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}
# 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}.tar.gz
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}/log
LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/
mkdir -p ${LOG_DIR}
cp ${dev_node_logs_path}/* ${LOG_DIR}
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
tar -czvf "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")"

cd "$OLD_DIR"

# Slightly faster than removing
mv "$LOG_DIR_ROOT" /tmp/

0 comments on commit 03107db

Please sign in to comment.