Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add global cache for binaries #1254

Closed
wants to merge 1 commit into from

Conversation

maxime1992
Copy link

Global cache will speed up local development when running npm i or yarn.
It'll downloaded Cypress binaries once and if available, next time will only get the cached one.

I believe it might also be safer for projects using Cypress to cache only that global cache folder + yarn or npm cache on CI instead of the whole node_modules.

This closes #1188

@CLAassistant
Copy link

CLAassistant commented Feb 3, 2018

CLA assistant check
All committers have signed the CLA.

@maxime1992 maxime1992 changed the title [WIP] cli: add global cache for binaries cli: add global cache for binaries Feb 4, 2018
@maxime1992
Copy link
Author

So, I think it's good now, just waiting for comments 😄!

One thing tho: I don't know how to test the functionality for real (which is not ideal of course).

@brian-mann
Copy link
Member

brian-mann commented Feb 4, 2018

pinging @bahmutov

My thoughts:

There are some existing node modules that handle the "global cache" like this - which prevents you from having to build up the homeDir/.cypress/ pathing. We've had so many issues with Windows that we internally always look for modules that have already solved this in a cross platform way. Although this is minor - you shouldn't ever build up path slashes like you're doing because of Windows - always go through path.join(...)

Alternatively - Cypress itself uses the "proper" application cache of the OS which we utilize here https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/app_data.coffee. It may make more sense to store the binaries there since we also give you a way to "View App Data" from the "File" menu from the GUI itself. It would make things more consistent and that code is already cross platform ready and would not create two different areas where we store data on your system. We'd need to extract this file into something more generic to make it available to the CLI.

As for testing this code for real - you generally just start from another project and call directly into the CLI code by invoking cypress/cli/bin/cypress directly. That should make it behave as if it's been NPM installed. You could also take an existing installation and just copy/paste your updated code into the NPM module.

@brian-mann
Copy link
Member

@bahmutov thinking about this further....

Maybe instead of caching the zipped Cypress globally and then unzipping it into the dist folder within the NPM module -- why wouldn't we unzip it into the global cache and then just point the CLI to use the global version?

This would save you from having Cypress (which is very large) installed on multiple projects. As long as they use the same version number they'd all use the exact binary.

We'd have to likely come up with some new CLI flags to clear the cache when you want to do reinstall the binary or maybe a --force flag which bypasses the cache... but this seems to not only solve this issue of caching, but also fixes other issues people have asked for (that Cypress takes up too much space across multiple project installations).

@paulfalgout
Copy link
Contributor

While I like where this is headed and it will help the issue, it won't resolve #1188 which seems to be that cloudflare is abysmal in the eastern hemisphere. Not only does re-downloading Cypress take 30 minutes, but the docs take an enormous amount of time to load.

@bahmutov
Copy link
Contributor

bahmutov commented Feb 7, 2018 via email

// ... and also add it to the global cache
fs.copy(
options.downloadDestination,
`${home}/.cypress/${options.version}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should never concatenate paths ourselves (Windows ...)

@bahmutov
Copy link
Contributor

bahmutov commented Feb 7, 2018

BTW last comment: I usually do not struggle with Cypress installs because I use https://github.com/bahmutov/have-it to pull an alias from some other project that already has it installed

$ have -D cypress

@bahmutov
Copy link
Contributor

@maxime1992 I will close this request in favor of #1300 - reusing same binary from different projects. This will avoid custom code and will do the same caching as other projects are doing (like Electron).

@bahmutov bahmutov closed this Feb 12, 2018
@kuceb kuceb mentioned this pull request Apr 13, 2018
@kuceb kuceb mentioned this pull request May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs site and binary install from yarn can be very slow from Korea
5 participants