github-action icon indicating copy to clipboard operation
github-action copied to clipboard

Allow disabling cache

Open skjnldsv opened this issue 1 year ago • 10 comments

Hi,

Because of that issue: https://github.com/actions/cache/issues/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 https://github.com/actions/cache/issues/720

Thanks :)

image

skjnldsv avatar Jun 29 '23 10:06 skjnldsv

@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.

MikeMcC399 avatar Jun 29 '23 13:06 MikeMcC399

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?

  • https://github.com/nextcloud/viewer/blob/master/.github/workflows/cypress.yml

Also a workflow log with debug enabled would be useful:

  • https://github.com/nextcloud/viewer/pull/1762
  • https://github.com/nextcloud/viewer/actions/runs/5413086375?pr=1762

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:

skjnldsv avatar Jun 29 '23 14:06 skjnldsv

@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.

MikeMcC399 avatar Jun 30 '23 10:06 MikeMcC399

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 https://github.com/actions/cache/issues/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 :)

skjnldsv avatar Jun 30 '23 12:06 skjnldsv

Any news @MikeMcC399 ?

skjnldsv avatar Mar 01 '24 07:03 skjnldsv

@skjnldsv

There is no new status on your enhancement request.

  • The issue you mentioned https://github.com/actions/cache/issues/720 is still open
  • The Cypress.io team has not given any opinion on your 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.

MikeMcC399 avatar Mar 01 '24 08:03 MikeMcC399

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

krishanbhasin-px avatar Aug 15 '24 16:08 krishanbhasin-px

@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

MikeMcC399 avatar Aug 16 '24 11:08 MikeMcC399

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

krishanbhasin-px avatar Aug 16 '24 14:08 krishanbhasin-px