Skip to content

Commit ba9956d

Browse files
authored
test: add npm caching to pnpm examples (#1043)
1 parent 58f8597 commit ba9956d

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

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

+65
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ jobs:
1919
with:
2020
version: 8
2121

22+
- name: Get pnpm store directory
23+
shell: bash
24+
run: |
25+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
26+
27+
- name: Setup pnpm cache
28+
uses: actions/cache@v3
29+
with:
30+
path: ${{ env.STORE_PATH }}
31+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
32+
restore-keys: |
33+
${{ runner.os }}-pnpm-store-
34+
2235
- name: Cypress tests
2336
# normally you would write
2437
# uses: cypress-io/github-action@v6
@@ -43,6 +56,19 @@ jobs:
4356
with:
4457
version: 8
4558

59+
- name: Get pnpm store directory
60+
shell: bash
61+
run: |
62+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
63+
64+
- name: Setup pnpm cache
65+
uses: actions/cache@v3
66+
with:
67+
path: ${{ env.STORE_PATH }}
68+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
69+
restore-keys: |
70+
${{ runner.os }}-pnpm-store-
71+
4672
- name: Cypress tests
4773
uses: ./
4874
with:
@@ -60,6 +86,19 @@ jobs:
6086
with:
6187
version: 8
6288

89+
- name: Get pnpm store directory
90+
shell: bash
91+
run: |
92+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
93+
94+
- name: Setup pnpm cache
95+
uses: actions/cache@v3
96+
with:
97+
path: ${{ env.STORE_PATH }}
98+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
99+
restore-keys: |
100+
${{ runner.os }}-pnpm-store-
101+
63102
- name: Cypress tests
64103
uses: ./
65104
with:
@@ -77,6 +116,19 @@ jobs:
77116
with:
78117
version: 8
79118

119+
- name: Get pnpm store directory
120+
shell: bash
121+
run: |
122+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
123+
124+
- name: Setup pnpm cache
125+
uses: actions/cache@v3
126+
with:
127+
path: ${{ env.STORE_PATH }}
128+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
129+
restore-keys: |
130+
${{ runner.os }}-pnpm-store-
131+
80132
- name: Cypress tests
81133
uses: ./
82134
with:
@@ -97,6 +149,19 @@ jobs:
97149
with:
98150
version: 8
99151

152+
- name: Get pnpm store directory
153+
shell: bash
154+
run: |
155+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
156+
157+
- name: Setup pnpm cache
158+
uses: actions/cache@v3
159+
with:
160+
path: ${{ env.STORE_PATH }}
161+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
162+
restore-keys: |
163+
${{ runner.os }}-pnpm-store-
164+
100165
- name: Cypress tests
101166
uses: ./
102167
with:

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@ jobs:
10021002
### pnpm
10031003

10041004
The package manager `pnpm` is not pre-installed in [GitHub Actions runner images](https://github.com/actions/runner-images) (unlike `npm` and `yarn`): to install `pnpm` include [pnpm/action-setup](https://github.com/pnpm/action-setup) in your workflow. 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.
1005+
At this time the action does not automatically cache dependencies installed by pnpm. The example below includes steps to locate the pnpm store directory and to cache its contents for later use.
10051006

10061007
```yaml
10071008
name: example-basic-pnpm
@@ -1016,6 +1017,17 @@ jobs:
10161017
uses: pnpm/action-setup@v2
10171018
with:
10181019
version: 8
1020+
- name: Get pnpm store directory
1021+
shell: bash
1022+
run: |
1023+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
1024+
- name: Setup pnpm cache
1025+
uses: actions/cache@v3
1026+
with:
1027+
path: ${{ env.STORE_PATH }}
1028+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
1029+
restore-keys: |
1030+
${{ runner.os }}-pnpm-store-
10191031
- name: Cypress run
10201032
uses: cypress-io/github-action@v6
10211033
with:

0 commit comments

Comments
 (0)