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

Allow disabling cache #953

Open
skjnldsv opened this issue Jun 29, 2023 · 10 comments
Open

Allow disabling cache #953

skjnldsv opened this issue Jun 29, 2023 · 10 comments
Labels
E2E type: feature feature request

Comments

@skjnldsv
Copy link

Hi,

Because of that issue: actions/cache#720, the cypress action step takes a very long time on self-hosted runners. The difference is so big that disabling the cache is faster.

Alternatively, you could consider migrating to the buildjet/cache action, or push forward for Github to fix actions/cache#720

Thanks :)

image

@MikeMcC399
Copy link
Collaborator

@skjnldsv

Could you please share some more information?

  • What is your GitHub self-hosted runner environment?
  • How long does cache retrieval take? What is your expectation for how long it should take?
  • What is your workflow?
  • Also a workflow log with debug enabled would be useful:
  env:
    DEBUG: '@cypress/github-action'

The CI examples here all run on GitHub-hosted runners, so we only have timings available for these standard runners.

@skjnldsv
Copy link
Author

skjnldsv commented Jun 29, 2023

Of course :)

What is your GitHub self-hosted runner environment?

We're on ubuntu-latest (22.04), using the same image as the official Github runners.

How long does cache retrieval take? What is your expectation for how long it should take?

Github: ~4 seconds
Self-hosted: ~70 seconds

What is your workflow?

Also a workflow log with debug enabled would be useful:


PS: if you want to know if a runner executed on our self hosted or github official, you can check the Setup job step output:

@MikeMcC399
Copy link
Collaborator

@skjnldsv
Thanks for the material!

This is a feature request, so the Cypress.io team would need to weigh in on the request to allow optional disabling of caching.

I read in the GitHub documentation Caching dependencies to speed up workflows:

"When using self-hosted runners, caches from workflow runs are stored on GitHub-owned cloud storage. A customer-owned storage solution is only available with GitHub Enterprise Server."

which probably contributes to generally longer run times for caching on self-hosted runners.

@skjnldsv
Copy link
Author

which probably contributes to generally longer run times for caching on self-hosted runners.

If you look at the article from https://buildjet.com/for-github-actions/blog/launch-buildjet-cache as well as the issue here actions/cache#720, you'll see this is more of an issue with azure than else.

But this is also not really your call. Thus me only asking for a way to disable the cache.
The issue should be fixed by Github, I agree with you :)

@nagash77 nagash77 added type: feature feature request E2E labels Jul 5, 2023
@skjnldsv
Copy link
Author

skjnldsv commented Mar 1, 2024

Any news @MikeMcC399 ?

@MikeMcC399
Copy link
Collaborator

@skjnldsv

There is no new status on your enhancement request.

As a flexible alternative to using the cypress-io/github-action JavaScript GitHub action you may like to consider basing your workflow(s) on one of the two examples listed in the cypress-io/cypress-example-kitchensink > README

In these up-to-date example workflows the caching is set up in the workflows themselves, so the caching could be removed / commented out or could be replaced by the buildjet/cache you suggested. The workflows run under GitHub Actions and run Cypress from the CLI instead of using the Cypress Module API. These workflows have no dependency on cypress-io/github-action.

@krishanbhasin-px
Copy link

Hi there,
Thank you for maintaining this project, its super useful. I would also love the ability to optionally disable the cache; not for reasons of slowness but because I need to use my cache-allocation on GitHub Actions for other things that save me more time.

Ideally this would be a disable-cache config boolean that defaults to False.

I don't mind trying to bring a PR if you'd be open to reviewing and considering merging it

@MikeMcC399
Copy link
Collaborator

@krishanbhasin-px

Thank you for maintaining this project, its super useful.

Thank you for your feedback! It is good to hear that it is useful to you!

I would also love the ability to optionally disable the cache; not for reasons of slowness but because I need to use my cache-allocation on GitHub Actions for other things that save me more time.

It is not necessary to modify the action to achieve your results. You can set install: false which disables installation and caching, then replace this with a manual installation of dependencies, for instance npm ci.

For instance here is a modified workflow taken from https://github.com/cypress-io/cypress-example-kitchensink/blob/master/.github/workflows/chrome.yml

name: Chrome

on: [push, workflow_dispatch]

jobs:
  chrome:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version-file: .node-version
      - name: Install dependencies
        run: npm ci
      - name: Chrome
        uses: cypress-io/github-action@v6
        timeout-minutes: 10
        with:
          install: false
          build: npm run build
          start: npm start
          browser: chrome

Surprisingly, not using cache on GitHub Actions does not notably change the run-time of the workflow. I suspect that GitHub Actions may be using proxy servers or similar to cache downloads.

Phase With cache Without cache
Install dependencies - 15s
Run Cypress 2m 21s 2m 3s
Total 2m 21s 2m 18s

@krishanbhasin-px
Copy link

@MikeMcC399 that was indeed exactly what I wanted! Thank you for the guidance, it worked perfectly 🚀

@MikeMcC399
Copy link
Collaborator

@krishanbhasin-px

that was indeed exactly what I wanted! Thank you for the guidance, it worked perfectly 🚀

It's good to know that this worked for you! Thanks for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E type: feature feature request
Projects
None yet
Development

No branches or pull requests

4 participants