Skip to content

Commit cac568e

Browse files
authored
Drop yarn-native-cache feature (heroku#1004)
* 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
1 parent b71e33b commit cac568e

File tree

9 files changed

+6
-68
lines changed

9 files changed

+6
-68
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Node.js Buildpack Changelog
22

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

56
## v196 (2022-05-31)
67
- Add metrics plugin for Node 17 and 18 ([#1002](https://github.com/heroku/heroku-buildpack-nodejs/pull/1002))

bin/compile

-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ fi
192192
[ ! "$NPM_CONFIG_CACHE" ] && NPM_CONFIG_CACHE=$(mktemp -d -t npmcache.XXXXX)
193193
export YARN_CACHE_FOLDER NPM_CONFIG_CACHE
194194

195-
[[ $(features_get "cache-native-yarn-cache") == "false" ]] && USE_YARN_CACHE=false
196-
197195
if [[ -z "$USE_NPM_INSTALL" ]] && [[ $(features_get_with_blank "use-npm-ci") == "false" ]]; then
198196
USE_NPM_INSTALL=true
199197
fi

features

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
cache-native-yarn-cache=100

lib/cache.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ restore_default_cache_directories() {
4949
local cache_dir=${2:-}
5050
local yarn_cache_dir=${3:-}
5151

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

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

test/fixtures/yarn-native-cache-false/heroku-buildpack-features

-1
This file was deleted.

test/fixtures/yarn-native-cache-false/package.json

-15
This file was deleted.

test/fixtures/yarn-native-cache-false/yarn.lock

-19
This file was deleted.

test/fixtures/yarn-native-cache/heroku-buildpack-features

-1
This file was deleted.

test/run

+3-27
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,13 @@ testYarn() {
253253
assertCapturedSuccess
254254
}
255255

256-
testYarnCacheDirectory() {
256+
testYarnCache() {
257257
local cache=$(mktmpdir)
258-
local env_dir=$(mktmpdir)
259-
local cache_dir=$(mktmpdir)
260-
echo "${cache_dir}/yarn"> "$env_dir/YARN_CACHE_FOLDER"
261-
compile "yarn" $cache $env_dir
262-
# These will be created if yarn is using the directory for its cache
263258

264-
assertDirectoryExists ${cache_dir}/yarn
265-
# yarn frequently bumps the version number used in its cache
266-
# so use a wildcard here to prevent frequent CI failures
267-
268-
# assert that the above ls command exited successfully, which only happens if the file exists
269-
assertEquals "0" "$?"
259+
compile "yarn" $cache
270260

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

274264
assertCapturedSuccess
275265
}
@@ -286,20 +276,6 @@ testYarnNativeCache() {
286276
assertCapturedSuccess
287277
}
288278

289-
testYarnNativeCacheFalse() {
290-
local cache=$(mktmpdir)
291-
292-
compile "yarn-native-cache-false" $cache
293-
# These will be created if yarn is using the directory for its cache
294-
295-
# Run this again with a cache
296-
compile "yarn-native-cache-false" $cache
297-
298-
# assert that devDependencies are not cached
299-
assertEquals "1" "$(ls -1 $cache/node/cache/node_modules | grep -c debug | tr -d ' ')"
300-
assertCapturedSuccess
301-
}
302-
303279
testNpm5CacheDirectory() {
304280
local cache=$(mktmpdir)
305281
local env_dir=$(mktmpdir)

0 commit comments

Comments
 (0)