Skip to content

Commit 13042d4

Browse files
authored
test: implement example pnpm workflow caching (#1228)
1 parent 55398cb commit 13042d4

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

.github/workflows/example-basic-pnpm.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@v4
2020

21+
# See https://github.com/pnpm/action-setup
2122
- name: Install pnpm
22-
run: npm install -g pnpm@9
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 9
26+
27+
# See https://github.com/actions/setup-node
28+
- name: Install Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: 'pnpm'
33+
cache-dependency-path: examples/basic-pnpm/pnpm-lock.yaml
2334

2435
- name: Cypress tests
2536
# if you copy this workflow to another repository

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,8 @@ jobs:
11271127
### pnpm
11281128

11291129
The package manager `pnpm` is not pre-installed in [GitHub Actions runner images](https://github.com/actions/runner-images) (unlike `npm` and `yarn`) and so it must be installed in a separate workflow step (see below). If the action finds a `pnpm-lock.yaml` file, it uses the [pnpm](https://pnpm.io/cli/install) command `pnpm install --frozen-lockfile` by default to install dependencies.
1130-
At this time, the action does not automatically cache dependencies installed by pnpm. We advise against attempting to work around this restriction, by caching the pnpm store directory through additional workflow steps, as this can lead to the action skipping installation of the Cypress binary, causing workflow failure.
1130+
1131+
The example below follows [pnpm recommendations](https://pnpm.io/continuous-integration#github-actions) for installing pnpm and caching the [pnpm store](https://pnpm.io/cli/store).
11311132

11321133
```yaml
11331134
name: example-basic-pnpm
@@ -1139,7 +1140,15 @@ jobs:
11391140
- name: Checkout
11401141
uses: actions/checkout@v4
11411142
- name: Install pnpm
1142-
run: npm install -g pnpm@9
1143+
uses: pnpm/action-setup@v4
1144+
with:
1145+
version: 9
1146+
- name: Install Node.js
1147+
uses: actions/setup-node@v4
1148+
with:
1149+
node-version: 20
1150+
cache: 'pnpm'
1151+
cache-dependency-path: examples/basic-pnpm/pnpm-lock.yaml
11431152
- name: Cypress run
11441153
uses: cypress-io/github-action@v6
11451154
with:

0 commit comments

Comments
 (0)