Skip to content

Commit b067f78

Browse files
authored
Use CI friendly commands in documentation (#326)
1 parent 0bd0676 commit b067f78

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ steps:
2323
- uses: actions/setup-node@v3
2424
with:
2525
node-version: 14
26-
- run: npm install
26+
- run: npm ci
2727
- run: npm test
2828
```
2929
@@ -41,6 +41,10 @@ major versions: `12`, `14`, `16`
4141
more specific versions: `10.15`, `14.2.0`, `16.3.0`
4242
nvm lts syntax: `lts/erbium`, `lts/fermium`, `lts/*`
4343

44+
### Checking in lockfiles
45+
46+
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+
4448
## Caching global packages data
4549

4650
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.
@@ -60,7 +64,7 @@ steps:
6064
with:
6165
node-version: 14
6266
cache: 'npm'
63-
- run: npm install
67+
- run: npm ci
6468
- run: npm test
6569
```
6670

@@ -74,7 +78,7 @@ steps:
7478
node-version: 14
7579
cache: 'npm'
7680
cache-dependency-path: subdir/package-lock.json
77-
- run: npm install
81+
- run: npm ci
7882
- run: npm test
7983
```
8084

@@ -94,7 +98,7 @@ jobs:
9498
uses: actions/setup-node@v3
9599
with:
96100
node-version: ${{ matrix.node }}
97-
- run: npm install
101+
- run: npm ci
98102
- run: npm test
99103
```
100104

docs/advanced-usage.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff 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)
236

337
## Check latest version
438

@@ -15,7 +49,7 @@ steps:
1549
with:
1650
node-version: '14'
1751
check-latest: true
18-
- run: npm install
52+
- run: npm ci
1953
- run: npm test
2054
```
2155
@@ -31,7 +65,7 @@ steps:
3165
- uses: actions/setup-node@v3
3266
with:
3367
node-version-file: '.nvmrc'
34-
- run: npm install
68+
- run: npm ci
3569
- run: npm test
3670
```
3771

@@ -51,7 +85,7 @@ jobs:
5185
with:
5286
node-version: '14'
5387
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
54-
- run: npm install
88+
- run: npm ci
5589
- run: npm test
5690
```
5791

@@ -67,7 +101,7 @@ steps:
67101
with:
68102
node-version: '14'
69103
cache: 'yarn'
70-
- run: yarn install
104+
- run: yarn install --frozen-lockfile
71105
- run: yarn test
72106
```
73107

@@ -89,7 +123,7 @@ steps:
89123
with:
90124
node-version: '14'
91125
cache: 'pnpm'
92-
- run: pnpm install
126+
- run: pnpm install --frozen-lockfile
93127
- run: pnpm test
94128
```
95129

@@ -102,7 +136,7 @@ steps:
102136
node-version: '14'
103137
cache: 'npm'
104138
cache-dependency-path: '**/package-lock.json'
105-
- run: npm install
139+
- run: npm ci
106140
- run: npm test
107141
```
108142

@@ -117,7 +151,7 @@ steps:
117151
cache-dependency-path: |
118152
server/app/package-lock.json
119153
frontend/app/package-lock.json
120-
- run: npm install
154+
- run: npm ci
121155
- run: npm test
122156
```
123157

@@ -152,7 +186,7 @@ jobs:
152186
with:
153187
node-version: ${{ matrix.node_version }}
154188
architecture: ${{ matrix.architecture }}
155-
- run: npm install
189+
- run: npm ci
156190
- run: npm test
157191
```
158192

@@ -164,7 +198,7 @@ steps:
164198
with:
165199
node-version: '14.x'
166200
registry-url: 'https://registry.npmjs.org'
167-
- run: npm install
201+
- run: npm ci
168202
- run: npm publish
169203
env:
170204
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -184,7 +218,7 @@ steps:
184218
with:
185219
node-version: '14.x'
186220
registry-url: <registry url>
187-
- run: yarn install
221+
- run: yarn install --frozen-lockfile
188222
- run: yarn publish
189223
env:
190224
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
@@ -206,7 +240,7 @@ steps:
206240
registry-url: 'https://registry.npmjs.org'
207241
# Skip post-install scripts here, as a malicious
208242
# script could steal NODE_AUTH_TOKEN.
209-
- run: npm install --ignore-scripts
243+
- run: npm ci --ignore-scripts
210244
env:
211245
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
212246
# `npm rebuild` will run all those post-install scripts for us.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy