forked from TryGhost/node-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (214 loc) · 8.33 KB
/
test-electron-package.yml
File metadata and controls
233 lines (214 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Test Electron package
on:
workflow_call:
inputs:
target_run_id:
description: 'The Run ID of the upstream CI workflow'
required: true
type: string
electron_version:
description: 'Electron version to test with'
required: false
default: '35'
type: string
node_version:
description: 'Node.js version for npm/setup'
required: false
default: '20'
type: string
workflow_dispatch:
inputs:
target_run_id:
description: 'The Run ID of the upstream CI workflow'
required: true
type: string
electron_version:
description: 'Electron version to test with'
required: false
default: '35'
type: string
node_version:
description: 'Node.js version for npm/setup'
required: false
default: '20'
type: string
permissions:
contents: read
jobs:
test-electron:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux-x64
- os: ubuntu-24.04-arm
platform: linux-arm64
- os: macos-latest
platform: macos-arm64
- os: windows-latest
platform: win32-x64
- os: windows-11-arm
platform: win32-arm64
runs-on: ${{ matrix.os }}
name: ${{ matrix.platform }} (electron=${{ inputs.electron_version || '35' }})
steps:
- name: Download artifact from specific run
uses: actions/download-artifact@v5
with:
run-id: ${{ inputs.target_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: npm-package-tarball
path: ./downloads
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node_version || '20' }}
- name: Install xvfb (Linux only)
if: runner.os == 'Linux'
run: sudo apt-get install -y xvfb
- name: Set Electron runner command
shell: bash
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
echo "ELECTRON_RUN=xvfb-run npx electron --no-sandbox" >> $GITHUB_ENV
else
echo "ELECTRON_RUN=npx electron --no-sandbox" >> $GITHUB_ENV
fi
- name: Install tarball and Electron
shell: bash
run: |
TARBALL="$(pwd)/downloads/$(ls downloads/*.tgz | head -1 | xargs basename)"
echo "Installing tarball: $TARBALL"
mkdir test-project && cd test-project
npm init -y
npm install "$TARBALL"
npm install --save-dev electron@${{ inputs.electron_version || '35' }}
echo "--- Installed package contents ---"
ls -la node_modules/@homeofthings/sqlite3/ 2>/dev/null || dir node_modules\\@homeofthings\\sqlite3\\ 2>/dev/null || true
echo "--- Prebuilds ---"
find node_modules/@homeofthings/sqlite3/prebuilds -name "*.node" -type f 2>/dev/null || true
- name: Smoke test - Electron callback API
shell: bash
timeout-minutes: 5
run: |
cd test-project
cat > test-callback.js << 'SCRIPT'
const { app } = require('electron');
const sqlite3 = require('@homeofthings/sqlite3');
function fail(err) { console.error('Callback API failed:', err); app.exit(1); }
app.whenReady().then(() => {
console.log('Electron version:', process.versions.electron);
console.log('sqlite3 version:', sqlite3.VERSION);
const db = new sqlite3.Database(':memory:');
db.serialize(() => {
db.run('CREATE TABLE test (id INT, name TEXT)');
db.run("INSERT INTO test VALUES (1, 'hello')");
db.get('SELECT * FROM test', (err, row) => {
if (err) return fail(err);
console.log('Callback API result:', JSON.stringify(row));
db.close((err) => { if (err) return fail(err); app.exit(0); });
});
});
}).catch(fail);
SCRIPT
$ELECTRON_RUN test-callback.js
- name: Smoke test - Electron promise API
shell: bash
timeout-minutes: 5
run: |
cd test-project
cat > test-promise.js << 'SCRIPT'
const { app } = require('electron');
const { SqliteDatabase } = require('@homeofthings/sqlite3/promise');
app.whenReady().then(() => {
return SqliteDatabase.open(':memory:');
}).then(db => {
return db.run('CREATE TABLE test (id INT, name TEXT)')
.then(() => db.run("INSERT INTO test VALUES (1, 'hello')"))
.then(() => db.get('SELECT * FROM test'))
.then(row => {
console.log('Promise API result:', JSON.stringify(row));
return db.close();
});
}).then(() => app.exit(0)).catch(err => {
console.error('Promise API failed:', err); app.exit(1);
});
SCRIPT
$ELECTRON_RUN test-promise.js
- name: Smoke test - Electron ESM default import
shell: bash
timeout-minutes: 5
run: |
cd test-project
cat > test-esm-default.js << 'SCRIPT'
const { app } = require('electron');
function fail(err) { console.error('ESM default import failed:', err); app.exit(1); }
app.whenReady().then(() => {
return import('@homeofthings/sqlite3');
}).then(sqlite3 => {
console.log('ESM default: sqlite3 version:', sqlite3.default.VERSION);
const db = new sqlite3.default.Database(':memory:');
db.serialize(() => {
db.run('CREATE TABLE test (id INT, name TEXT)');
db.run("INSERT INTO test VALUES (1, 'hello')");
db.get('SELECT * FROM test', (err, row) => {
if (err) return fail(err);
console.log('ESM default import result:', JSON.stringify(row));
db.close((err) => { if (err) return fail(err); app.exit(0); });
});
});
}).catch(fail);
SCRIPT
$ELECTRON_RUN test-esm-default.js
- name: Smoke test - Electron ESM named imports
shell: bash
timeout-minutes: 5
run: |
cd test-project
cat > test-esm-named.js << 'SCRIPT'
const { app } = require('electron');
function fail(err) { console.error('ESM named import failed:', err); app.exit(1); }
app.whenReady().then(() => {
return import('@homeofthings/sqlite3');
}).then(sqlite3 => {
const { Database, OPEN_READWRITE, OPEN_CREATE } = sqlite3;
console.log('ESM named: OPEN_READWRITE=', OPEN_READWRITE);
const db = new Database(':memory:');
db.serialize(() => {
db.run('CREATE TABLE test (id INT, name TEXT)');
db.run("INSERT INTO test VALUES (2, 'world')");
db.get('SELECT * FROM test', (err, row) => {
if (err) return fail(err);
console.log('ESM named import result:', JSON.stringify(row));
db.close((err) => { if (err) return fail(err); app.exit(0); });
});
});
}).catch(fail);
SCRIPT
$ELECTRON_RUN test-esm-named.js
- name: Smoke test - Electron ESM promise API
shell: bash
timeout-minutes: 5
run: |
cd test-project
cat > test-esm-promise.js << 'SCRIPT'
const { app } = require('electron');
app.whenReady().then(() => {
return import('@homeofthings/sqlite3/promise');
}).then(({ SqliteDatabase }) => {
return SqliteDatabase.open(':memory:')
.then(db => {
return db.run('CREATE TABLE test (id INT, name TEXT)')
.then(() => db.run("INSERT INTO test VALUES (3, 'esm')"))
.then(() => db.get('SELECT * FROM test'))
.then(row => {
console.log('ESM promise API result:', JSON.stringify(row));
return db.close();
});
});
}).then(() => app.exit(0)).catch(err => {
console.error('ESM promise API failed:', err); app.exit(1);
});
SCRIPT
$ELECTRON_RUN test-esm-promise.js