Skip to content

Commit 379487f

Browse files
committed
test: add yarn modern caching
1 parent 108b868 commit 379487f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.github/workflows/example-yarn-modern-pnp.yml

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515
- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
16+
- name: Set up Yarn cache
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: '.node-version'
20+
cache: yarn
21+
cache-dependency-path: examples/yarn-modern-pnp/yarn.lock
1622
- name: Custom Yarn command
1723
uses: ./
1824
with:

.github/workflows/example-yarn-modern.yml

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515
- run: corepack enable yarn # experimental - see https://nodejs.org/docs/latest/api/corepack.html
16+
- name: Set up Yarn cache
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: '.node-version'
20+
cache: yarn
21+
cache-dependency-path: examples/yarn-modern/yarn.lock
1622
- name: Custom Yarn command
1723
uses: ./
1824
with:

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,9 @@ jobs:
12051205

12061206
### Yarn Modern
12071207

1208-
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:
1208+
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.
1209+
1210+
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`.
12091211

12101212
```yaml
12111213
name: example-yarn-modern
@@ -1216,6 +1218,13 @@ jobs:
12161218
steps:
12171219
- name: Checkout
12181220
uses: actions/checkout@v4
1221+
- run: corepack enable # (experimental and optional)
1222+
- name: Set up Yarn cache
1223+
uses: actions/setup-node@v4
1224+
with:
1225+
node-version: 22
1226+
cache: yarn
1227+
cache-dependency-path: examples/yarn-modern/yarn.lock
12191228
- name: Cypress run
12201229
uses: cypress-io/github-action@v6
12211230
with:
@@ -1232,6 +1241,8 @@ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc
12321241

12331242
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).
12341243

1244+
See the above [Yarn Modern](#yarn-modern) section for information on caching Yarn Modern dependencies.
1245+
12351246
```yaml
12361247
name: example-yarn-modern-pnp
12371248
on: push

0 commit comments

Comments
 (0)