Skip to content

Commit 7a58264

Browse files
isaacswraithgar
authored andcommitted
chore(ci): check that docs are up to date in ci
When we accidentally edit the auto-generated portions of the docs, this will catch the error and cause CI to fail. Later phase automated safety check that the early-stage human commenting in the last commit also addresses. Re: #3654 Re: #3630 PR-URL: #3655 Credit: @isaacs Close: #3655 Reviewed-by: @nlf
1 parent 22f3bbb commit 7a58264

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

.github/workflows/ci.yml

+18-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,24 @@ jobs:
2020
run: node . run posttest
2121
env:
2222
DEPLOY_VERSION: testing
23-
23+
24+
check_docs:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Use Node.js 14.x
29+
uses: actions/setup-node@v1
30+
with:
31+
node-version: 14.x
32+
- name: Install dependencies
33+
run: |
34+
node . install --ignore-scripts --no-audit
35+
- name: Rebuild the docs
36+
run: make freshdocs
37+
- name: Git should not be dirty
38+
run: node scripts/git-dirty.js
39+
40+
2441
licenses:
2542
runs-on: ubuntu-latest
2643
steps:

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ docs/content/using-npm/config.md: scripts/config-doc.js lib/utils/config/*.js
7676
docs/content/commands/npm-%.md: lib/%.js scripts/config-doc-command.js lib/utils/config/*.js
7777
node scripts/config-doc-command.js $@ $<
7878

79+
freshdocs:
80+
touch lib/utils/config/definitions.js
81+
touch scripts/config-doc-command.js
82+
touch scripts/config-doc.js
83+
make docs
84+
7985
test: dev-deps
8086
node bin/npm-cli.js test
8187

@@ -109,4 +115,4 @@ publish: gitclean ls-ok link test smoke-tests docs prune
109115
release: gitclean ls-ok docs prune
110116
@bash scripts/release.sh
111117

112-
.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok dev-deps prune
118+
.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok dev-deps prune freshdocs

scripts/git-dirty.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env node
2+
const { spawnSync } = require('child_process')
3+
const changes = spawnSync('git', ['status', '--porcelain', '-uno'])
4+
const stdout = changes.stdout.toString('utf8')
5+
const stderr = changes.stderr.toString('utf8')
6+
const { status, signal } = changes
7+
console.log(stdout)
8+
console.error(stderr)
9+
if (status || signal) {
10+
console.error({ status, signal })
11+
process.exitCode = status || 1
12+
}
13+
if (stdout.trim() !== '')
14+
throw new Error('git dirty')
15+
else
16+
console.log('git clean')

0 commit comments

Comments
 (0)