Merge pull request #11857 from mvines/cache

ci: cargo-target-cache is now channel specific
This commit is contained in:
Michael Vines 2020-08-26 11:35:41 -07:00 committed by GitHub
parent 5c7d743883
commit 5c7080c1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 23 deletions

View File

@ -3,16 +3,19 @@
# #
# Save target/ for the next CI build on this machine # Save target/ for the next CI build on this machine
# #
( if [[ -z $CARGO_TARGET_CACHE ]]; then
set -x echo "+++ CARGO_TARGET_CACHE not defined" # pre-command should have defined it
d=$HOME/cargo-target-cache/"$BUILDKITE_LABEL" else
mkdir -p "$d" (
set -x set -x
rsync -a --delete --link-dest="$PWD" target "$d" mkdir -p "$CARGO_TARGET_CACHE"
du -hs "$d" set -x
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$d") rsync -a --delete --link-dest="$PWD" target "$CARGO_TARGET_CACHE"
echo "--- ${cacheSizeInGB}GB: $d" du -hs "$CARGO_TARGET_CACHE"
) read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
)
fi
# #
# Add job_stats data point # Add job_stats data point

View File

@ -11,23 +11,24 @@ export PS4="++"
# #
# Restore target/ from the previous CI build on this machine # Restore target/ from the previous CI build on this machine
# #
eval "$(ci/channel-info.sh)"
export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"
( (
set -x set -x
d=$HOME/cargo-target-cache/"$BUILDKITE_LABEL"
MAX_CACHE_SIZE=18 # gigabytes MAX_CACHE_SIZE=18 # gigabytes
if [[ -d $d ]]; then if [[ -d $CARGO_TARGET_CACHE ]]; then
du -hs "$d" du -hs "$CARGO_TARGET_CACHE"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$d") read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $d" echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then
echo "--- $d is too large, removing it" echo "--- $CARGO_TARGET_CACHE is too large, removing it"
rm -rf "$d" rm -rf "$CARGO_TARGET_CACHE"
fi fi
else else
echo "--- $d not present" echo "--- $CARGO_TARGET_CACHE not present"
fi fi
mkdir -p "$d"/target mkdir -p "$CARGO_TARGET_CACHE"/target
rsync -a --delete --link-dest="$d" "$d"/target . rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$CARGO_TARGET_CACHE"/target .
) )

View File

@ -89,11 +89,17 @@ BETA_CHANNEL_LATEST_TAG=${beta_tag:+v$beta_tag}
STABLE_CHANNEL_LATEST_TAG=${stable_tag:+v$stable_tag} STABLE_CHANNEL_LATEST_TAG=${stable_tag:+v$stable_tag}
if [[ $CI_BRANCH = "$STABLE_CHANNEL" ]]; then if [[ -n $CI_BASE_BRANCH ]]; then
BRANCH="$CI_BASE_BRANCH"
elif [[ -n $CI_BRANCH ]]; then
BRANCH="$CI_BRANCH"
fi
if [[ $BRANCH = "$STABLE_CHANNEL" ]]; then
CHANNEL=stable CHANNEL=stable
elif [[ $CI_BRANCH = "$EDGE_CHANNEL" ]]; then elif [[ $BRANCH = "$EDGE_CHANNEL" ]]; then
CHANNEL=edge CHANNEL=edge
elif [[ $CI_BRANCH = "$BETA_CHANNEL" ]]; then elif [[ $BRANCH = "$BETA_CHANNEL" ]]; then
CHANNEL=beta CHANNEL=beta
fi fi