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

Invalid cache folder for macOS #792

Closed
eplatek-safyr opened this issue Feb 15, 2023 · 7 comments
Closed

Invalid cache folder for macOS #792

eplatek-safyr opened this issue Feb 15, 2023 · 7 comments

Comments

@eplatek-safyr
Copy link

eplatek-safyr commented Feb 15, 2023

[macOS latest version, package manager is yarn]

I was playing around the cache on my machine, and after removing manually the cache folders in ~/.cache and ~/Library/Caches, cypress could not start anymore on the CI action.

Locally, when I run npx cypress verify, cypress is correctly installed in ~/Library/Caches/Cypress/12.5.1, but the CI script tries to locate the executable under ~/.cache/Cypress/12.5.1

I can mitigate the issue by adding a symbolic link to the library folder:

ln -s ~/Library/Caches/Cypress ~/.cache/Cypress

Can you confirm that the issue comes from the github action script ? Or am I missing some option related the install folder to use ?

@eplatek-safyr
Copy link
Author

I think I've found the issue, I added a PR here

So maybe the issue is not related to this repo, the cypress install script should ensure that the .cache folder exists when installing on macOS

@MikeMcC399
Copy link
Collaborator

@eplatek-safyr

If you look at the .github/workflows/example-basic.yml and the logs from running this e.g. https://github.com/cypress-io/github-action/actions/runs/4167116736/jobs/7212307325 you will see that the GitHub action works on macOS.

Could you provide some steps to reproduce and a log file in order to understand the problem that you are running into?

@eplatek-safyr
Copy link
Author

eplatek-safyr commented Feb 15, 2023

Sure, here is a repro on a CI machine :

  1. setup a machine with macOS as a github agent
  2. run the script with success the first time
  3. delete the ~/.cache/Cypress folder
  4. The next run in your CI will fail as it is unable to locate any cypress folder under ~/.cache

here is a sample of the log:

Run cypress-io/github-action@v5
Skipping install because install parameter is false
start server command "yarn workspace app-front serve"
current working directory "/Users/user1/actions-runner/_work/xxx/xxx"
waiting on "http://localhost:2222" with timeout of 60 seconds
/Users/user1/.yarn/bin/yarn workspace app-front serve
yarn workspace v1.22.19
yarn run v1.22.19
$ vite preview --port=2222 --strictPort
  ➜  Local:   http://localhost:2222/
  ➜  Network: [http://192.168.1.159:](http://192.168.1.159/)2222/
Error: The cypress npm package is installed, but the Cypress binary is missing.

We expected the binary to be installed here: /Users/user1/.cache/Cypress/12.5.1/Cypress.app/Contents/MacOS/Cypress

Reasons it may be missing:

- You're caching 'node_modules' but are not caching this path: /Users/user1/Library/Caches/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /Users/user1/Library/Caches/Cypress

Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.

Error: The cypress npm package is installed, but the Cypress binary is missing.

We expected the binary to be installed here: /Users/user1/.cache/Cypress/12.5.1/Cypress.app/Contents/MacOS/Cypress

Reasons it may be missing:

- You're caching 'node_modules' but are not caching this path: /Users/user1/Library/Caches/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /Users/user1/Library/Caches/Cypress

Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.

Alternatively, you can run 'cypress install' to download the binary again.

https://on.cypress.io/not-installed-ci-error

----------

Platform: darwin-arm64 (22.2.0)
Cypress Version: 12.5.1
Alternatively, you can run 'cypress install' to download the binary again.

https://on.cypress.io/not-installed-ci-error

----------

Platform: darwin-arm64 (22.2.0)
Cypress Version: 12.5.1
    at /Users/user1/actions-runner/_work/xxx/xxx/node_modules/cypress/lib/errors.js:328:17 ***
  known: true
***

npx cypress verify will confirm you that cypress cache is located at ~/Library/Caches/Cypress and is valid, you even can run your tests manually with npx cypress run since the cypress executable will be found correctly when using the reference defined in the node_modules.

With that said, maybe the issue doesn't come from the github action script, because the documentation of cypress states that the cache location is supposed to be found in the ~/.cache folder. I'm not a macOS user, but it seems that many applications (including cypress) use the ~/Library/Caches folder, so the maybe the issue comes from here.

Another fix could be maybe to look in the test-project/node_modules/.bin folder to use the cypress executable found here, but I don't have more info on the internals

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Feb 15, 2023

@eplatek-safyr

@MikeMcC399
Copy link
Collaborator

@eplatek-safyr

In your logs it shows:

Skipping install because install parameter is false

Would you post your .yml workflow so it is clearer what is being called and with what parameters?

@MikeMcC399
Copy link
Collaborator

@eplatek-safyr

The following workflow runs without issues. I replaced the code in https://github.com/cypress-io/github-action/blob/master/.github/workflows/example-basic.yml to test it out.

I'm guessing that you ran cypress-io/github-action with the parameter install: false.

cypress-io/github-action is using a custom directory for the location of the cache (as you already know, since your PR is based on changing this).

I'm assuming that install: false implicitly assumes that there was a previous run of cypress-io/github-action which set up the install, so that the cache locations match, even though they are non-standard compared to the documentation Binary cache.

So I think that your expectations are more in line with an enhancement request than a bug report. We'll have to wait for the Cypress.io team to cross-check about this though.

name: example-basic
on:
  push:
    branches:
      - 'master'
  pull_request:
  workflow_dispatch:

env:
  DEBUG: '@cypress/github-action, cypress:*'

jobs:
  basic-split-macos-12:
    runs-on: macos-12
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Cypress install
        uses: ./
        with:
          runTests: false
          working-directory: examples/basic

      - name: Cypress run
        uses: ./
        with:
          install: false
          working-directory: examples/basic

There is an outdated example in https://github.com/bahmutov/cypress-gh-action-split-install/blob/master/.github/workflows/tests.yml about handling the Cypress cache by hand without using cypress/github-action. That might be suitable for you if you want full control and are willing to work at a deeper level directly with actions/cache.

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Nov 4, 2023

Closing due to inactivity.

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

2 participants