Skip to content

Commit 94cb80a

Browse files
authored
chore: simplify and standardize package.json scripts and CI setup (#7069)
* chore(package.json): simplify site build There were two separate scripts for doing the same thing. * refactor(scripts): split up prepare-for-publish No behavioural changes in this commit. * chore: remove bizarre postinstall hook that builds - It's nonstandard - It's surprising - Since we use `tsc` to build, it causes every CI check to fail if you have type errors - It causes issues when rewriting git history - It's a bit magical * chore: remove leftover refs to ava ava was removed a couple years ago * ci: rename misleading jobs They handle two kinds of benchmarks, only one of which is package size * chore: split formating, linting, and unit testing * ci: simplify workflow skipping for release branches * chore(package.json): sort scripts * chore(deps): add missing dependency on npm-run-all We're using `run-s` which comes from this dep but it only happens to work because one of our dependencies has a transitive dependency on `npm-run-all`. IMO we should kill this, but for now this just adds the missing dep. Note: npm-run-all2 is a maintained fork of the unmaintained npm-run-all
1 parent fb36998 commit 94cb80a

12 files changed

+334
-136
lines changed

.github/workflows/benchmark-post.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- completed
77

88
jobs:
9-
post-package-size:
9+
post-benchmarks:
1010
runs-on: ubuntu-latest
1111
steps:
1212
# This posts the status to the PR/commit

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches: [main]
88
jobs:
9-
package-size:
9+
calculate-benchmarks:
1010
if: startsWith(github.head_ref, 'release-please') == false
1111
runs-on: ubuntu-latest
1212
steps:

.github/workflows/e2e-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
key: verdaccio-e2e-cli-${{ hashFiles('./package-lock.json') }}
4242
- name: Install dependencies
4343
run: npm ci --no-audit
44+
- name: Build package
45+
run: npm run build
4446
- run: npm run e2e
4547
- name: Notify Slack
4648
uses: 8398a7/action-slack@v3
@@ -89,6 +91,8 @@ jobs:
8991
key: verdaccio-e2e-cli-${{ hashFiles('./package-lock.json') }}
9092
- name: Install dependencies
9193
run: npm ci --no-audit
94+
- name: Build package
95+
run: npm run build
9296
- run: npm run e2e
9397
- name: Notify Slack
9498
uses: 8398a7/action-slack@v3

.github/workflows/format.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
format:
11+
name: Format
12+
if: "${{ !startsWith(github.head_ref, 'release-') }}"
13+
steps:
14+
- name: Git checkout
15+
uses: actions/checkout@v4
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22
20+
cache: npm
21+
- name: Install core dependencies
22+
run: npm ci --no-audit
23+
- name: Check format
24+
run: npm run format

.github/workflows/integration-tests.yml

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
integration:
1111
name: Integration
12+
if: "${{ !startsWith(github.head_ref, 'release-') }}"
1213
runs-on: ${{ matrix.os }}
1314
timeout-minutes: 40
1415
strategy:
@@ -27,55 +28,41 @@ jobs:
2728
node-version: '22'
2829
fail-fast: false
2930
steps:
30-
# Sets an output parameter if this is a release PR
31-
- name: Check for release
32-
id: release-check
33-
# For windows we have to use $env:
34-
run: |-
35-
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
36-
echo "IS_RELEASE=true" >> $env:GITHUB_OUTPUT
37-
if: "${{ startsWith(github.head_ref, 'release-') }}"
3831
# This improves Windows network performance, we need this since we open many ports in our tests
3932
- name: Increase Windows port limit and reduce time wait delay
4033
run: |
4134
netsh int ipv4 set dynamicport tcp start=1025 num=64511
4235
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters /v TcpTimedWaitDelay /t REG_DWORD /d 30 /f
43-
if: "${{ matrix.os == 'windows-latest' && !steps.release-check.outputs.IS_RELEASE }}"
36+
if: "${{ matrix.os == 'windows-latest' }}"
4437
- name: Git checkout
4538
uses: actions/checkout@v4
4639
with:
4740
fetch-depth: 0
48-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
4941
- name: Use Node.js ${{ matrix.node-version }}
5042
uses: actions/setup-node@v4
5143
with:
5244
node-version: ${{ matrix.node-version }}
5345
cache: npm
5446
check-latest: true
55-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
5647
- name: Install PNPM
5748
run: |
5849
corepack enable
5950
corepack prepare [email protected] --activate
60-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
6151
- name: Setup Deno
6252
uses: denoland/setup-deno@v1
63-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
6453
with:
6554
deno-version: v1.44.4
6655
- name: Install core dependencies
6756
run: npm ci --no-audit
68-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
57+
- name: Build package
58+
run: npm run build
6959
- name: Generate self-signed certificates
7060
run: npm run certs
71-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
7261
shell: bash
7362
- name: Prepare tests
7463
run: npm run test:init
75-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
7664
- name: Tests
7765
uses: nick-fields/retry@v3
78-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
7966
with:
8067
timeout_minutes: 15
8168
max_attempts: 3
@@ -103,7 +90,6 @@ jobs:
10390
echo "node=node_${node/.*.*/}" >> $GITHUB_OUTPUT
10491
echo "node=node_${node/.*.*/}" >> $env:GITHUB_OUTPUT
10592
shell: bash
106-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
10793

10894
- name: Sanitize shard for artefact name
10995
id: sanitize-shard-name
@@ -122,22 +108,14 @@ jobs:
122108
with:
123109
flags: ${{ steps.test-coverage-flags.outputs.os }},${{ steps.test-coverage-flags.outputs.node }}
124110
token: ${{ secrets.CODECOV_TOKEN }}
125-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
126111
# Specific tests for known test that failed on windows using node 23.
127112
# Can be replaced with larger node 23 tests in the future.
128113
integration-win-node-23:
129114
name: Integration test windows latest node23 specific
115+
if: "${{ !startsWith(github.head_ref, 'release-') }}"
130116
runs-on: windows-latest
131117
timeout-minutes: 40
132118
steps:
133-
# Sets an output parameter if this is a release PR
134-
- name: Check for release
135-
id: release-check
136-
# For windows we have to use $env:
137-
run: |-
138-
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
139-
echo "IS_RELEASE=true" >> $env:GITHUB_OUTPUT
140-
if: "${{ startsWith(github.head_ref, 'release-') }}"
141119
# This improves Windows network performance, we need this since we open many ports in our tests
142120
- name: Increase Windows port limit and reduce time wait delay
143121
run: |
@@ -147,37 +125,31 @@ jobs:
147125
uses: actions/checkout@v4
148126
with:
149127
fetch-depth: 0
150-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
151128
- name: Use Node.js
152129
uses: actions/setup-node@v4
153130
with:
154131
node-version: '23.x'
155132
cache: npm
156133
check-latest: true
157-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
158134
- name: Install PNPM
159135
run: |
160136
corepack enable
161137
corepack prepare [email protected] --activate
162-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
163138
- name: Setup Deno
164139
uses: denoland/setup-deno@v1
165-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
166140
with:
167141
deno-version: v1.44.4
168142
- name: Install core dependencies
169143
run: npm ci --no-audit
170-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
144+
- name: Build package
145+
run: npm run build
171146
- name: Generate self-signed certificates
172147
run: npm run certs
173-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
174148
shell: bash
175149
- name: Prepare tests
176150
run: npm run test:init
177-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
178151
- name: Tests
179152
uses: nick-fields/retry@v3
180-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
181153
with:
182154
timeout_minutes: 15
183155
max_attempts: 3
@@ -205,7 +177,6 @@ jobs:
205177
echo "node=node_${node/.*.*/}" >> $GITHUB_OUTPUT
206178
echo "node=node_${node/.*.*/}" >> $env:GITHUB_OUTPUT
207179
shell: bash
208-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
209180

210181
- name: Store npm error artefacts
211182
uses: actions/upload-artifact@v4
@@ -220,4 +191,3 @@ jobs:
220191
with:
221192
flags: ${{ steps.test-coverage-flags.outputs.os }},${{ steps.test-coverage-flags.outputs.node }}
222193
token: ${{ secrets.CODECOV_TOKEN }}
223-
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'

.github/workflows/lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
if: "${{ !startsWith(github.head_ref, 'release-') }}"
13+
steps:
14+
- name: Git checkout
15+
uses: actions/checkout@v4
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22
20+
cache: npm
21+
- name: Install core dependencies
22+
run: npm ci --no-audit
23+
- name: Run lint
24+
run: npm run lint

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
unit:
1111
name: Unit
12+
if: "${{ !startsWith(github.head_ref, 'release-') }}"
1213
runs-on: ${{ matrix.os }}
1314
strategy:
1415
matrix:
@@ -19,35 +20,22 @@ jobs:
1920
node-version: '22.x'
2021
fail-fast: false
2122
steps:
22-
# Sets an output parameter if this is a release PR
23-
- name: Check for release
24-
id: release-check
25-
# For windows we have to use $env:
26-
run: |-
27-
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
28-
echo "IS_RELEASE=true" >> $env:GITHUB_OUTPUT
29-
if: "${{ startsWith(github.head_ref, 'release-') }}"
3023
- name: Git checkout
3124
uses: actions/checkout@v4
32-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
3325
- name: Use Node.js ${{ matrix.node-version }}
3426
uses: actions/setup-node@v4
3527
with:
3628
node-version: ${{ matrix.node-version }}
3729
cache: npm
3830
check-latest: true
39-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
4031
- name: Install core dependencies
4132
run: npm ci --no-audit
42-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
43-
- name: Linting
44-
run: npm run format:ci
45-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
33+
- name: Build package
34+
run: npm run build
4635
- name: Run unit tests
4736
uses: nick-fields/retry@v3
4837
with:
4938
timeout_minutes: 15
5039
max_attempts: 3
5140
retry_on: error
5241
command: npm run test:ci:vitest:unit
53-
if: '${{!steps.release-check.outputs.IS_RELEASE}}'

.github/workflows/verify-docs.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ jobs:
2020
cache: npm
2121
- name: Install core dependencies
2222
run: npm ci --no-audit
23-
- name: Install site dependencies
24-
run: npm run site:build:install
2523
- name: Generate docs
26-
run: npm run docs
24+
run: npm run site:build
2725
- name: Check for changes
2826
run: |
2927
if [ -z "$(git status --porcelain)" ]; then
3028
echo "No changes to docs files detected"
3129
else
32-
echo "Changes to docs files detected, please run 'npm run docs' to sync docs"
30+
echo "Changes to docs files detected, please run 'npm run site:build' to sync docs"
3331
exit 1
3432
fi

CONTRIBUTING.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ promote a positive and inclusive environment.
2424
- [Releasing](#releasing)
2525
- [License](#license)
2626

27-
2827
## Developing locally
2928

3029
First, fork and clone the repository. If you’re not sure how to do this, please watch
@@ -33,7 +32,7 @@ First, fork and clone the repository. If you’re not sure how to do this, pleas
3332
Run:
3433

3534
```bash
36-
npm install && npm run site:build:install
35+
npm install && npm run build
3736
```
3837

3938
Tests are run with:
@@ -73,6 +72,7 @@ to run ESLint and Prettier automatically on file save. Otherwise, you should run
7372

7473
```bash
7574
npm run format
75+
npm run lint
7676
```
7777

7878
Alternatively, you can set up your IDE to integrate with Prettier and ESLint for JavaScript and Markdown files.
@@ -91,11 +91,14 @@ DEBUG=true ./bin/run.js [command]
9191

9292
### Attaching a Debugger
9393

94-
When debugging a project, it's super helpful to attach a debugger to the CLI. If you use VS Code, here's how you can do it:
94+
When debugging a project, it's super helpful to attach a debugger to the CLI. If you use VS Code, here's how you can do
95+
it:
9596

9697
1. Open this repository in VS Code.
97-
2. Open a "JavaScript Debug Terminal" (e.g. by searching for it in the Command Palette (Shift-Cmd+P)). Every Node process that's opened in this terminal will have a debugger attached.
98-
3. Place a breakpoint somewhere in the CLI. You will have to place them in the compiled `.js` files as opposed to the `.ts` files.
98+
2. Open a "JavaScript Debug Terminal" (e.g. by searching for it in the Command Palette (Shift-Cmd+P)). Every Node
99+
process that's opened in this terminal will have a debugger attached.
100+
3. Place a breakpoint somewhere in the CLI. You will have to place them in the compiled `.js` files as opposed to the
101+
`.ts` files.
99102
4. In your JavaScript Debug Terminal, navigate to the project you'd like to debug.
100103
5. Run `/path/to/netlify/cli/bin/run.js`. The debugger should be connecting automatically.
101104

@@ -113,9 +116,10 @@ A good place to start is reading the base command README and looking at the comm
113116

114117
> If you’d like to learn more on how `netlify dev` works, check [here](./docs/netlify-dev.md)
115118
116-
117119
### Adding or updating a command
118-
If you're adding a new command or updating an existing one, make sure to also add docs for it by running `npm run site:build`.
120+
121+
If you're adding a new command or updating an existing one, make sure to also add docs for it by running
122+
`npm run site:build`.
119123

120124
This will automatically generate documentation for you that will look like the following:
121125

@@ -130,17 +134,18 @@ description: A description.
130134
<!-- AUTO-GENERATED-CONTENT:START (GENERATE_COMMANDS_DOCS) -->
131135

132136
<!-- AUTO-GENERATED-CONTENT:END -->
133-
134137
```
135138

136-
When adding a new command, you will also need to add it to the nav sidebar manually by adding it to the `navOrder` array in `site/src/_app.js`
139+
When adding a new command, you will also need to add it to the nav sidebar manually by adding it to the `navOrder` array
140+
in `site/src/_app.js`
137141

138142
### Updating our documentation
139143

140144
If documentation looks to be out of date, it is likely that the code for the command itself is not correct.
141145

142-
To update the documentation, update the code (rather than the markdown files) and then run `npm run docs` to sync the docs. To confirm that the changes to the docs are correct, run `cd site && npm run dev:start` to run the docs locally.
143-
146+
To update the documentation, update the code (rather than the markdown files) and then run `npm run site:build` to sync
147+
the docs. To confirm that the changes to the docs are correct, run `cd site && npm run dev:start` to run the docs
148+
locally.
144149

145150
### Testing
146151

@@ -200,7 +205,8 @@ We actively welcome your pull requests.
200205

201206
## Releasing
202207

203-
Tag the 'release' pull request using the `automerge` label. This will merge the pull request on GitHub and publish the package to npm.
208+
Tag the 'release' pull request using the `automerge` label. This will merge the pull request on GitHub and publish the
209+
package to npm.
204210

205211
### Creating a prerelease
206212

0 commit comments

Comments
 (0)