You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
47
+
44
48
## Caching global packages data
45
49
46
50
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
Copy file name to clipboardExpand all lines: docs/advanced-usage.md
+46-12
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,38 @@
1
-
# Advanced usage
1
+
## Working with lockfiles
2
+
3
+
All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
4
+
5
+
- Enables faster installation for CI and production environments, due to being able to skip package resolution.
6
+
- Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
7
+
- Provides a facility for users to "time-travel" to previous states of `node_modules` without having to commit the directory itself.
8
+
- Facilitates greater visibility of tree changes through readable source control diffs.
9
+
10
+
In order to get the most out of using your lockfile on continuous integration follow the conventions outlined below for your respective package manager.
11
+
12
+
### NPM
13
+
14
+
Ensure that `package-lock.json` is always committed, use `npm ci` instead of `npm install` when installing packages.
15
+
16
+
**See also:**
17
+
-[Documentation of `package-lock.json`](https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json)
18
+
-[Documentation of `npm ci`](https://docs.npmjs.com/cli/v8/commands/npm-ci)
19
+
20
+
### Yarn
21
+
22
+
Ensure that `yarn.lock` is always committed, pass `--frozen-lockfile` to `yarn install` when installing packages.
23
+
24
+
**See also:**
25
+
-[Documentation of `yarn.lock`](https://classic.yarnpkg.com/en/docs/yarn-lock)
26
+
-[Documentation of `--frozen-lockfile` option](https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-frozen-lockfile)
27
+
-[QA - Should lockfiles be committed to the repoistory?](https://yarnpkg.com/getting-started/qa/#should-lockfiles-be-committed-to-the-repository)
28
+
29
+
### PNPM
30
+
31
+
Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lockfile` to `pnpm install` when installing packages.
32
+
33
+
**See also:**
34
+
-[Working with Git - Lockfiles](https://pnpm.io/git#lockfiles)
35
+
-[Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile)
2
36
3
37
## Check latest version
4
38
@@ -15,7 +49,7 @@ steps:
15
49
with:
16
50
node-version: '14'
17
51
check-latest: true
18
-
- run: npm install
52
+
- run: npm ci
19
53
- run: npm test
20
54
```
21
55
@@ -31,7 +65,7 @@ steps:
31
65
- uses: actions/setup-node@v3
32
66
with:
33
67
node-version-file: '.nvmrc'
34
-
- run: npm install
68
+
- run: npm ci
35
69
- run: npm test
36
70
```
37
71
@@ -51,7 +85,7 @@ jobs:
51
85
with:
52
86
node-version: '14'
53
87
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
54
-
- run: npm install
88
+
- run: npm ci
55
89
- run: npm test
56
90
```
57
91
@@ -67,7 +101,7 @@ steps:
67
101
with:
68
102
node-version: '14'
69
103
cache: 'yarn'
70
-
- run: yarn install
104
+
- run: yarn install --frozen-lockfile
71
105
- run: yarn test
72
106
```
73
107
@@ -89,7 +123,7 @@ steps:
89
123
with:
90
124
node-version: '14'
91
125
cache: 'pnpm'
92
-
- run: pnpm install
126
+
- run: pnpm install --frozen-lockfile
93
127
- run: pnpm test
94
128
```
95
129
@@ -102,7 +136,7 @@ steps:
102
136
node-version: '14'
103
137
cache: 'npm'
104
138
cache-dependency-path: '**/package-lock.json'
105
-
- run: npm install
139
+
- run: npm ci
106
140
- run: npm test
107
141
```
108
142
@@ -117,7 +151,7 @@ steps:
117
151
cache-dependency-path: |
118
152
server/app/package-lock.json
119
153
frontend/app/package-lock.json
120
-
- run: npm install
154
+
- run: npm ci
121
155
- run: npm test
122
156
```
123
157
@@ -152,7 +186,7 @@ jobs:
152
186
with:
153
187
node-version: ${{ matrix.node_version }}
154
188
architecture: ${{ matrix.architecture }}
155
-
- run: npm install
189
+
- run: npm ci
156
190
- run: npm test
157
191
```
158
192
@@ -164,7 +198,7 @@ steps:
164
198
with:
165
199
node-version: '14.x'
166
200
registry-url: 'https://registry.npmjs.org'
167
-
- run: npm install
201
+
- run: npm ci
168
202
- run: npm publish
169
203
env:
170
204
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -184,7 +218,7 @@ steps:
184
218
with:
185
219
node-version: '14.x'
186
220
registry-url: <registry url>
187
-
- run: yarn install
221
+
- run: yarn install --frozen-lockfile
188
222
- run: yarn publish
189
223
env:
190
224
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
@@ -206,7 +240,7 @@ steps:
206
240
registry-url: 'https://registry.npmjs.org'
207
241
# Skip post-install scripts here, as a malicious
208
242
# script could steal NODE_AUTH_TOKEN.
209
-
- run: npm install --ignore-scripts
243
+
- run: npm ci --ignore-scripts
210
244
env:
211
245
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
212
246
# `npm rebuild` will run all those post-install scripts for us.
0 commit comments