Skip to content

Commit e2034eb

Browse files
rushikeshmoreclaude
andcommitted
test: add grammar loader smoke test + CI workflow
- Smoke test loads all 27 grammars via parseSource(), catching missing packages, broken native builds, and incorrect require() paths. - CI matrix: Node 20/22/24 × ubuntu/macos. Runs tsc, tests, build, and a tarball install test (simulates npm install -g). - NODE_MODULE_VERSION mismatches (local Node upgrades) are skipped in tests — CI's fresh install matrix catches those instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 51587c5 commit e2034eb

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
node-version: [20, 22, 24]
15+
os: [ubuntu-latest, macos-latest]
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- run: npm install --legacy-peer-deps
22+
- run: npx tsc --noEmit
23+
- run: npm test
24+
- run: npm run build
25+
26+
install-test:
27+
runs-on: ${{ matrix.os }}
28+
needs: test
29+
strategy:
30+
matrix:
31+
node-version: [20, 22, 24]
32+
os: [ubuntu-latest, macos-latest]
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: ${{ matrix.node-version }}
38+
- run: npm install --legacy-peer-deps
39+
- run: npm pack
40+
- name: Install from tarball (simulates npm install -g)
41+
run: npm install -g ./codecortex-ai-*.tgz --legacy-peer-deps
42+
- name: Verify CLI works
43+
run: |
44+
codecortex --version
45+
codecortex --help

tests/extraction/parser.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,27 @@ describe('supportedLanguages', () => {
8181
})
8282
})
8383

84+
describe('grammar loader smoke test', () => {
85+
const langs = supportedLanguages()
86+
87+
it.each(langs)('%s grammar loads without error', (lang) => {
88+
// This catches: missing npm packages, broken native builds,
89+
// incorrect require() paths (e.g. .typescript, .php, .ocaml sub-exports)
90+
// NODE_MODULE_VERSION mismatches (stale rebuild after Node upgrade) are
91+
// skipped locally — they're caught by CI's fresh install matrix instead.
92+
try {
93+
parseSource('x', lang)
94+
} catch (e: unknown) {
95+
const msg = e instanceof Error ? e.message : String(e)
96+
if (msg.includes('NODE_MODULE_VERSION')) {
97+
// Stale native build from Node version switch — skip, CI catches this
98+
return
99+
}
100+
throw e
101+
}
102+
})
103+
})
104+
84105
describe('initParser', () => {
85106
it('is a no-op (native bindings need no async init)', async () => {
86107
await expect(initParser()).resolves.toBeUndefined()

0 commit comments

Comments
 (0)