pr-checkmate 1.23.24 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -13
- package/cspell.json +11 -9
- package/dist/cli.js +37 -64
- package/dist/config/constants.d.ts +51 -3
- package/dist/config/constants.js +73 -11
- package/dist/config/pr-checkmate-workflow-docker.yml +79 -0
- package/dist/config/pr-checkmate-workflow.yml +65 -326
- package/dist/core/checks/dependencies/banned-imports.js +23 -24
- package/dist/core/checks/dependencies/circular-deps.js +1 -0
- package/dist/core/checks/dependencies/dependency-check.js +1 -0
- package/dist/core/checks/dependencies/grype-scan.js +1 -0
- package/dist/core/checks/dependencies/npm-audit.js +6 -1
- package/dist/core/checks/dependencies/vuln-scan.js +1 -0
- package/dist/core/checks/findings.d.ts +198 -19
- package/dist/core/checks/findings.js +474 -22
- package/dist/core/checks/git/custom-rules.js +21 -16
- package/dist/core/checks/git/diff-smell.d.ts +17 -0
- package/dist/core/checks/git/diff-smell.js +43 -24
- package/dist/core/checks/git/large-files.js +14 -2
- package/dist/core/checks/git/leftover-debug.js +23 -14
- package/dist/core/checks/git/lockfile-drift.js +2 -1
- package/dist/core/checks/git/merge-conflict.js +19 -8
- package/dist/core/checks/git/missing-tests.js +22 -6
- package/dist/core/checks/git/todo-fixme.js +10 -9
- package/dist/core/checks/languages/shellcheck.d.ts +1 -1
- package/dist/core/checks/languages/shellcheck.js +1 -1
- package/dist/core/checks/languages/typecheck.js +1 -0
- package/dist/core/checks/pr/pr-size-check.js +2 -1
- package/dist/core/checks/quality/config-validation.d.ts +14 -4
- package/dist/core/checks/quality/config-validation.js +119 -17
- package/dist/core/checks/quality/dead-code.js +1 -0
- package/dist/core/checks/quality/duplicate-check.js +1 -0
- package/dist/core/checks/quality/license-header.js +12 -2
- package/dist/core/checks/quality/markdown-lint.js +7 -2
- package/dist/core/checks/quality/spellcheck.d.ts +50 -0
- package/dist/core/checks/quality/spellcheck.js +141 -13
- package/dist/core/checks/quality/yaml-lint.js +22 -9
- package/dist/core/checks/security/diff-security.js +115 -28
- package/dist/core/checks/security/dockerfile-security.js +23 -20
- package/dist/core/checks/security/migration-safety.js +19 -17
- package/dist/core/checks/security/sensitive-file-guard.js +37 -5
- package/dist/core/checks/security/workflow-security.d.ts +10 -0
- package/dist/core/checks/security/workflow-security.js +48 -26
- package/dist/core/commands.d.ts +27 -0
- package/dist/core/commands.js +91 -0
- package/dist/core/context.d.ts +12 -3
- package/dist/core/context.js +118 -16
- package/dist/core/install/cache.d.ts +39 -0
- package/dist/core/install/cache.js +99 -0
- package/dist/core/install/doctor.d.ts +35 -0
- package/dist/core/install/doctor.js +145 -0
- package/dist/core/install/ensure.d.ts +60 -0
- package/dist/core/install/ensure.js +169 -0
- package/dist/core/install/lock.d.ts +33 -0
- package/dist/core/install/lock.js +99 -0
- package/dist/core/install/profiles.d.ts +64 -0
- package/dist/core/install/profiles.js +170 -0
- package/dist/core/reporters.d.ts +13 -2
- package/dist/core/reporters.js +145 -104
- package/dist/core/run-checks.d.ts +25 -1
- package/dist/core/run-checks.js +124 -14
- package/dist/core/targets.js +26 -4
- package/dist/core/types.d.ts +49 -1
- package/dist/init.d.ts +29 -14
- package/dist/init.js +284 -263
- package/dist/interfaces/index.d.ts +120 -0
- package/dist/scripts/copy-configs.js +4 -0
- package/dist/scripts/generate-install-manifests.d.ts +39 -0
- package/dist/scripts/generate-install-manifests.js +121 -0
- package/dist/scripts/publish-github.js +18 -4
- package/dist/utils/detect-language.d.ts +37 -4
- package/dist/utils/detect-language.js +113 -19
- package/dist/utils/http.d.ts +59 -0
- package/dist/utils/http.js +119 -0
- package/dist/utils/logger.d.ts +52 -6
- package/dist/utils/logger.js +125 -33
- package/dist/utils/pool.d.ts +49 -0
- package/dist/utils/pool.js +124 -0
- package/dist/utils/update-notifier.d.ts +9 -0
- package/dist/utils/update-notifier.js +57 -3
- package/eslint-default-rules.json +1 -1
- package/eslint.config.mjs +14 -2
- package/install-manifests/commitlint/package-lock.json +1028 -0
- package/install-manifests/commitlint/package.json +9 -0
- package/install-manifests/core/package-lock.json +1335 -0
- package/install-manifests/core/package.json +11 -0
- package/install-manifests/cpp/package-lock.json +29 -0
- package/install-manifests/cpp/package.json +8 -0
- package/install-manifests/duplicate/package-lock.json +113 -0
- package/install-manifests/duplicate/package.json +8 -0
- package/install-manifests/js/package-lock.json +5099 -0
- package/install-manifests/js/package.json +26 -0
- package/install-manifests/markdown/package-lock.json +1281 -0
- package/install-manifests/markdown/package.json +8 -0
- package/install-manifests/python/package-lock.json +21 -0
- package/install-manifests/python/package.json +8 -0
- package/install-manifests/spellcheck/package-lock.json +1047 -0
- package/install-manifests/spellcheck/package.json +8 -0
- package/package.json +14 -28
- package/pr-checkmate.schema.json +1062 -104
- package/src/config/cspell.json +11 -9
- package/src/config/eslint-default-rules.json +1 -1
- package/src/config/pr-checkmate-workflow-docker.yml +79 -0
- package/src/config/pr-checkmate-workflow.yml +65 -326
- package/src/config/pr-checkmate.schema.json +1062 -104
|
@@ -1,353 +1,92 @@
|
|
|
1
|
-
name: PR
|
|
1
|
+
name: PR CheckMate
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
5
5
|
branches: [main, master, develop]
|
|
6
6
|
types: [opened, synchronize, reopened]
|
|
7
7
|
|
|
8
|
+
# Least privilege. `pull-requests: write` is what lets the run upsert its summary
|
|
9
|
+
# comment on the PR; drop it and the checks still run, they just report to the log.
|
|
8
10
|
permissions:
|
|
9
|
-
contents:
|
|
11
|
+
contents: read
|
|
10
12
|
pull-requests: write
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
with:
|
|
20
|
-
ref: ${{ github.head_ref }}
|
|
21
|
-
fetch-depth: 0
|
|
22
|
-
|
|
23
|
-
- name: Setup Node.js
|
|
24
|
-
uses: actions/setup-node@v4
|
|
25
|
-
with:
|
|
26
|
-
node-version: 24
|
|
27
|
-
|
|
28
|
-
- name: Install dependencies
|
|
29
|
-
run: npm ci
|
|
30
|
-
|
|
31
|
-
- name: Run PR Checkmate All Checks
|
|
32
|
-
run: npx pr-checkmate all
|
|
33
|
-
continue-on-error: true
|
|
34
|
-
|
|
35
|
-
- name: Auto-commit formatting changes
|
|
36
|
-
run: |
|
|
37
|
-
git config user.name "github-actions[bot]"
|
|
38
|
-
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
39
|
-
git add -A
|
|
40
|
-
if ! git diff --cached --quiet; then
|
|
41
|
-
git commit -m "style: auto-format code with Prettier"
|
|
42
|
-
git push origin HEAD:${{ github.head_ref }}
|
|
43
|
-
echo "Formatting changes committed and pushed"
|
|
44
|
-
else
|
|
45
|
-
echo "No formatting changes needed"
|
|
46
|
-
fi
|
|
47
|
-
env:
|
|
48
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
-
|
|
50
|
-
lint:
|
|
51
|
-
name: ESLint
|
|
52
|
-
runs-on: ubuntu-latest
|
|
53
|
-
steps:
|
|
54
|
-
- name: Checkout code
|
|
55
|
-
uses: actions/checkout@v4
|
|
56
|
-
|
|
57
|
-
- name: Setup Node.js
|
|
58
|
-
uses: actions/setup-node@v4
|
|
59
|
-
with:
|
|
60
|
-
node-version: 24
|
|
61
|
-
|
|
62
|
-
- name: Install dependencies
|
|
63
|
-
run: npm ci
|
|
64
|
-
|
|
65
|
-
- name: Run ESLint
|
|
66
|
-
run: npx pr-checkmate lint
|
|
67
|
-
continue-on-error: true
|
|
68
|
-
|
|
69
|
-
prettier:
|
|
70
|
-
name: Prettier
|
|
71
|
-
runs-on: ubuntu-latest
|
|
72
|
-
steps:
|
|
73
|
-
- name: Checkout code
|
|
74
|
-
uses: actions/checkout@v4
|
|
75
|
-
|
|
76
|
-
- name: Setup Node.js
|
|
77
|
-
uses: actions/setup-node@v4
|
|
78
|
-
with:
|
|
79
|
-
node-version: 24
|
|
80
|
-
|
|
81
|
-
- name: Install dependencies
|
|
82
|
-
run: npm ci
|
|
83
|
-
|
|
84
|
-
- name: Run Prettier
|
|
85
|
-
run: npx pr-checkmate prettier
|
|
86
|
-
continue-on-error: true
|
|
87
|
-
|
|
88
|
-
spellcheck:
|
|
89
|
-
name: Spellcheck
|
|
90
|
-
runs-on: ubuntu-latest
|
|
91
|
-
steps:
|
|
92
|
-
- name: Checkout code
|
|
93
|
-
uses: actions/checkout@v4
|
|
94
|
-
|
|
95
|
-
- name: Setup Node.js
|
|
96
|
-
uses: actions/setup-node@v4
|
|
97
|
-
with:
|
|
98
|
-
node-version: 24
|
|
99
|
-
|
|
100
|
-
- name: Install dependencies
|
|
101
|
-
run: npm ci
|
|
102
|
-
|
|
103
|
-
- name: Run Spellcheck
|
|
104
|
-
run: npx pr-checkmate spellcheck
|
|
105
|
-
continue-on-error: true
|
|
106
|
-
|
|
107
|
-
security:
|
|
108
|
-
name: Security Scan
|
|
109
|
-
runs-on: ubuntu-latest
|
|
110
|
-
steps:
|
|
111
|
-
- name: Checkout code
|
|
112
|
-
uses: actions/checkout@v4
|
|
113
|
-
with:
|
|
114
|
-
fetch-depth: 0
|
|
115
|
-
|
|
116
|
-
- name: Setup Node.js
|
|
117
|
-
uses: actions/setup-node@v4
|
|
118
|
-
with:
|
|
119
|
-
node-version: 24
|
|
120
|
-
|
|
121
|
-
- name: Install dependencies
|
|
122
|
-
run: npm ci
|
|
123
|
-
|
|
124
|
-
- name: Run Security Scan
|
|
125
|
-
run: npx pr-checkmate security
|
|
126
|
-
continue-on-error: true
|
|
127
|
-
|
|
128
|
-
dependency-check:
|
|
129
|
-
name: Dependency Check
|
|
130
|
-
runs-on: ubuntu-latest
|
|
131
|
-
steps:
|
|
132
|
-
- name: Checkout code
|
|
133
|
-
uses: actions/checkout@v4
|
|
134
|
-
with:
|
|
135
|
-
fetch-depth: 0
|
|
136
|
-
|
|
137
|
-
- name: Setup Node.js
|
|
138
|
-
uses: actions/setup-node@v4
|
|
139
|
-
with:
|
|
140
|
-
node-version: 24
|
|
141
|
-
|
|
142
|
-
- name: Install dependencies
|
|
143
|
-
run: npm ci
|
|
144
|
-
|
|
145
|
-
- name: Run Dependency Check
|
|
146
|
-
run: npx pr-checkmate dependencies
|
|
147
|
-
continue-on-error: true
|
|
148
|
-
|
|
149
|
-
circular-deps:
|
|
150
|
-
name: Circular Dependencies
|
|
151
|
-
runs-on: ubuntu-latest
|
|
152
|
-
steps:
|
|
153
|
-
- name: Checkout code
|
|
154
|
-
uses: actions/checkout@v4
|
|
155
|
-
|
|
156
|
-
- name: Setup Node.js
|
|
157
|
-
uses: actions/setup-node@v4
|
|
158
|
-
with:
|
|
159
|
-
node-version: 24
|
|
160
|
-
|
|
161
|
-
- name: Install dependencies
|
|
162
|
-
run: npm ci
|
|
163
|
-
|
|
164
|
-
- name: Run Circular Dependency Check
|
|
165
|
-
run: npx pr-checkmate circular
|
|
166
|
-
continue-on-error: true
|
|
167
|
-
|
|
168
|
-
license-check:
|
|
169
|
-
name: License Check
|
|
170
|
-
runs-on: ubuntu-latest
|
|
171
|
-
steps:
|
|
172
|
-
- name: Checkout code
|
|
173
|
-
uses: actions/checkout@v4
|
|
174
|
-
|
|
175
|
-
- name: Setup Node.js
|
|
176
|
-
uses: actions/setup-node@v4
|
|
177
|
-
with:
|
|
178
|
-
node-version: 24
|
|
179
|
-
|
|
180
|
-
- name: Install dependencies
|
|
181
|
-
run: npm ci
|
|
182
|
-
|
|
183
|
-
- name: Run License Check
|
|
184
|
-
run: npx pr-checkmate license
|
|
185
|
-
continue-on-error: true
|
|
186
|
-
|
|
187
|
-
pr-size:
|
|
188
|
-
name: PR Size
|
|
189
|
-
runs-on: ubuntu-latest
|
|
190
|
-
steps:
|
|
191
|
-
- name: Checkout code
|
|
192
|
-
uses: actions/checkout@v4
|
|
193
|
-
with:
|
|
194
|
-
fetch-depth: 0
|
|
195
|
-
|
|
196
|
-
- name: Setup Node.js
|
|
197
|
-
uses: actions/setup-node@v4
|
|
198
|
-
with:
|
|
199
|
-
node-version: 24
|
|
200
|
-
|
|
201
|
-
- name: Install dependencies
|
|
202
|
-
run: npm ci
|
|
203
|
-
|
|
204
|
-
- name: Check PR Size
|
|
205
|
-
run: npx pr-checkmate pr-size
|
|
206
|
-
continue-on-error: true
|
|
207
|
-
|
|
208
|
-
pr-title:
|
|
209
|
-
name: PR Title
|
|
210
|
-
runs-on: ubuntu-latest
|
|
211
|
-
steps:
|
|
212
|
-
- name: Checkout code
|
|
213
|
-
uses: actions/checkout@v4
|
|
214
|
-
|
|
215
|
-
- name: Setup Node.js
|
|
216
|
-
uses: actions/setup-node@v4
|
|
217
|
-
with:
|
|
218
|
-
node-version: 24
|
|
219
|
-
|
|
220
|
-
- name: Install dependencies
|
|
221
|
-
run: npm ci
|
|
222
|
-
|
|
223
|
-
- name: Check PR Title
|
|
224
|
-
run: npx pr-checkmate pr-title
|
|
225
|
-
continue-on-error: true
|
|
226
|
-
|
|
227
|
-
outdated-deps:
|
|
228
|
-
name: Outdated Dependencies
|
|
229
|
-
runs-on: ubuntu-latest
|
|
230
|
-
steps:
|
|
231
|
-
- name: Checkout code
|
|
232
|
-
uses: actions/checkout@v4
|
|
233
|
-
|
|
234
|
-
- name: Setup Node.js
|
|
235
|
-
uses: actions/setup-node@v4
|
|
236
|
-
with:
|
|
237
|
-
node-version: 24
|
|
238
|
-
|
|
239
|
-
- name: Install dependencies
|
|
240
|
-
run: npm ci
|
|
241
|
-
|
|
242
|
-
- name: Check Outdated Dependencies
|
|
243
|
-
run: npx pr-checkmate outdated
|
|
244
|
-
continue-on-error: true
|
|
245
|
-
|
|
246
|
-
markdown-lint:
|
|
247
|
-
name: Markdown Lint
|
|
248
|
-
runs-on: ubuntu-latest
|
|
249
|
-
steps:
|
|
250
|
-
- name: Checkout code
|
|
251
|
-
uses: actions/checkout@v4
|
|
252
|
-
with:
|
|
253
|
-
fetch-depth: 0
|
|
14
|
+
# Push three times in a minute and the first two runs become answers to questions
|
|
15
|
+
# nobody is asking any more — they still hold a runner, and they still race to
|
|
16
|
+
# upsert the summary comment, so a stale verdict can land on top of a fresh one.
|
|
17
|
+
# Keyed per PR, so runs on different pull requests never cancel each other.
|
|
18
|
+
concurrency:
|
|
19
|
+
group: pr-checkmate-${{ github.workflow }}-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
254
21
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
node-version: 24
|
|
259
|
-
|
|
260
|
-
- name: Install dependencies
|
|
261
|
-
run: npm ci
|
|
262
|
-
|
|
263
|
-
- name: Run Markdown Lint
|
|
264
|
-
run: npx pr-checkmate markdown
|
|
265
|
-
continue-on-error: true
|
|
266
|
-
|
|
267
|
-
typecheck:
|
|
268
|
-
name: TypeScript Type Check
|
|
269
|
-
runs-on: ubuntu-latest
|
|
270
|
-
steps:
|
|
271
|
-
- name: Checkout code
|
|
272
|
-
uses: actions/checkout@v4
|
|
273
|
-
with:
|
|
274
|
-
ref: ${{ github.head_ref }}
|
|
275
|
-
fetch-depth: 0
|
|
276
|
-
|
|
277
|
-
- name: Setup Node.js
|
|
278
|
-
uses: actions/setup-node@v4
|
|
279
|
-
with:
|
|
280
|
-
node-version: 24
|
|
281
|
-
|
|
282
|
-
- name: Install dependencies
|
|
283
|
-
run: npm ci
|
|
284
|
-
|
|
285
|
-
- name: Run TypeScript Type Check
|
|
286
|
-
run: npx pr-checkmate typecheck
|
|
287
|
-
continue-on-error: true
|
|
288
|
-
|
|
289
|
-
diff-smell:
|
|
290
|
-
name: Diff Code Smell
|
|
291
|
-
runs-on: ubuntu-latest
|
|
292
|
-
steps:
|
|
293
|
-
- name: Checkout code
|
|
294
|
-
uses: actions/checkout@v4
|
|
295
|
-
with:
|
|
296
|
-
ref: ${{ github.head_ref }}
|
|
297
|
-
fetch-depth: 0
|
|
298
|
-
|
|
299
|
-
- name: Setup Node.js
|
|
300
|
-
uses: actions/setup-node@v4
|
|
301
|
-
with:
|
|
302
|
-
node-version: 24
|
|
303
|
-
|
|
304
|
-
- name: Install dependencies
|
|
305
|
-
run: npm ci
|
|
306
|
-
|
|
307
|
-
- name: Scan Diff for Code Smells
|
|
308
|
-
run: npx pr-checkmate diff-smell
|
|
309
|
-
continue-on-error: true
|
|
310
|
-
|
|
311
|
-
pr-body:
|
|
312
|
-
name: PR Description
|
|
22
|
+
jobs:
|
|
23
|
+
pr-checkmate:
|
|
24
|
+
name: PR CheckMate
|
|
313
25
|
runs-on: ubuntu-latest
|
|
26
|
+
# A hung step otherwise runs to GitHub's six-hour default before anyone hears
|
|
27
|
+
# about it. Every check here has its own internal timeout; this is the backstop
|
|
28
|
+
# for the ones that cannot fail themselves — a wedged network fetch, a tool
|
|
29
|
+
# waiting on stdin. Raise it for a large monorepo.
|
|
30
|
+
timeout-minutes: 20
|
|
314
31
|
steps:
|
|
315
32
|
- name: Checkout code
|
|
316
|
-
uses: actions/checkout@v4
|
|
33
|
+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
317
34
|
with:
|
|
318
|
-
|
|
35
|
+
# Required, not optional. Without the full history the PR base commit is
|
|
36
|
+
# not in the clone, no diff range can be built, and every diff-based
|
|
37
|
+
# check — Diff Security, Workflow Security, Dockerfile Security,
|
|
38
|
+
# Sensitive Files and a dozen others — skips itself. The run then says
|
|
39
|
+
# `Scan Scope: … set fetch-depth: 0`, which is this line.
|
|
319
40
|
fetch-depth: 0
|
|
320
41
|
|
|
321
42
|
- name: Setup Node.js
|
|
322
|
-
uses: actions/setup-node@v4
|
|
43
|
+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
323
44
|
with:
|
|
324
45
|
node-version: 24
|
|
46
|
+
cache: 'npm'
|
|
325
47
|
|
|
326
48
|
- name: Install dependencies
|
|
327
49
|
run: npm ci
|
|
328
50
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
steps:
|
|
337
|
-
- name: Checkout code
|
|
338
|
-
uses: actions/checkout@v4
|
|
51
|
+
# PR CheckMate fetches only the tooling this repository turns out to need
|
|
52
|
+
# (`npx pr-checkmate doctor` prints what and why). Without this step that
|
|
53
|
+
# tooling is fetched again on every run: the download shrinks, the wait
|
|
54
|
+
# does not. The key carries the pr-checkmate version, so an upgrade fetches
|
|
55
|
+
# afresh instead of reusing tooling meant for the previous one.
|
|
56
|
+
- name: Cache PR CheckMate tooling
|
|
57
|
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
339
58
|
with:
|
|
340
|
-
|
|
341
|
-
|
|
59
|
+
path: ~/.cache/pr-checkmate
|
|
60
|
+
key: pr-checkmate-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
|
61
|
+
restore-keys: |
|
|
62
|
+
pr-checkmate-${{ runner.os }}-
|
|
342
63
|
|
|
343
|
-
|
|
344
|
-
|
|
64
|
+
# Grype keeps its own vulnerability database, and it is the single largest
|
|
65
|
+
# download in the whole run: 134 MB compressed, 1.9 GB unpacked, refreshed
|
|
66
|
+
# daily upstream. Without this step every job pays for it again. The key is
|
|
67
|
+
# dated rather than content-hashed, because the thing that changes is the
|
|
68
|
+
# upstream database, not anything in this repository — a stale entry is
|
|
69
|
+
# restored by the prefix and grype updates it in place.
|
|
70
|
+
- name: Cache Grype vulnerability database
|
|
71
|
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
345
72
|
with:
|
|
346
|
-
|
|
73
|
+
path: ~/.cache/grype
|
|
74
|
+
key: grype-db-${{ runner.os }}-${{ github.run_id }}
|
|
75
|
+
restore-keys: |
|
|
76
|
+
grype-db-${{ runner.os }}-
|
|
347
77
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
78
|
+
# One job runs the whole registry. Splitting it per check would repeat the
|
|
79
|
+
# checkout and install for every one of them, and the selection of what runs
|
|
80
|
+
# belongs in pr-checkmate.json (`severity`), not in copied YAML.
|
|
81
|
+
#
|
|
82
|
+
# This template is the one `init` scaffolds when pr-checkmate IS a
|
|
83
|
+
# dependency: `npm ci` above installs it, so npx runs that copy at the
|
|
84
|
+
# version your lockfile pins. A repository that does not install it gets
|
|
85
|
+
# the container variant instead, because bare `npx` would resolve to the
|
|
86
|
+
# newest release and download it on every job.
|
|
87
|
+
- name: Run PR CheckMate
|
|
88
|
+
env:
|
|
89
|
+
# Not injected automatically: without this the run cannot authenticate,
|
|
90
|
+
# and the summary comment silently never reaches the PR.
|
|
91
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
92
|
+
run: npx pr-checkmate all
|
|
@@ -27,41 +27,40 @@ function compileBans(ctx) {
|
|
|
27
27
|
exports.bannedImportsCheck = {
|
|
28
28
|
name: 'Banned Imports',
|
|
29
29
|
phase: 'informational',
|
|
30
|
+
// No `requiresDiff`: a banned import is banned wherever it is, not only where
|
|
31
|
+
// it was just introduced (ticket 067).
|
|
30
32
|
applies(ctx) {
|
|
31
|
-
return (ctx.config.bannedImports?.length ?? 0) > 0
|
|
33
|
+
return (ctx.config.bannedImports?.length ?? 0) > 0;
|
|
32
34
|
},
|
|
33
35
|
async run(ctx) {
|
|
34
|
-
var _a;
|
|
35
36
|
const bans = compileBans(ctx);
|
|
36
37
|
if (bans.length === 0)
|
|
37
38
|
return (0, types_1.pass)('no banned imports configured');
|
|
38
39
|
try {
|
|
39
|
-
const stdout = await (0, findings_1.diffAddedLines)(ctx, ['*']);
|
|
40
40
|
const errors = {};
|
|
41
41
|
const warnings = {};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(
|
|
42
|
+
await (0, findings_1.reviewLines)(ctx, ['*'], stdout => {
|
|
43
|
+
var _a;
|
|
44
|
+
for (const raw of stdout.split('\n')) {
|
|
45
|
+
if (!raw.startsWith('+') || raw.startsWith('+++'))
|
|
46
|
+
continue;
|
|
47
|
+
const content = raw.slice(1);
|
|
48
|
+
for (const ban of bans) {
|
|
49
|
+
if (ban.re.test(content)) {
|
|
50
|
+
const bucket = ban.severity === 'error' ? errors : warnings;
|
|
51
|
+
(bucket[_a = ban.message] ?? (bucket[_a] = [])).push(content.trim().substring(0, 100));
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
parts.push(`${totalErrors} banned (error)`);
|
|
62
|
-
if (totalWarnings > 0)
|
|
63
|
-
parts.push(`${totalWarnings} banned (warn)`);
|
|
64
|
-
return totalErrors > 0 ? (0, types_1.fail)(parts.join(', ')) : (0, types_1.warn)(parts.join(', '));
|
|
55
|
+
});
|
|
56
|
+
// A ban configured as "error" blocks the run, regardless of phase — that
|
|
57
|
+
// is the default `failOn`, and the client can still relax it per repo.
|
|
58
|
+
return (0, findings_1.reportSeverityBuckets)(errors, warnings, {
|
|
59
|
+
prefix: PREFIX,
|
|
60
|
+
errorSummary: n => `${n} banned (error)`,
|
|
61
|
+
warningSummary: n => `${n} banned (warn)`,
|
|
62
|
+
...(0, findings_1.clientFindingOptions)(ctx),
|
|
63
|
+
});
|
|
65
64
|
}
|
|
66
65
|
catch (err) {
|
|
67
66
|
utils_1.logger.warn(`[Banned Imports]: ⚠️ Could not analyze diff\n${err}`);
|
|
@@ -37,7 +37,12 @@ exports.npmAuditCheck = {
|
|
|
37
37
|
return node_fs_1.default.existsSync(node_path_1.default.join(ctx.cwd, 'package.json'));
|
|
38
38
|
},
|
|
39
39
|
async run(ctx) {
|
|
40
|
-
|
|
40
|
+
// `high`, not `moderate`. A moderate CVE in a direct dependency often has no
|
|
41
|
+
// fix available, and blocking on it stops the team shipping anything at all —
|
|
42
|
+
// indefinitely, for a risk they have usually already accepted. A gate that
|
|
43
|
+
// cannot be satisfied gets switched off, and then the high ones stop blocking
|
|
44
|
+
// too. Clients who want the stricter line set `security.npm-audit.auditLevel`.
|
|
45
|
+
const auditLevel = ctx.config.security?.['npm-audit']?.auditLevel ?? 'high';
|
|
41
46
|
const ignore = new Set((ctx.config.security?.['npm-audit']?.ignore ?? []).map(name => name.toLowerCase()));
|
|
42
47
|
const ownName = getOwnPackageName();
|
|
43
48
|
const { stdout } = await (0, execa_1.execa)('npm', ['audit', '--json'], { cwd: ctx.cwd, reject: false });
|