Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement native Yarn Modern support #969

Open
MikeMcC399 opened this issue Jul 18, 2023 · 1 comment
Open

Implement native Yarn Modern support #969

MikeMcC399 opened this issue Jul 18, 2023 · 1 comment
Labels
type: feature feature request

Comments

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Jul 18, 2023

This is a feature request for github-action.

What would you like

github-action should provide full native support for Yarn Modern (version 2 and later) usage.

Why is this needed

Yarn Classic (version 1) entered maintenance mode in January 2022, so github-action should provide full support for the follow-on version Yarn Modern (aka Yarn Berry - current version is 3.x 4.x).

Due to the fact that Yarn Classic is still widely used, Yarn Classic and Yarn Modern both need to be supported. Yarn Classic support cannot yet be dropped.

Yarn Modern is currently dealt with through the use of github-action options. These are workarounds because the action does not recognize Yarn Modern and therefore does not change the commands it calls internally. For workaround usage see:

Missing features and possible solutions

Module API call for Yarn Plug'n'Play (pnp)

The call to the Cypress Module API to invoke cypress run fails in a Yarn Plug'n'Play (pnp) environment. It does not find cypress.

For comparison: at the CLI level, for Yarn Classic and Yarn Modern, yarn node script.js works with all variations. In contrast node script.js works with only with Yarn Classic, Yarn Modern node-modules and Yarn Modern pnpm. It does not work with Yarn Modern pnp.

npx replacement by yarn

Internally github-action uses npx to execute cypress commands such as cypress cache list and cypress verify.

This does not work correctly with the Yarn Plug'n'Play default mode of Yarn Modern because there is no node_modules directory available in this configuration. npx will then separately download the arbitrary latest version of Cypress to work with, producing results which are not tied to the yarn.lock file.

With Yarn Modern configured for pnpm any npx commands fail completely. Since npx is currently hard-wired into github-action it is incompatible with this mode.

The Yarn Modern CLI run command offers the option --binaries-only so npx can be replaced by yarn run --binaries-only or yarn run -B in Yarn Modern environments. An equivalent option is not available for Yarn Classic, so npx should continue to be used in this case to avoid issues with Yarn Classic environments where cypress has been used as the name of a script in package.json. See issue #941 where this conflict became apparent.

yarn install command

Yarn Classic dependencies are correctly installed by github-action using yarn --frozen-lockfile, however the option --frozen-lockfile is deprecated in the Yarn Modern CLI install. For correct usage with Yarn Modern, the option --frozen-lockfile should be removed. (See also the detailed discussion in #611). This issue is currently worked around by using the custom install-command github-action option for Yarn Modern configurations.

Suggestion summary

Yarn Version / Mode Installation npx Module API
Yarn Classic no change no change no change
Yarn Modern node-modules yarn (drop --frozen-lockfile) yarn run -B yarn node
Yarn Modern pnp ditto ditto ditto
Yarn Modern pnpm ditto ditto ditto

This means that the action needs to differentiate between Yarn Classic (version 1) and Yarn Modern (version 2 and later) and needs to change the logic correspondingly. Since the three nodeLinker variants of Yarn Modern (node-modules, pnp and pnpm) can be handled the same, there is no need to differentiate between them.

Currently the action checks for the presence of yarn.lock to recognize Yarn projects. yarn.lock is used by both Yarn Classic and Yarn Modern.

@MikeMcC399
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature feature request
Projects
None yet
Development

No branches or pull requests

2 participants