2018-06-30 21:51:15 -07:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
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="++"
|
2018-06-30 21:51:15 -07:00
|
|
|
|
|
|
|
#
|
|
|
|
# Restore target/ from the previous CI build on this machine
|
|
|
|
#
|
2018-09-07 09:08:08 -07:00
|
|
|
[[ -n "$CARGO_TARGET_CACHE_NAME" ]] || (
|
2018-06-30 21:51:15 -07:00
|
|
|
d=$HOME/cargo-target-cache/"$CARGO_TARGET_CACHE_NAME"
|
2018-09-07 10:19:24 -07:00
|
|
|
|
|
|
|
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
|
2018-06-30 21:51:15 -07:00
|
|
|
set -x
|
2018-07-04 10:26:32 -07:00
|
|
|
rsync -a --delete --link-dest="$d" "$d"/target .
|
2018-06-30 21:51:15 -07:00
|
|
|
)
|
2018-09-07 09:08:08 -07:00
|
|
|
|