solana/.buildkite/hooks/pre-command

24 lines
500 B
Plaintext
Raw Normal View History

#!/bin/bash -e
[[ -n "$CARGO_TARGET_CACHE_NAME" ]] || exit 0
#
# Restore target/ from the previous CI build on this machine
#
(
d=$HOME/cargo-target-cache/"$CARGO_TARGET_CACHE_NAME"
if [[ -d $d ]]; then
du -hs "$d"
read -r cacheSizeInGB _ < <(du -s --block-size=1000000000 "$d")
if [[ $cacheSizeInGB -gt 5 ]]; then
echo "$d has gotten too large, removing it"
rm -rf "$d"
fi
fi
2018-07-04 10:26:32 -07:00
mkdir -p "$d"/target
set -x
2018-07-04 10:26:32 -07:00
rsync -a --delete --link-dest="$d" "$d"/target .
)