Skip to content

Commit be45d04

Browse files
authored
chore: add local CI script and format:check (#965)
## Summary - Adds `.github/workflows/ci-local.sh` to run the full CI suite locally before pushing — validates Node version against `.nvmrc`, exports `CI=true`, and runs the same steps as GitHub Actions (`test`, `fuzz`, `lint`, `test:types`, `format:check`) - Adds `format:check` npm script and wires it into the `lint` job in `test-node.js.yml` - Ignores generated files that would otherwise cause false positives: `examples/typescript-node-es6/dist` (from `test:types`) in `.eslintignore` and `.prettierignore`; `test/error/reported.json` in `.prettierignore` - Fixes `test:types` failing locally when root `node_modules` is installed: restricts `typeRoots` in `examples/typescript-node-es6/tsconfig.json` to the example's own `node_modules` so TypeScript 3 doesn't pick up `@types/yargs` (which uses TS 4.1+ template literal syntax) - Script cleans up generated test artefacts (`test/error/reported.json`, `test/errors/reported.json`) on start to prevent cross-branch contamination ## Test plan - [x] CI passes on this PR - [ ] `bash .github/workflows/ci-local.sh` passes locally on `master` after merge
1 parent 2d73ddd commit be45d04

6 files changed

Lines changed: 28 additions & 1 deletion

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test/grammar/regexp.js
2+
examples/typescript-node-es6/dist

.github/workflows/ci-local.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
export CI=true
4+
5+
EXPECTED=$(cat .nvmrc)
6+
ACTUAL=$(node --version)
7+
if [[ "$ACTUAL" != "v${EXPECTED}"* ]]; then
8+
echo "ERROR: expected node $EXPECTED, got $ACTUAL" >&2
9+
exit 1
10+
fi
11+
12+
# Remove generated test artefacts that differ between branches to avoid cross-branch contamination
13+
rm -f test/error/reported.json test/errors/reported.json
14+
15+
npm ci
16+
npm run test
17+
npm run fuzz
18+
npm run lint
19+
npm run test:types
20+
npm run format:check

.github/workflows/test-node.js.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ jobs:
6565
node-version-file: .node-version
6666
- run: npm ci --no-audit
6767
- run: npm run lint
68+
- run: npm run format:check

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
test/grammar/regexp.js
2+
test/error/reported.json
3+
examples/typescript-node-es6/dist

examples/typescript-node-es6/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3333
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
3434
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35-
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
35+
"typeRoots": [
36+
"./node_modules/@types"
37+
] /* Specify multiple folders that act like `./node_modules/@types`. */,
3638
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
3739
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3840
// "resolveJsonModule": true, /* Enable importing .json files */

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"scripts": {
3131
"lint": "eslint examples lib test",
3232
"format": "prettier --write examples lib test index.d.ts",
33+
"format:check": "prettier --check examples lib test index.d.ts",
3334
"changelog": "auto-changelog --unreleased-only",
3435
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
3536
"test": "jest",

0 commit comments

Comments
 (0)