Cypress: Add new command: cypress cache prune

Created on 16 Dec 2019  路  5Comments  路  Source: cypress-io/cypress

When caching Cypress binary on CI, it is easy to start carrying LOTS of installed binary versions, increasing cache size and time it takes to restore cache on each CI build.

Situation

Imagine you start using Cypress v3.5.0 and cache ~/.cache folder like we advise in https://on.cypress.io/caching. Initially, you will have just v3.5.0 there.

Then you upgrade to v3.6.0 in package.json file. The CI build does the following

  • restores the existing ~/.cache folder with 3.5.0
  • installs v3.6.0. Now ~/.cache has both 3.5.0 and 3.6.0
  • saves the ~/.cache folder as new cache

Boom, after a few version upgrades you have lots of old binary versions, making cache size easily pass 1GB

Commands

In current Cypress version v3.8.0 we have the following commands related to the binary cache

$ npx cypress cache

  Usage: cache [command]

  Manages the Cypress binary cache

  Options:

    list        list cached binary versions
    path        print the path to the binary cache
    clear       delete all cached binaries
    -h, --help  output usage information

I propose we add one more command cypress cache prune that removes all versions from the binary cache folder but the current one. Then one could run this command on CI like this

  • restore cache folder
  • npm install
  • npx cypress verify
  • npx cypress cache prune
  • save cache folder
cli topic

Most helpful comment

Would love to see this command added! Cypress cache is over 2GB now, installing every update since 3.5.0.

All 5 comments

Real-world example was in https://github.com/cypress-io/cypress-example-kitchensink/pull/335 where GitHub Action could not cache the binary folder with 2 versions of Cypress while trying to test new version via RenovateBot update

Would love to see this command added! Cypress cache is over 2GB now, installing every update since 3.5.0.

+1

The code for this is done in cypress-io/cypress#8766, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Released in 5.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.4.0, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings