From cac568e6fbfec1f0e854d431e7a1d90b3691956f Mon Sep 17 00:00:00 2001 From: Josh W Lewis Date: Wed, 1 Jun 2022 10:27:45 -0500 Subject: [PATCH] Drop yarn-native-cache feature (#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 --- CHANGELOG.md | 1 + bin/compile | 2 -- features | 1 - lib/cache.sh | 4 +-- .../heroku-buildpack-features | 1 - .../yarn-native-cache-false/package.json | 15 ---------- .../yarn-native-cache-false/yarn.lock | 19 ------------ .../heroku-buildpack-features | 1 - test/run | 30 ++----------------- 9 files changed, 6 insertions(+), 68 deletions(-) delete mode 100644 test/fixtures/yarn-native-cache-false/heroku-buildpack-features delete mode 100644 test/fixtures/yarn-native-cache-false/package.json delete mode 100644 test/fixtures/yarn-native-cache-false/yarn.lock delete mode 100644 test/fixtures/yarn-native-cache/heroku-buildpack-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d698cf6..7aafb53ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/bin/compile b/bin/compile index 12570ee4e..215d921ed 100755 --- a/bin/compile +++ b/bin/compile @@ -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 diff --git a/features b/features index 70158358f..e69de29bb 100644 --- a/features +++ b/features @@ -1 +0,0 @@ -cache-native-yarn-cache=100 diff --git a/lib/cache.sh b/lib/cache.sh index d2f0d4fbb..5c2a580f3 100644 --- a/lib/cache.sh +++ b/lib/cache.sh @@ -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 @@ -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" diff --git a/test/fixtures/yarn-native-cache-false/heroku-buildpack-features b/test/fixtures/yarn-native-cache-false/heroku-buildpack-features deleted file mode 100644 index f7406cf2c..000000000 --- a/test/fixtures/yarn-native-cache-false/heroku-buildpack-features +++ /dev/null @@ -1 +0,0 @@ -cache-native-yarn-cache=false diff --git a/test/fixtures/yarn-native-cache-false/package.json b/test/fixtures/yarn-native-cache-false/package.json deleted file mode 100644 index 675d2d400..000000000 --- a/test/fixtures/yarn-native-cache-false/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "yarn", - "version": "1.0.0", - "main": "index.js", - "license": "MIT", - "engines": { - "yarn": "1.x" - }, - "dependencies": { - "lodash": "^4.16.4" - }, - "devDependencies": { - "debug": "^4.1.1" - } -} diff --git a/test/fixtures/yarn-native-cache-false/yarn.lock b/test/fixtures/yarn-native-cache-false/yarn.lock deleted file mode 100644 index 6b43163f7..000000000 --- a/test/fixtures/yarn-native-cache-false/yarn.lock +++ /dev/null @@ -1,19 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - -lodash: - version "4.16.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127" - -ms@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== diff --git a/test/fixtures/yarn-native-cache/heroku-buildpack-features b/test/fixtures/yarn-native-cache/heroku-buildpack-features deleted file mode 100644 index ff035967d..000000000 --- a/test/fixtures/yarn-native-cache/heroku-buildpack-features +++ /dev/null @@ -1 +0,0 @@ -cache-native-yarn-cache=true diff --git a/test/run b/test/run index b0860be41..b6bcb3131 100755 --- a/test/run +++ b/test/run @@ -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 } @@ -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)