Skip to content

Commit

Permalink
Drop yarn-native-cache feature (#1004)
Browse files Browse the repository at this point in the history
* Drop yarn-native-cache feature

* Drop fixture feature setting

* Drop yarn-native-cache feature

* Update test expectations: it was testing an impossible scenario

* Add changelog entry for feature flag removal
  • Loading branch information
joshwlewis authored Jun 1, 2022
1 parent b71e33b commit cac568e
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Node.js Buildpack Changelog

## main
- Drop the `yarn-native-cache` feature flag ([#1004](https://github.com/heroku/heroku-buildpack-nodejs/pull/1004))

## v196 (2022-05-31)
- Add metrics plugin for Node 17 and 18 ([#1002](https://github.com/heroku/heroku-buildpack-nodejs/pull/1002))
Expand Down
2 changes: 0 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ fi
[ ! "$NPM_CONFIG_CACHE" ] && NPM_CONFIG_CACHE=$(mktemp -d -t npmcache.XXXXX)
export YARN_CACHE_FOLDER NPM_CONFIG_CACHE

[[ $(features_get "cache-native-yarn-cache") == "false" ]] && USE_YARN_CACHE=false

if [[ -z "$USE_NPM_INSTALL" ]] && [[ $(features_get_with_blank "use-npm-ci") == "false" ]]; then
USE_NPM_INSTALL=true
fi
Expand Down
1 change: 0 additions & 1 deletion features
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
cache-native-yarn-cache=100
4 changes: 2 additions & 2 deletions lib/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ restore_default_cache_directories() {
local cache_dir=${2:-}
local yarn_cache_dir=${3:-}

if [[ $(features_get "cache-native-yarn-cache") == "true" ]] && [[ "$YARN" == "true" ]]; then
if [[ "$YARN" == "true" ]]; then
if has_yarn_cache "$build_dir"; then
echo "- yarn cache is checked into source control and cannot be cached"
elif [[ -e "$cache_dir/node/cache/yarn" ]]; then
Expand Down Expand Up @@ -121,7 +121,7 @@ save_default_cache_directories() {
local cache_dir=${2:-}
local yarn_cache_dir=${3:-}

if [[ $(features_get "cache-native-yarn-cache") == "true" ]] && [[ "$YARN" == "true" ]]; then
if [[ "$YARN" == "true" ]]; then
if [[ -d "$yarn_cache_dir" ]]; then
if [[ "$YARN_2" == "true" ]] && ! node_modules_enabled "$BUILD_DIR"; then
cp -RTf "$yarn_cache_dir" "$cache_dir/node/cache/yarn"
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions test/fixtures/yarn-native-cache-false/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions test/fixtures/yarn-native-cache-false/yarn.lock

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/yarn-native-cache/heroku-buildpack-features

This file was deleted.

30 changes: 3 additions & 27 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,13 @@ testYarn() {
assertCapturedSuccess
}

testYarnCacheDirectory() {
testYarnCache() {
local cache=$(mktmpdir)
local env_dir=$(mktmpdir)
local cache_dir=$(mktmpdir)
echo "${cache_dir}/yarn"> "$env_dir/YARN_CACHE_FOLDER"
compile "yarn" $cache $env_dir
# These will be created if yarn is using the directory for its cache

assertDirectoryExists ${cache_dir}/yarn
# yarn frequently bumps the version number used in its cache
# so use a wildcard here to prevent frequent CI failures

# assert that the above ls command exited successfully, which only happens if the file exists
assertEquals "0" "$?"
compile "yarn" $cache

# assert that devDependencies are cached
assertEquals "1" "$(ls -1 $cache/node/cache/node_modules | grep -c debug | tr -d ' ')"
assertEquals "1" "$(ls -1 $cache/node/cache/yarn/v6 | grep -c debug | tr -d ' ')"

assertCapturedSuccess
}
Expand All @@ -286,20 +276,6 @@ testYarnNativeCache() {
assertCapturedSuccess
}

testYarnNativeCacheFalse() {
local cache=$(mktmpdir)

compile "yarn-native-cache-false" $cache
# These will be created if yarn is using the directory for its cache

# Run this again with a cache
compile "yarn-native-cache-false" $cache

# assert that devDependencies are not cached
assertEquals "1" "$(ls -1 $cache/node/cache/node_modules | grep -c debug | tr -d ' ')"
assertCapturedSuccess
}

testNpm5CacheDirectory() {
local cache=$(mktmpdir)
local env_dir=$(mktmpdir)
Expand Down

0 comments on commit cac568e

Please sign in to comment.