cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests
https://on.cypress.io/guides/continuous-integration/github-actions
MIT License
1.35k stars 357 forks source link

docs: recommend CYPRESS_INSTALL_BINARY=0 for cypress/included Docker image #1202

Closed MikeMcC399 closed 2 months ago

MikeMcC399 commented 2 months ago

Issue

If cypress-io/github-action is used to run a Cypress Docker image cypress/included as a container with --user 1001 (as recommended), then GitHub actions may report a caching error:

Failed to restore: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2

Background

cypress/included Docker images include the Cypress binary installed in /root/.cache/Cypress with owner root (see environment variable CYPRESS_CACHE_FOLDER of Docker image).

By default cypress-io/github-action attempts to cache and restore the Cypress binary. Any such restore action fails if the user has been set to a non-root value, since the owner of $CYPRESS_CACHE_FOLDER is root.

Caching the Cypress binary is superfluous when the Docker image already includes the binary.

If the environment variable CYPRESS_INSTALL_BINARY=0 is set (see Skipping installation) then isCypressBinarySkipped is set internally in the action and no CYPRESS_BINARY_CACHE is saved. If no cache is saved, then restoreCachedCypressBinary will not be able to restore a cache and will not provoke any error condition.

Note that this is not quite error proof because if a workflow has run without CYPRESS_INSTALL_BINARY=0 and has stored a cache, then this will be picked up and provoke an error message. This is mitigated by the fact that the error is cosmetic, in that it does not cause the workflow to fail. It is also self-correcting since cache entries which have not been accessed in over 7 days are removed (see User limits and eviction policy).

Change

Add advice to README > Docker image to set CYPRESS_INSTALL_BINARY=0 with cypress/included Docker images.

cypress-app-bot commented 2 months ago
MikeMcC399 commented 2 months ago

Preview

https://github.com/MikeMcC399/github-action/blob/cypress-included-setup/README.md#docker-image

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 6.7.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: