cypress-io / cypress-docker-images

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

Cypress in docker fails to run with read-only project dir #686

Open varac opened 2 years ago

varac commented 2 years ago

Current behavior

Currently, when using the cypress/included docker image and mounting a project dir read-only, cypress fails to run.

Desired behavior

It should not fail and run the tests. It could issue a warning that it is not able to save screenshots or videos.

Test code to reproduce

❯ docker run --rm -it -v $PWD:/e2e:ro -w /e2e cypress/included:10.2.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[213:0624/072239.698161:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[213:0624/072239.700359:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
EROFS: read-only file system, access '/e2e'
Error: EROFS: read-only file system, access '/e2e'

Cypress Version

10.2.0

Other

These issues/PRs might be related, however I was not able to determine if this behaviour should be already fixed or not:

varac commented 2 years ago

Interestingly, this seems to only happen in docker. Running is locally (installed with npm) leads to the desired result:

❯ touch /tmp/cytest/de
touch: cannot touch '/tmp/cytest/de': Permission denied

❯ ./node_modules/.bin/cypress run -P /tmp/cytest 
This folder is not writable: /tmp/cytest

Writing to this directory is required by Cypress in order to store screenshots and videos.

Enable write permissions to this directory to ensure screenshots and videos are stored.

If you don't require screenshots or videos to be stored you can safely ignore this warning.
Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: EACCES: permission denied, unlink '/tmp/cytest/cypress/videos/test-nextcloud.cy.js.mp4'

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        10.2.0                                                                         │
  │ Browser:        Electron 100 (headless)                                                        │
  │ Node Version:   v16.15.1 (/snap/node/6378/bin/node)                                            │
  │ Specs:          1 found (test-nextcloud.cy.js)                                                 │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  test-nextcloud.cy.js                                                            (1 of 1)
...
varac commented 2 years ago

The use-case is that I want to run cypress in kubernetes, and the project dir is mounted from a readonly configmap.

hai-le-niteco commented 2 years ago

I'm encountering this too. Desperately looking for a fix

Tigatok commented 2 years ago

Encountering this in a gitlab pipeline, also see the error is related here as well: https://github.com/cypress-io/cypress/issues/23326

SvartAlfe commented 2 years ago

Similar errors displayed here, with Kubernetes. Surprisingly, the tests are working fine. And I managed to remove the ALSA errors, but not yet the "libva error". But I wish Cypress would not display "This folder is not writable" in quiet mode...

[14887:0901/193637.064164:ERROR:zygote_host_impl_linux.cc(263)] Failed to adjust OOM score of renderer with pid 15064: Permission denied (13)
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[15064:0901/193637.106703:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[15064:0901/193637.112561:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
This folder is not writable: /usr/src/app

Writing to this directory is required by Cypress in order to store screenshots and videos.

Enable write permissions to this directory to ensure screenshots and videos are stored.

If you don't require screenshots or videos to be stored you can safely ignore this warning.
[14887:0901/193640.509047:ERROR:zygote_host_impl_linux.cc(263)] Failed to adjust OOM score of renderer with pid 15243: Permission denied (13)
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
[15394:0901/193650.405867:ERROR:alsa_util.cc(204)] PcmOpen: default,No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
[15394:0901/193650.406082:ERROR:alsa_util.cc(204)] PcmOpen: plug:default,No such file or directory
immogish commented 7 months ago

I have this problem too, on Cypress version 12.17.4

askhanna-mdsol commented 5 months ago

Got this problem as well.

MikeMcC399 commented 4 months ago

@askhanna-mdsol

Can you provide some more information?

Which Cypress Docker image are you using? What is your host operating system for Docker? Are you running Desktop Docker? How are you running it? Locally or in CI? Can you give the commands you use to run the container? Are you using the default root user or a non-root user? Is your project directory generally read-only or is it read-only, only for the user running the Docker container?

askhanna-mdsol commented 4 months ago

@askhanna-mdsol

Can you provide some more information?

Which Cypress Docker image are you using? What is your host operating system for Docker? Are you running Desktop Docker? How are you running it? Locally or in CI? Can you give the commands you use to run the container? Are you using the default root user or a non-root user? Is your project directory generally read-only or is it read-only, only for the user running the Docker container?

Cypress image : cypress/included:cypress-13.11.0 Yes, these tests are a running in github action CI pipeline on linux machines. These git runners are a part of the K8 infrastructure that the tests are running on, we are not Dockerizing the application to execute it inside the container.

MikeMcC399 commented 4 months ago

@askhanna-mdsol

I understand that you are running your workflow through Kubernetes (K8s) under GitHub Actions.

If you would like this issue investigated further, please open a new issue. Include your GitHub Actions workflow, any error message you are seeing and any other further details that could be helpful for troubleshooting, such as the name and version of the Linux operating system in use. I presume that these are self-hosted GitHub runners.

You can find an example workflow .github/workflows/example-cypress-github-action.yml showing Cypress Docker images running successfully under GitHub Actions on GitHub-hosted runners (no K8s involved).