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

Proposal: download Cypress to the common cached folder #1300

Closed
27 of 33 tasks
bahmutov opened this issue Feb 12, 2018 · 19 comments · Fixed by #1699
Closed
27 of 33 tasks

Proposal: download Cypress to the common cached folder #1300

bahmutov opened this issue Feb 12, 2018 · 19 comments · Fixed by #1699
Labels
cli Epic Requires breaking up into smaller issues type: enhancement Requested enhancement of existing feature
Milestone

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Feb 12, 2018

Feature

Instead of downloading and unzipping Cypress into ./node_modules/cypress/dist/ download it into a global folder for better caching. This will allow

  • better caching of dependencies on CI
  • reusing same version of Cypress if already downloaded once for some project

To determine output location use https://github.com/LinusU/node-cachedir

var cachedir = require('cachedir')
var path = cachedir('cypress')
// `path` now contains the path under which you should store cached files
  • cypress run, open, verify

    • take arg --binary-folder (looks like: /foo/bar/Cypress.app (macOS) or /foo/bar/Cypress (linux, win), to override default path to cypress binary folder (default is (cypressCache)/<cli version>/Cypress.app)
    • can override folder of binary with env var CYPRESS_BINARY_FOLDER=/path/to/Cypress.app
      • warn user if set
  • cypress install

    • Checks (cypressCache)/<cli version> for already installed binary folder (Cypress.app on macOS, Cypress on linux/win), and if binary version matches (installVersion), do nothing.
    • (installVersion) defaults to cli version, is overridden by env var CYPRESS_BINARY_VERSION during install
      • can be either semvar: 1.2.3, url: www.cypress.io/download/1.2.3, or zip: /path/to/cypress.zip
    • if cypress install --force, force reinstall to (cypressCache)/<cli version>
    • (cypressCache) defaults to:
      • ~/Library/Caches/Cypress (macOS)
      • ~/.cache/Cypress (linux)
      • /AppData/Local/Cypress/Cache (win)
    • (cypressCache) can be overridden with env var CYPRESS_CACHE_DIRECTORY
    • before install, ensure write access to (cypressCache)
  • custom error message for failed access to (cypressCache)

  • docs

    • Installing Cypress
    • command line usage
    • update info about global install
  • manual testing all use cases

    • cypress install
      • CYPRESS_BINARY_VERSION
        • url
          • skip if has any cache
        • semvar
        • zip
          • skip if has any cache
          • show progress for unzipping
        • --force
      • --force
    • --binary-folder
      • cypress run
      • cypress open
      • cypress verify
      • invalid
    • CYPRESS_CACHE_DIRECTORY
      • valid
      • invalid, error message
  • add local code coverage with nyc

    • send to coveralls in CI

Stretch goal

  • can we cache ffmpeg separately to avoid bundling the same version over and over?
@bahmutov bahmutov added the Epic Requires breaking up into smaller issues label Feb 12, 2018
@bahmutov bahmutov changed the title Download Cypress to the common cached folder Proposal: download Cypress to the common cached folder Feb 12, 2018
@bahmutov bahmutov added type: enhancement Requested enhancement of existing feature cli stage: proposal 💡 No work has been done of this issue labels Feb 12, 2018
@ntwb
Copy link

ntwb commented Feb 18, 2018

Either this is a duplicate of #1233 or vice-versa, not overly concerned which issue is closed but they are for the most part duplicates

@zkat
Copy link

zkat commented Feb 27, 2018

psst: If you use make-fetch-happen you'll be able to tie the cypress download cache to npm's own cache (by pointing it at process.env.npm_config_cache in the run script).

@EirikBirkeland
Copy link
Contributor

The Cypress.io download always doubles the time my yarn install takes, on a 25 mbit connection. There are ways to get around, but would greatly appreciate caching.

@bahmutov
Copy link
Contributor Author

bahmutov commented Mar 20, 2018 via email

@ncjones
Copy link

ncjones commented Mar 22, 2018

To work around this issue we build a docker image with our test suite's dependencies pre-installed.

@KellyR-STCU
Copy link

KellyR-STCU commented Mar 29, 2018

Would love to see this put into a global location. My team is really excited about Cypress, but we've got to optimize the build time. I tried out npm ci and that actually shaved 2 minutes off the install process. Preventing this download from needing to occur repeatedly would shave about another 40-45 seconds off.

@EirikBirkeland
Copy link
Contributor

@bahmutov I can cache node_modules on CI server, but for local builds we often change our dependencies because we are jumping between branches.

@garytryan
Copy link

Also having this problem with slow install times for local development using Yarn.

@kuceb
Copy link
Contributor

kuceb commented Apr 13, 2018

currently in progress in PR #1582

(my hard drive needed the space) --> image

@kuceb
Copy link
Contributor

kuceb commented Apr 14, 2018

This also enables us to ship our docker images with Cypress pre-cached, which will help simplify CI setup!
Opened issue in docker images

@brian-mann
Copy link
Member

Yeah it's true but we'll need to update our build process to include it - but we should it's a good idea.

Open a separate issue for that and we can work on that while you finish this PR.

@bahmutov
Copy link
Contributor Author

we need to think about caching Cypress in the docker container - because it takes up a lot of space. If we do second split (Electron vs our code), then YES, @bkucera that would be super good idea to include multiple versions pre-cached because they would not add much weight

@brian-mann
Copy link
Member

@bahmutov good point... that's another "+" in the corner of splitting out those two things vs caching the entire app bundle.

@jennifer-shehane jennifer-shehane added this to the 3.0.0 milestone May 16, 2018
@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: pending release stage: investigating Someone from Cypress is looking into this stage: needs investigating Someone from Cypress needs to look at this stage: ready for work The issue is reproducible and in scope labels May 24, 2018
@brian-mann
Copy link
Member

Released in 3.0.0.

@maxime1992
Copy link

maxime1992 commented May 30, 2018

According to Gleb's comment, this issue should include:

better caching of dependencies on CI
reusing same version of Cypress if already downloaded once for some project

I just tried to:

  • upgrade cypress within my project to 3.0
  • make sure that ~/.cache/Cypress/3.0.0 exists
  • rm -rf node_modules
  • yarn again

Cypress has been downloaded again instead of using the local version, available in cypress global cache folder. Am I missing something? Is that not the expected behaviour and maybe I should open a new issue?

That's a great feature, looking forward to it, congrats :)

@kuceb
Copy link
Contributor

kuceb commented May 30, 2018

@maxime1992 yep, that was a bug, fixed in 3.0.1 !

@jeserkin
Copy link

jeserkin commented Feb 13, 2020

If one installs it globally on machine and versions match (with project), then installing with npm shouldn't pull it again and install on project level, correct?

@kuceb
Copy link
Contributor

kuceb commented Feb 13, 2020

@jeserkin correct

@jeserkin
Copy link

jeserkin commented Feb 14, 2020

@bkucera Is it possible, that installing dependencies with npm ci, somehow mitigates existence check and still downloads cypress based on project level description?
At the moment I have npm install -g cypress@3.3.2 pre-installed on docker image. Later I run npm ci in container, that is based on given image and it does following:

HH:mm:ss  > cypress@3.3.2 postinstall /build/xtss/node_modules/cypress
HH:mm:ss  > node index.js --exec install
HH:mm:ss  
HH:mm:ss  Installing Cypress (version: 3.3.2)
HH:mm:ss  
HH:mm:ss  �[?25l[12:31:14]  Downloading Cypress     [started]
HH:mm:ss  [12:31:15]  Downloading Cypress      0% 0s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      3% 3s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      8% 2s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      12% 2s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      18% 2s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      24% 2s [title changed]
HH:mm:ss  [12:31:15]  Downloading Cypress      29% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      34% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      41% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      47% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      52% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      60% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      68% 1s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      74% 0s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      81% 0s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      89% 0s [title changed]
HH:mm:ss  [12:31:16]  Downloading Cypress      96% 0s [title changed]
HH:mm:ss  [12:31:16]  Downloaded Cypress      [title changed]
HH:mm:ss  [12:31:16]  Downloaded Cypress      [completed]
HH:mm:ss  [12:31:16]  Unzipping Cypress       [started]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Epic Requires breaking up into smaller issues type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.