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

test: migrate yarn modern examples to corepack #1350

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/example-yarn-modern-pnp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
- name: Custom Yarn command
uses: ./
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-yarn-modern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
- name: Custom Yarn command
uses: ./
with:
Expand Down
16 changes: 8 additions & 8 deletions docs/MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes updating the [examples](../examples) in this repository

The [examples](../examples) directory contains examples of the use of Cypress (Current) [Configuration](https://docs.cypress.io/guides/references/configuration) which applies to Cypress 10 and later. These examples test and demonstrate the use of [cypress-io/github-action](https://github.com/cypress-io/github-action).

The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [Yarn 1 (Classic)](https://classic.yarnpkg.com/) and [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) to define and install the packages being used.
The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [Yarn 1 (Classic)](https://classic.yarnpkg.com/) and [Yarn Modern](https://yarnpkg.com/) to define and install the packages being used. For [Yarn Modern](https://yarnpkg.com/) the recommended [Corepack](https://yarnpkg.com/corepack) is used as a Yarn version manager.

*The previous [examples/v9](https://github.com/cypress-io/github-action/tree/v5/examples/v9) are archived in the [v5](https://github.com/cypress-io/github-action/tree/v5/) branch. This directory contains examples which were set up to use Cypress `9.7.0`, the last version using Legacy Configuration, covering Cypress 9 and below. These `v9` examples are no longer maintained.

Expand All @@ -18,20 +18,16 @@ The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/)

- [git](https://git-scm.com/) distributed version control system.

- [npm](https://www.npmjs.com/), which is installed with [Node.js](https://nodejs.org/)
- [npm](https://www.npmjs.com/), which is installed with [Node.js](https://nodejs.org/).

- [corepack](https://github.com/nodejs/corepack), which is installed with [Node.js](https://nodejs.org/).

- [pnpm](https://pnpm.io/) installed through:

```bash
npm install pnpm@latest -g
```

- [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installed through:

```bash
npm install yarn@latest -g
```

- [Visual Studio Code](https://code.visualstudio.com/) or other editor

Under Microsoft Windows it may be necessary to also execute the following preparatory command:
Expand All @@ -55,3 +51,7 @@ This updates all [examples](../examples) to cypress@latest.
[.github/workflows/example-install-only.yml](../.github/workflows/example-install-only.yml) contains a hard-coded Cypress version number. This can be updated by hand.

After updating the examples locally, they can be committed with git and a pull request opened on GitHub.

### Updating Yarn examples

The script [/scripts/update-cypress-latest-yarn.sh](../scripts/update-cypress-latest-yarn.sh) (which is invoked through `npm run update:cypress` to update the Yarn examples) runs [Yarn 1 (Classic)](https://classic.yarnpkg.com/) as an `npm` global install, runs [Yarn Modern](https://yarnpkg.com/) through Corepack and returns Corepack to its default disabled state on completion.
934 changes: 0 additions & 934 deletions examples/yarn-modern-pnp/.yarn/releases/yarn-4.6.0.cjs

This file was deleted.

1 change: 0 additions & 1 deletion examples/yarn-modern-pnp/.yarnrc.yml

This file was deleted.

10 changes: 9 additions & 1 deletion examples/yarn-modern-pnp/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# example: yarn-modern-pnp

This example demonstrates installing dependencies using [Yarn Modern (version 2 and later)](https://yarnpkg.com/) with [Plug'n'Play](https://yarnpkg.com/features/pnp) turned on.
This example demonstrates installing dependencies using [Yarn Modern v4](https://yarnpkg.com/) with [corepack](https://yarnpkg.com/corepack) enabled and the default configuration of [Plug'n'Play](https://yarnpkg.com/features/pnp) enabled.

Run locally with:

```shell
corepack enable yarn
yarn
yarn test
```
934 changes: 0 additions & 934 deletions examples/yarn-modern/.yarn/releases/yarn-4.6.0.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions examples/yarn-modern/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.6.0.cjs
10 changes: 9 additions & 1 deletion examples/yarn-modern/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# example: yarn-modern

This example demonstrates installing dependencies using [Yarn Modern (version 2 and later)](https://yarnpkg.com/).
This example demonstrates installing dependencies using [Yarn Modern v4](https://yarnpkg.com/) with [corepack](https://yarnpkg.com/corepack) enabled and the configuration option `nodeLinker: node-modules` selected.

Run locally with:

```shell
corepack enable yarn
yarn
yarn test
```
14 changes: 0 additions & 14 deletions scripts/check-package-manager-yarn.sh

This file was deleted.

34 changes: 31 additions & 3 deletions scripts/update-cypress-latest-yarn.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#!/bin/bash
set -e # fail on error
#
if ! command -v corepack &> /dev/null
then
echo "**corepack is required and not installed**"
echo "Refer to Yarn Modern installation instructions"
echo "https://yarnpkg.com/getting-started/install"
echo "https://yarnpkg.com/corepack"
echo
exit 1 # failure
else
echo "corepack is installed"
fi
#
# Examples using the yarn package manager are
# updated to Cypress latest version
#
# Make sure that yarn is installed
./scripts/check-package-manager-yarn.sh

# After running this script, Yarn 1 Classic latest is installed
# corepack is disabled
#
echo updating yarn examples to Cypress latest version
cd examples
# --------------------------------------------------
# Yarn 1 Classic section
# No corepack
corepack disable yarn
npm install yarn@latest -g

# examples/start-and-yarn-workspaces (yarn)
echo
Expand Down Expand Up @@ -37,6 +54,11 @@ cd yarn-classic
yarn add cypress --dev --exact
cd ..

# --------------------------------------------------
# Yarn 4 Modern section
# Use corepack
corepack enable yarn

# examples/yarn-modern
echo
echo updating examples/yarn-modern to cypress@latest
Expand All @@ -53,4 +75,10 @@ yarn set version latest
yarn add cypress --dev --exact
cd ..

corepack disable yarn
echo "corepack is now disabled for Yarn"
npm install yarn@latest -g
# End of Yarn 4 Modern section
# --------------------------------------------------

cd ..
4 changes: 1 addition & 3 deletions scripts/update-cypress-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ set -e # fail on error
# All examples are updated to Cypress latest version
#
# Make sure that Node.js LTS from https://nodejs.org/en/ is installed before running.
# Ensure yarn v1 (classic) and pnpm are installed.
# npm install yarn -g
# Ensure pnpm is installed.
# npm install pnpm -g
# The VScode editor is also used in the last step if available.
#
# First check if the required package managers are installed
./scripts/check-package-manager-npm.sh
./scripts/check-package-manager-yarn.sh
./scripts/check-package-manager-pnpm.sh
# then proceed to updating the examples
echo
Expand Down
Loading