-
Notifications
You must be signed in to change notification settings - Fork 196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! I've left a few comments, I hope someone from Netlify will be able to take a look.
run-build-functions.sh
Outdated
export YARN_GLOBAL_FOLDER="$NETLIFY_BUILD_BASE/.yarn_cache" | ||
export YARN_ENABLE_GLOBAL_CACHE=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of using environment variables for this, because it'll break people using zero-installs (when the cache is inside the repository), overriding the config they explicitly requested (I know it's what the code already did, overriding --cache-folder
etc, but that really strikes me as a bad idea).
I think a more gentle approach would be to create a .yarnrc.yml
file in the home directory that would contain the "default options" you want to have. This way, users would still be able to opt-out of the default workflow to use their own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arcanis Thank you for the review! I've removed export YARN_ENABLE_GLOBAL_CACHE=1
. The user now can opt-in to use global cache by setting YARN_ENABLE_GLOBAL_CACHE
in Netlify settings.
I guess it'd be for Netlify to decide the default for enableGlobalCache
and whether to allow users to override the global folder, so I'll leave it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chiming in here... :)
I've also attempted to use zero-installs on Netlify and ran into issues as the install command always seems to run. Would it be possible to amend these changes to allow skipping of the install step completely? Or did I just miss how to do that 🙃 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kara-todd AFAIK, shoudn't yarn install
only take few seconds with zero-installs? You can set YARN_ENABLE_NETWORK=0
to disallow making network requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ylemkimon when I was running it... it still seemed to still run the relink step, but I didn't try it with YARN_ENABLE_NETWORK=0
. It didn't take terribly long as I recall... 🤔 However, I use this in conjunction with Netlify CMS which has to wait on builds for content reviews... So every second ends up being precious. :)
I know that part of the problem was caused by Netlify not correctly detecting the cache directory as you are trying to fix here. Still, a true zero install
where I only run my build command would be preferable to me if it's not a huge lift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kara-todd I have a Netlify repo with zero-install and it takes less than two seconds running yarn install
. If it takes more than a few seconds, the repo may not have been set up properly. A workaround for now would be move the whole project into a subdirectory, not having package.json
and yarn.lock
at the root, and cd
in the build command.
Co-authored-by: Maël Nison <nison.mael@gmail.com>
Would love for this to be merged in so that I move a site over to netlify. 🙏 |
The line below |
Closing this PR as the it's against xenial branch and the Xenial image is going to be deprecated: https://answers.netlify.com/t/please-read-end-of-support-for-xenial-build-image-everything-you-need-to-know/68239 Feel free to reopen against focal branch. |
YARN_IGNORE_PATH=1
. The environment variableYARN_VERSION
sets the version of Yarn to install globally.YARN_GLOBAL_FOLDER
environment variable to the cache directory. Thecache-folder
flag is deprecated in Yarn 2. The user can opt-in to use the global cache by settingYARN_ENABLE_GLOBAL_CACHE
in Netlify settings. (See Fix support for Yarn 2 (berry) #465 (comment))Closes #319.
Suggestion for Docs:
https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables
https://docs.netlify.com/configure-builds/manage-dependencies/#yarn
CC @arcanis Could you check whether this is the right way to use Yarn 2 in CI?