solana/.buildkite/hooks/pre-command

34 lines
831 B
Plaintext
Raw Normal View History

2018-12-15 13:49:22 -08:00
#!/usr/bin/env bash
set -e
eval "$(ejson2env .buildkite/env/secrets.ejson)"
2018-09-07 09:08:08 -07:00
# Ensure the pattern "+++ ..." never occurs when |set -x| is set, as buildkite
# interprets this as the start of a log group.
# Ref: https://buildkite.com/docs/pipelines/managing-log-output
export PS4="++"
#
# Restore target/ from the previous CI build on this machine
#
(
set -x
d=$HOME/cargo-target-cache/"$BUILDKITE_LABEL"
2019-05-12 21:28:12 -07:00
MAX_CACHE_SIZE=18 # gigabytes
if [[ -d $d ]]; then
du -hs "$d"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$d")
2019-05-12 21:28:12 -07:00
echo "--- ${cacheSizeInGB}GB: $d"
if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then
echo "--- $d is too large, removing it"
rm -rf "$d"
fi
2019-05-12 21:28:12 -07:00
else
echo "--- $d not present"
fi
2018-07-04 10:26:32 -07:00
mkdir -p "$d"/target
rsync -a --delete --link-dest="$d" "$d"/target .
)