Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Fix Rust caching issues #521

Merged
merged 5 commits into from
Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,11 @@ cache_artifacts() {
cache_cwd_directory ".venv" "python virtualenv"
cache_cwd_directory ".build" "swift build"
cache_cwd_directory ".netlify/plugins" "build plugins"
cache_cwd_directory "target" "rust compile output"

if [ -f Cargo.toml ] || [ -f Cargo.lock ]
then
cache_cwd_directory_fast_copy "target" "rust compile output"
fi

cache_home_directory ".yarn_cache" "yarn cache"
cache_home_directory ".cache/pip" "pip cache"
Expand All @@ -686,8 +690,12 @@ cache_artifacts() {
cache_home_directory ".composer" "composer dependencies"
cache_home_directory ".homebrew-cache", "homebrew cache"
cache_home_directory ".rustup" "rust rustup cache"
cache_home_directory ".cargo/registry" "rust cargo registry cache"
cache_home_directory ".cargo/bin" "rust cargo bin cache"

if [ -f Cargo.toml ] || [ -f Cargo.lock ]
then
cache_home_directory ".cargo/registry" "rust cargo registry cache"
cache_home_directory ".cargo/bin" "rust cargo bin cache"
fi

# Don't follow the Go import path or we'll store
# the origin repo twice.
Expand Down Expand Up @@ -748,6 +756,17 @@ move_cache() {
fi
}

fast_copy_cache() {
local src=$1
local dst=$2
if [ -d $src ]
then
echo "Started $3"
cp --reflink=always $src $dst
echo "Finished $3"
fi
}

restore_home_cache() {
move_cache "$NETLIFY_CACHE_DIR/$1" "$HOME/$1" "restoring cached $2"
}
Expand All @@ -764,6 +783,10 @@ cache_cwd_directory() {
move_cache "$PWD/$1" "$NETLIFY_CACHE_DIR/$1" "saving $2"
}

cache_cwd_directory_fast_copy() {
fast_copy_cache "$PWD/$1" "$NETLIFY_CACHE_DIR/$1" "saving $2"
}

install_missing_commands() {
if [[ $BUILD_COMMAND_PARSER == *"grunt"* ]]
then
Expand Down