test: set up included-non-root example screenshot #1273
Merged
+23
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
examples/included-as-non-root cannot capture screenshots when running with a non-root user in GitHub Actions.
In actions/workflows/example-tests.yml running the job
example (included-as-non-root)
in GitHub Actions, Cypress outputs the warning:See logs in https://github.com/cypress-io/cypress-docker-images/actions/runs/12585519287/job/35077469532
The workflow effectively runs the following:
cypress-docker-images/examples/included-as-non-root/scripts/test.sh
Lines 1 to 7 in 31d5a60
GitHub Runners under
ubuntu-24.04
run commands with the Linux user:The volume mount
-v .:/test
source is owned by therunner
user and the Cypressnode
user has onlyr-x
access, not write access to the directory/test
.Note that this is different from running Docker images as an explicit container in GitHub Actions (see Running jobs in a container where the Docker (default) user is
root
unless replaced through jobs.<job_id>.container.options).Change
In the Cypress configuration examples/included-as-non-root/cypress.config.js configure the volatile folders outside the Cypress project in the
/tmp
directory which is writable by all users.downloadsFolder
cypress/downloads
/tmp/cypress/downloads
screenshotsFolder
cypress/screenshots
/tmp/cypress/screenshots
videosFolder
cypress/videos
/tmp/cypress/videos
Add
cy.screenshot()
to examples/included-as-non-root/cypress/e2e/spec.cy.js to test that a screenshot can be captured.Verification
Local test Ubuntu
Ubuntu
24.04.1
LTS, Node.js22.12.0 LTS
, Docker Desktop4.37.1
/tmp/cypress/screenshots/spec.cy.js/test local demo page -- heading.png
is logged as being written.Local test Windows 11
Windows 11 24H2, Node.js
22.12.0 LTS
, Docker Desktop4.37.1
in acmd
terminal windowCommands and test as above for Ubuntu.