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

Cypress caching in ~/.cache/Cypress #50

Open
ehmicky opened this issue May 23, 2020 · 4 comments
Open

Cypress caching in ~/.cache/Cypress #50

ehmicky opened this issue May 23, 2020 · 4 comments
Assignees

Comments

@ehmicky
Copy link
Contributor

ehmicky commented May 23, 2020

Installing Build plugins takes time. To make builds as fast as possible, Netlify is now pre-installing all known Build plugins before the build even starts, leading to 0s additional installation time. This is done as part of the build step of our main Docker image.

However, Cypress downloads binaries and caches them in ~/.cache/Cypress (on Linux). By default, ~/.cache is restored/saved to a cache at the beginning/end of every build. Since ~/.cache/Cypress takes 580MB, this adds 20s to 30s additional time to every build.

We are discussing with @mikeh and @vbrown608 how to fix this performance issue. One way would be to use the CYPRESS_CACHE_FOLDER environment variable to change the location of this directory. Note: this would mean the following section of this plugin's README would need to be updated.

What are your thoughts on this @bahmutov? Do you think this is a viable approach?

@ehmicky
Copy link
Contributor Author

ehmicky commented Jun 2, 2020

We have added the CYPRESS_CACHE_FOLDER environment variable to point to /opt/buildhome/.cypress-cache instead. That cache directory is thrown away after the initial pre-installation (before the build starts). When this plugin's onPreBuild kicks in, cypress install is run, which should add ~/.cache/Cypress, which is then saved in the build cache.

Please let us know if there is anything problematic with this approach.

@quantizor
Copy link

I've been trying to integrate this plugin and no matter what I try I get this error:

2:08:10 PM: ┌────────────────────────────────────────────────┐
2:08:10 PM: │ Plugin "netlify-plugin-cypress" internal error │
2:08:10 PM: └────────────────────────────────────────────────┘
2:08:10 PM: ​
2:08:10 PM:   Error message
2:08:10 PM:   Error: The cypress npm package is installed, but the Cypress binary is missing.
2:08:10 PM: ​
2:08:10 PM:   We expected the binary to be installed here: /opt/build/repo/node_modules/CypressBinary/4.9.0/Cypress/Cypress
2:08:10 PM: ​
2:08:10 PM:   Reasons it may be missing:
2:08:10 PM: ​
2:08:10 PM:   - You're caching 'node_modules' but are not caching this path: /opt/buildhome/.cache/Cypress
  - You ran 'npm install' at an earlier build step but did not persist: /opt/buildhome/.cache/Cypress
2:08:10 PM: ​
2:08:10 PM:   Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
2:08:10 PM: ​
2:08:10 PM:   Alternatively, you can run 'cypress install' to download the binary again.

I've tried with and without CYPRESS_CACHE_FOLDER in the [build.enviroment] netlify toml section.

My netlify toml looks like this:

[build]
  base = ""
  functions = "functions"
  publish = "public/"
  command = "yarn build && yarn build:functions"

[[plugins]]
  package = "netlify-plugin-cypress"
    [plugins.inputs]
      record = true

Installed cypress via yarn add -D cypress.

@quantizor
Copy link

quantizor commented Jul 16, 2020

Was missing installing the plugin itself as well as a node dependency. I think some of the blogs forget to mention that step

@SimeonUnder2
Copy link

^^ I was having the same drama.

To be clear. on the solution, I had to install netlify-plugin-cypres in the root of the project.

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

No branches or pull requests

4 participants