Skip to content

Commit

Permalink
test: add yarn modern caching
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcC399 committed Feb 26, 2025
1 parent 2ba4378 commit e8b3db4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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 @@ -1204,7 +1204,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 @@ -1215,6 +1217,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 @@ -1231,6 +1240,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

0 comments on commit e8b3db4

Please sign in to comment.