Skip to content

Commit 5efeea2

Browse files
tkirda-bisonclaude
andcommitted
ci: add github actions workflow for lint, format, test, build
PR-3 of the modernization plan: every push to master and every pull request now runs npm ci then lint, format:check, test, build sequentially on node 20 / ubuntu. All four are required. - .github/workflows/ci.yml: single job, single matrix entry, npm cache keyed off package-lock.json. - package.json: new format:check script (prettier --check, same scope as format) so CI doesn't have to abuse --write. engines.node set to >=20 to mirror the runner. - CLAUDE.md: documents both the new script and the CI gate. This is the safety net before the TypeScript rewrite of src/ lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f5ae91e commit 5efeea2

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: npm
18+
19+
- run: npm ci
20+
21+
- run: npm run lint
22+
- run: npm run format:check
23+
- run: npm test
24+
- run: npm run build

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ This is a single-file jQuery plugin (Ajax Autocomplete). The entire implementati
1212
- `npm run test:watch` — Vitest watch mode for local TDD.
1313
- `npm run lint` — ESLint (flat config in `eslint.config.mjs`) over `src/`, `test/`, and `scripts/build.mjs`.
1414
- `npm run format` — Prettier rewrite of `src/`, `test/`, and `scripts/build.mjs` (100-col, 4-space, ES5 trailing commas — config in `package.json`). Demo files under `scripts/` (`countries.js`, `demo.js`) are intentionally excluded.
15+
- `npm run format:check` — Prettier check-only, same scope. Used by CI; fails if anything would be rewritten.
1516
- `npm run build` — runs `scripts/build.mjs` (Node ESM, no bundler): copies `src/jquery.autocomplete.js` to `dist/jquery.autocomplete.js` while substituting the `%version%` placeholder with `package.json` `version`, minifies to `dist/jquery.autocomplete.min.js` via terser with a fresh banner, and syncs `devbridge-autocomplete.jquery.json` version. Run this before release/commit when source changes.
1617

18+
## CI
19+
20+
`.github/workflows/ci.yml` runs on every push to `master` and every pull request: `npm ci`, then `lint`, `format:check`, `test`, `build` — in that order, all required. Node 20 LTS, Ubuntu, single job. The `engines.node` field in `package.json` mirrors the runner version.
21+
1722
## Tests
1823

1924
Vitest + jsdom, headless. Specs live in `test/autocomplete.test.js`. `test/setup.js` attaches a single jQuery instance to the jsdom `window` and `globalThis`, registers `jquery-mockjax` against it, silences mockjax's per-request console logging, then loads `src/jquery.autocomplete.js`. The plugin's UMD wrapper picks up `globalThis.jQuery` and registers `$.Autocomplete` plus `$.fn.autocomplete`/`$.fn.devbridgeAutocomplete` against that same instance.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
"scripts": {
1414
"build": "node scripts/build.mjs",
1515
"format": "prettier --write ./src ./test ./scripts/build.mjs",
16+
"format:check": "prettier --check ./src ./test ./scripts/build.mjs",
1617
"lint": "eslint ./src ./test ./scripts/build.mjs",
1718
"test": "vitest run",
1819
"test:watch": "vitest"
1920
},
21+
"engines": {
22+
"node": ">=20"
23+
},
2024
"repository": {
2125
"type": "git",
2226
"url": "git://github.com/devbridge/jQuery-Autocomplete.git"

0 commit comments

Comments
 (0)