cypress-io / cypress-docker-images

Docker images with Cypress dependencies and browsers
https://on.cypress.io/continuous-integration
MIT License
1.02k stars 380 forks source link

Gitlab pipeline fails with Cypress binary not installed #1178

Closed bharathmuppa closed 1 month ago

bharathmuppa commented 1 month ago

Gitlab pipeline fails with Cypress binary not installed though i am using cypress/included:latest

Here is my job definition in my gitlab-ci.yml

# Install steps happens in different stage 

Unit Test:
  image:  jfrog-mirai.ec.com/registry-1.docker.io/cypress/included:latest
  stage: Test
  script:
    - npm_config_registry=https://jfrog-mirai.ec.com/artifactory/api/npm/mirai-npm/ npx cypress install 
    - npx cypress cache path
    - npx cypress cache list
    - npm run cypress:run:unit
  allow_failure: true
  cache:
    key: node_modules-$VERSION
    paths:
      - node_modules/
      - cache/Cypress
    policy: pull
  artifacts:
    when: always
    paths:
      - cypress/videos/**/*.mp4
      - cypress/screenshots/**/*.png
    expire_in: 1 day

output

Checking cache for node_modules-0.1.2-feature-cypress-non_protected...
Downloading cache.zip from https://st2ldm32humncy3rdva.blob.core.windows.net/gitlab-runner-shared-cache/runner/project/5144/node_modules-0.1.2-feature-cypress-non_protected 
Successfully extracted cache
Executing "step_script" stage of the job script
00:03
$ npm_config_registry=https://jfrog-mirai.ec.com/artifactory/api/npm/mirai-npm/ npx cypress install
[STARTED] Task without title.
$ npx cypress cache path
/opt/.cache/Cypress
$ npx cypress cache list
┌─────────┬───────────┐
│ version │ last used │
└─────────┴───────────┘
$ npm run cypress:run:unit
> avt-app@0.0.0 cypress:run:unit
> cypress run --component
The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /opt/.cache/Cypress/13.12.0/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/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: linux-x64 (Debian - 12.6)
Cypress Version: 13.12.0
Uploading artifacts for failed job
MikeMcC399 commented 1 month ago

@bharathmuppa

Your job definition shows you are using

image:  jfrog-mirai.ec.com/registry-1.docker.io/cypress/included:latest
  1. jfrog-mirai.ec.com/registry-1.docker.io is not a registry controlled by Cypress.io
  2. Use of the latest tag in production is not recommended.
  3. In the Docker Hub registry on https://hub.docker.com/r/cypress/included the image reference cypress/included:latest is currently equivalent to cypress/included:13.13.1

Your log files indicate that your project is configured for Cypress Version: 13.12.0 which may be in conflict with the latest tag from your Docker registry.

You can try specifying

cypress/included:13.12.0 as your image

or you could try using a cypress/browsers image instead, for instance

cypress/browsers:node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1

There is no specific advice in this repository about using Cypress Docker images in GitLab. You can however find some documentation on the Cypress documentation site at https://docs.cypress.io/guides/continuous-integration/gitlab-ci.

MikeMcC399 commented 1 month ago

This issue is not reproducible locally. Possibly the setting for the Cypress binary cache is being overridden. The Docker image uses /root/.cache/Cypress not /opt/.cache/Cypress:

git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images/examples/basic
npm install cypress@13.12.0 -D
docker run -it --rm -v .:/e2e -w /e2e --entrypoint bash cypress/included:latest

root@46f8c91a41e8:/e2e# npx cypress install
root@46f8c91a41e8:/e2e# npx cypress cache path
/root/.cache/Cypress
root@46f8c91a41e8:/e2e# npx cypress cache list
┌─────────┬──────────────┐
│ version │ last used    │
├─────────┼──────────────┤
│ 13.12.0 │ a month ago  │
├─────────┼──────────────┤
│ 13.13.1 │ 14 hours ago │
└─────────┴──────────────┘
MikeMcC399 commented 1 month ago

@bharathmuppa

Please let us know if the information was helpful to you and if you were able to resolve your issue by re-configuration.

MikeMcC399 commented 1 month ago

Closing due to lack of response.

bharathmuppa commented 1 month ago

Thanks it worked @MikeMcC399

Problem is with the version as you explained, your help is much appreciated.