test: add pnpm workspaces example#1140
Merged
jennifer-shehane merged 1 commit intocypress-io:masterfrom Mar 7, 2024
Merged
Conversation
|
Collaborator
Author
|
README Preview The badge shows no status since workflow does not yet exist in the |
jennifer-shehane
approved these changes
Mar 7, 2024
Member
jennifer-shehane
left a comment
There was a problem hiding this comment.
@MikeMcC399 This is great. Thanks for the thorough addition and the explanation on how to test it.
Collaborator
Author
There have been a couple of users lately who were struggling to use the action with pnpm workspaces, so that was the motivation to put together a working demo. I will also submit an enhancement request, just so the requirement is documented. |
|
🎉 This PR is included in version 6.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The Cypress GitHub JavaScript Action (GHA) provides minimum support for projects using the pnpm package manager. It runs
pnpm install --frozen-lockfileif it finds apnpm-lock.yamllockfile. It however offers no simple out-of-the-box provision for working with pnpm workspaces. There is no logic in GHA to deal with the lack of a lockfile in a pnpm workspace and so GHA is unable to install dependencies directly from the workspace.Background
pnpm has built-in support for monorepositories (AKA multi-package repositories, multi-project repositories, or monolithic repositories).
pnpm repos using workspaces and Cypress are typically structured similar to the following E2E example:
Requirements
An example is needed to show how the Cypress GitHub Action (GHA) can be used with pnpm workspaces to install and cache dependencies including the Cypress binary and run Cypress tests in a selected workspace.
Example structure
The action is run twice. Once to install dependencies and a second time to run Cypress tests.
cypress-io/github-actionis run in the root of the pnpm workspace example with the optionrunTestsset tofalse. This installs all dependencies in all workspaces and caches the Cypress binary cache.cypress-io/github-actionis then run in a selected pnpm workspace using the optionworking_directoryset to the workspace directory with the optioninstallset tofalse. Cypress is able to run because thenode_modulesdirectory is populated from the previous step, and because the Cypress binary is also available in the cache.The example also includes caching of the pnpm store, like the non-workspace example for pnpm.
Additions
The example includes
examples/start-and-pnpm-workspaces.github/workflows/example-start-and-pnpm-workspaces.yml#pnpm-workspacesVerification
GitHub
example-start-and-pnpm-workspacesand check for successLinux-pnpm-store-xxxcache of/home/runner/.local/share/pnpm/store/v3for pnpm storecypress-linux-x64-xxxcache of/home/runner/.cache/Cypresfor Cypress binarypnpm-linux-x64-xxxcache of/home/runner/.npmLocal
Execute the following on Ubuntu 22.04 and check for success:
and repeat
The output should be similar to the following: