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: add yarn modern caching #1374

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions .github/workflows/example-yarn-modern-pnp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
- name: Set up Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: yarn
cache-dependency-path: examples/yarn-modern-pnp/yarn.lock
- name: Custom Yarn command
uses: ./
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/example-yarn-modern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
- name: Set up Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: yarn
cache-dependency-path: examples/yarn-modern/yarn.lock
- name: Custom Yarn command
uses: ./
with:
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,9 @@ jobs:

### Yarn Modern

To install dependencies using a `yarn.lock` file from [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) you need to override the default [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installation command `yarn --frozen-lockfile`. You can do this by using the `install-command` parameter and specifying `yarn install` for example:
To install dependencies using a `yarn.lock` file from [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) you need to override the default [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installation command `yarn --frozen-lockfile`. You can do this by using the `install-command` parameter and specifying `yarn install` as in the example below.

The action supports built-in caching of Yarn Classic dependencies only. To cache Yarn Modern dependencies additionally use [actions/setup-node](https://github.com/actions/setup-node) and specify `cache: yarn`.

```yaml
name: example-yarn-modern
Expand All @@ -1216,6 +1218,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- run: corepack enable # (experimental and optional)
- name: Set up Yarn cache
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
cache-dependency-path: examples/yarn-modern/yarn.lock
- name: Cypress run
uses: cypress-io/github-action@v6
with:
Expand All @@ -1232,6 +1241,8 @@ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc

When using [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) with [Plug'n'Play](https://yarnpkg.com/features/pnp) enabled, you will need to use the `command` parameter to run [`yarn`](https://yarnpkg.com/cli/run) instead of [`npx`](https://docs.npmjs.com/cli/v9/commands/npx).

See the above [Yarn Modern](#yarn-modern) section for information on caching Yarn Modern dependencies.

```yaml
name: example-yarn-modern-pnp
on: push
Expand Down