1+ name : Test npm package
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ target_run_id :
6+ description : ' The Run ID of the upstream CI workflow'
7+ required : true
8+ type : string
9+ node_version :
10+ description : ' Node.js version to test with'
11+ required : false
12+ default : ' 20'
13+ type : string
14+
15+ permissions :
16+ contents : read
17+
18+ jobs :
19+ test-artifact :
20+ strategy :
21+ fail-fast : false
22+ matrix :
23+ include :
24+ - os : ubuntu-latest
25+ platform : linux-x64
26+ - os : ubuntu-24.04-arm
27+ platform : linux-arm64
28+ - os : macos-latest
29+ platform : macos-arm64
30+ - os : windows-latest
31+ platform : win32-x64
32+ runs-on : ${{ matrix.os }}
33+ name : ${{ matrix.platform }}
34+ steps :
35+ - name : Download artifact from specific run
36+ uses : actions/download-artifact@v5
37+ with :
38+ run-id : ${{ github.event.inputs.target_run_id }}
39+ github-token : ${{ secrets.GITHUB_TOKEN }}
40+ name : npm-package-tarball
41+ path : ./downloads
42+
43+ - name : Set up Node.js
44+ uses : actions/setup-node@v6
45+ with :
46+ node-version : ${{ github.event.inputs.node_version || '20' }}
47+
48+ - name : Install tarball and verify
49+ shell : bash
50+ run : |
51+ TARBALL=$(ls ./downloads/*.tgz | head -1)
52+ echo "Installing tarball: $TARBALL"
53+ mkdir test-project && cd test-project
54+ npm init -y
55+ npm install "$TARBALL"
56+ echo "--- Installed package contents ---"
57+ ls -la node_modules/@homeofthings/sqlite3/ 2>/dev/null || dir node_modules\\@homeofthings\\sqlite3\\ 2>/dev/null || true
58+ echo "--- Prebuilds ---"
59+ find node_modules/@homeofthings/sqlite3/prebuilds -name "*.node" -type f 2>/dev/null || true
60+
61+ - name : Smoke test - callback API
62+ shell : bash
63+ run : |
64+ cd test-project
65+ node -e "
66+ const sqlite3 = require('@homeofthings/sqlite3');
67+ console.log('sqlite3 version:', sqlite3.VERSION);
68+ const db = new sqlite3.Database(':memory:');
69+ db.serialize(() => {
70+ db.run('CREATE TABLE test (id INT, name TEXT)');
71+ db.run('INSERT INTO test VALUES (1, \"hello\")');
72+ db.get('SELECT * FROM test', (err, row) => {
73+ if (err) { console.error('Query failed:', err); process.exit(1); }
74+ console.log('Callback API result:', JSON.stringify(row));
75+ db.close();
76+ });
77+ });
78+ "
79+
80+ - name : Smoke test - promise API
81+ shell : bash
82+ run : |
83+ cd test-project
84+ node -e "
85+ const sqlite3 = require('@homeofthings/sqlite3');
86+ const { SqliteDatabase } = sqlite3;
87+ async function main() {
88+ const db = await SqliteDatabase.open(':memory:');
89+ await db.run('CREATE TABLE test (id INT, name TEXT)');
90+ await db.run('INSERT INTO test VALUES (1, \"hello\")');
91+ const row = await db.get('SELECT * FROM test');
92+ console.log('Promise API result:', JSON.stringify(row));
93+ await db.close();
94+ }
95+ main().catch(err => { console.error(err); process.exit(1); });
96+ "
0 commit comments