Skip to content

Commit 3343dea

Browse files
committed
feat: add code quality checks with clang-tidy and memory tests in CI workflow
1 parent 8140417 commit 3343dea

File tree

7 files changed

+610
-8
lines changed

7 files changed

+610
-8
lines changed

.github/workflows/code-quality.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
clang-tidy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: "npm"
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y clang-tidy
24+
25+
- name: Install Node dependencies
26+
run: npm ci
27+
28+
- name: Build project
29+
run: npm run build
30+
31+
- name: Run clang-tidy
32+
run: npm run clang-tidy
33+
34+
memory-tests-basic:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
cache: "npm"
43+
44+
- name: Install dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y valgrind
48+
49+
- name: Install Node dependencies
50+
run: npm ci
51+
52+
- name: Build project
53+
run: npm run build
54+
55+
- name: Run JavaScript memory tests
56+
run: npm run test:memory
57+
58+
- name: Run valgrind tests
59+
run: bash scripts/valgrind.sh

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@photostructure/sqlite",
33
"version": "0.1.0",
4-
"description": "Drop-in replacement for node:sqlite - Node.js SQLite implementation extracted from Node.js core",
4+
"description": "Drop-in replacement for node:sqlite",
55
"homepage": "https://github.com/photostructure/node-sqlite",
66
"types": "./dist/index.d.ts",
77
"main": "./dist/index.js",
@@ -17,21 +17,27 @@
1717
"clean": "run-p clean:*",
1818
"clean:dist": "del-cli dist \"*.tsbuildinfo\"",
1919
"clean:gyp": "node-gyp clean",
20-
"sync": "node scripts/sync-from-node.js",
20+
"sync": "node scripts/sync-from-node.mjs",
2121
"node-gyp-rebuild": "node-gyp rebuild",
2222
"prebuild": "prebuildify --napi --tag-libc --strip",
2323
"compile": "tsc --noEmit",
2424
"bundle": "tsup src/index.ts --format cjs,esm --dts",
2525
"test": "jest",
2626
"test:unit": "jest --testPathPattern=src/",
2727
"test:integration": "jest --testPathPattern=test/",
28+
"test:memory": "cross-env TEST_MEMORY=1 node --expose-gc node_modules/jest/bin/jest.js --no-coverage test/memory.test.ts",
29+
"tests:memory": "node scripts/check-memory.mjs",
30+
"asan": "cross-env ENABLE_ASAN=1 node scripts/check-memory.mjs",
31+
"clang-tidy": "node scripts/clang-tidy.mjs",
32+
"precommit:quality": "node -e \"if(process.platform==='linux'||process.platform==='darwin')process.exit(1)\" || npm run clang-tidy",
33+
"precommit:memory": "node -e \"if(process.platform!=='linux')process.exit(1)\" && npm run test:memory || echo 'Skipping memory tests (Linux only)'",
2834
"lint": "run-s lint:*",
2935
"lint:eslint": "eslint src/ test/",
3036
"lint:api": "tsc --noEmit src/api-compatibility.test.ts",
3137
"lint:fix": "eslint --fix src/ test/",
3238
"fmt": "prettier --write \"**/*.{ts,js,json,md}\"",
3339
"build": "run-s compile bundle",
34-
"precommit": "run-s fmt lint build test",
40+
"precommit": "node scripts/precommit.mjs",
3541
"prepare-release": "npm run build",
3642
"release": "release-it"
3743
},
@@ -71,7 +77,7 @@
7177
"devDependencies": {
7278
"@eslint/js": "^9.27.0",
7379
"@types/jest": "^29.5.14",
74-
"@types/node": "^22.15.24",
80+
"@types/node": "^22.15.26",
7581
"@typescript-eslint/eslint-plugin": "^8.33.0",
7682
"@typescript-eslint/parser": "^8.33.0",
7783
"cross-env": "^7.0.3",

0 commit comments

Comments
 (0)