-
Notifications
You must be signed in to change notification settings - Fork 100
491 lines (416 loc) · 16.4 KB
/
test_electron.yml
File metadata and controls
491 lines (416 loc) · 16.4 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
name: Test Electron Framework and Apps
on:
workflow_call:
push:
branches: ["main"]
paths:
- 'src/gaia/electron/**'
- 'src/gaia/apps/*/webui/**'
- 'src/gaia/agents/emr/dashboard/electron/**'
- 'tests/electron/**'
- '.github/workflows/test_electron.yml'
pull_request:
branches: ["main"]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'src/gaia/electron/**'
- 'src/gaia/apps/*/webui/**'
- 'src/gaia/agents/emr/dashboard/electron/**'
- 'tests/electron/**'
- '.github/workflows/test_electron.yml'
merge_group:
workflow_dispatch:
# Cancel in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
test-electron-framework:
name: Test Electron Framework
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: tests/electron/package.json
- name: Install test dependencies
run: |
cd tests/electron
npm ci
- name: Run Electron framework unit tests
run: |
cd tests/electron
npm test
- name: Upload test coverage
if: always()
uses: actions/upload-artifact@v6
with:
name: electron-framework-coverage
path: tests/electron/coverage/
retention-days: 7
test-apps-integration:
name: Test Apps Integration
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: tests/electron/package.json
- name: Install test dependencies
run: |
cd tests/electron
npm ci
- name: Run app integration tests
run: |
cd tests/electron
# Run structure tests for all apps and framework integration
npm test -- test_electron_jira_app.js test_electron_example_app.js test_electron_emr_dashboard.js test_electron_framework_integration.js
- name: Run Agent UI tests
run: |
cd tests/electron
# Agent UI service tests: process manager, notification service
# --forceExit needed because AgentProcessManager health-check intervals
# survive Jest teardown in mocked environments (tests pass correctly)
npm test -- test_agent_process_manager.js test_notification_service.js --forceExit
- name: Upload test results
if: always()
uses: actions/upload-artifact@v6
with:
name: apps-integration-test-results
path: tests/electron/coverage/
retention-days: 7
test-apps-functional:
name: Test Apps Functionality
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install test dependencies
run: |
cd tests/electron
npm ci
- name: Run functional tests (builds and installs apps)
run: |
cd tests/electron
# These tests actually install deps and try to build the apps
npm test -- test_electron_functional.js --verbose
timeout-minutes: 15
- name: Upload functional test results
if: always()
uses: actions/upload-artifact@v6
with:
name: apps-functional-test-results
path: tests/electron/coverage/
retention-days: 7
test-apps-build:
name: Test Apps Build (${{ matrix.app.name }})
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
strategy:
fail-fast: false
matrix:
app:
- name: jira
path: src/gaia/apps/jira/webui
has_package_script: true
- name: example
path: src/gaia/apps/example/webui
has_package_script: true
- name: emr-dashboard
path: src/gaia/agents/emr/dashboard/electron
has_package_script: false
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: ${{ matrix.app.path }}/package-lock.json
- name: Install app dependencies
run: |
cd ${{ matrix.app.path }}
npm ci --prefix .
- name: Check for high-severity vulnerabilities
run: |
cd ${{ matrix.app.path }}
# Allow command to fail but capture output
npm audit --json > audit-results.json || true
# Check for high/critical vulnerabilities
HIGH=$(cat audit-results.json | jq -r '.metadata.vulnerabilities.high // 0')
CRITICAL=$(cat audit-results.json | jq -r '.metadata.vulnerabilities.critical // 0')
echo "High severity vulnerabilities: $HIGH"
echo "Critical severity vulnerabilities: $CRITICAL"
if [ "$HIGH" -gt 0 ] || [ "$CRITICAL" -gt 0 ]; then
echo "::warning::Found $HIGH high and $CRITICAL critical vulnerabilities in ${{ matrix.app.name }}"
cat audit-results.json | jq '.vulnerabilities'
fi
continue-on-error: true
- name: Verify package scripts
run: |
cd ${{ matrix.app.path }}
npm run --if-present lint || echo "No lint script"
- name: Test app packaging (Linux)
if: matrix.app.has_package_script
run: |
cd ${{ matrix.app.path }}
# Package the app for Linux - validates dependencies work together
# Note: This runs on ubuntu-latest, so only Linux packaging is tested.
# Windows/macOS packaging is tested separately in build-electron-apps.yml
# BLOCKING: Packaging failures indicate broken dependencies from Dependabot updates
npm run package
env:
# Electron Forge will auto-detect Linux platform
DEBUG: electron-forge:*
- name: Verify build artifacts exist
if: matrix.app.has_package_script
run: |
cd ${{ matrix.app.path }}
if [ -d "out" ]; then
echo "✅ Build artifacts created successfully"
ls -R out/ | head -20
else
echo "❌ No build artifacts found - packaging failed"
echo "This indicates a dependency compatibility issue from the update."
exit 1
fi
- name: Validate Electron can be required (EMR Dashboard)
if: matrix.app.name == 'emr-dashboard'
run: |
cd ${{ matrix.app.path }}
# Verify Electron module can be loaded
node -e "require('electron'); console.log('✅ Electron module loads successfully')"
dependency-audit:
name: Audit Dependencies
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
strategy:
matrix:
package:
- name: electron-framework
path: src/gaia/electron
- name: jira-app
path: src/gaia/apps/jira/webui
- name: example-app
path: src/gaia/apps/example/webui
- name: emr-dashboard
path: src/gaia/agents/emr/dashboard/electron
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Audit ${{ matrix.package.name }} dependencies
run: |
cd ${{ matrix.package.path }}
npm audit --audit-level=high || true
npm audit --json > audit-results.json || true
continue-on-error: true
- name: Upload audit results
if: always()
uses: actions/upload-artifact@v6
with:
name: audit-${{ matrix.package.name }}
path: ${{ matrix.package.path }}/audit-results.json
retention-days: 30
# Headless E2E tests - actually launches Electron apps to catch runtime breakage
test-electron-runtime:
name: Test Electron Runtime (${{ matrix.app.name }})
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
app:
- name: jira
path: src/gaia/apps/jira/webui
- name: example
path: src/gaia/apps/example/webui
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: ${{ matrix.app.path }}/package-lock.json
- name: Install app dependencies
run: |
cd ${{ matrix.app.path }}
npm ci --prefix .
- name: Install xvfb for headless display
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- name: Test Electron app launches (headless)
run: |
cd ${{ matrix.app.path }}
# Start xvfb for headless display
export DISPLAY=:99
Xvfb :99 -screen 0 1024x768x24 &
sleep 2
# Create a test script in app directory so it can find electron in node_modules
cat > test-launch.js << 'EOF'
const { spawn } = require('child_process');
const path = require('path');
/**
* Electron App Launch Test
*
* This script launches an Electron app in headless mode and verifies
* it starts without crashing. Used to catch breaking changes from
* Dependabot dependency updates.
*
* Timeout Configuration:
* - ELECTRON_LAUNCH_TIMEOUT_MS: Time to wait for app initialization (default: 5000ms)
* - 5 seconds is sufficient for most GAIA apps which have minimal startup logic
* - Apps with heavy initialization (database, network) may need longer timeouts
* - The timeout only needs to be long enough to detect startup crashes
*/
const LAUNCH_TIMEOUT_MS = parseInt(process.env.ELECTRON_LAUNCH_TIMEOUT_MS || '5000', 10);
console.log('Starting Electron app launch test...');
console.log(`Launch timeout: ${LAUNCH_TIMEOUT_MS}ms`);
const electronPath = require('electron');
const appPath = process.cwd();
// Get the main entry point from package.json
const pkg = require(path.join(appPath, 'package.json'));
const mainFile = pkg.main || 'src/main.js';
console.log(`Launching: ${electronPath} ${mainFile}`);
const proc = spawn(electronPath, [mainFile], {
cwd: appPath,
env: {
...process.env,
ELECTRON_DISABLE_SANDBOX: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1',
GAIA_TEST_MODE: '1'
},
stdio: ['ignore', 'pipe', 'pipe']
});
let stdout = '';
let stderr = '';
let crashed = false;
proc.stdout.on('data', (data) => {
stdout += data.toString();
console.log('[stdout]', data.toString().trim());
});
proc.stderr.on('data', (data) => {
stderr += data.toString();
const msg = data.toString();
console.log('[stderr]', msg.trim());
// Check for crash indicators
if (msg.includes('crashed') || msg.includes('SIGSEGV') || msg.includes('SIGABRT')) {
crashed = true;
}
});
// Wait for app to initialize, then terminate
// This timeout is configurable via ELECTRON_LAUNCH_TIMEOUT_MS
setTimeout(() => {
if (!crashed) {
console.log('✅ App launched successfully without crashing');
proc.kill('SIGTERM');
process.exit(0);
} else {
console.log('❌ App crashed during startup');
proc.kill('SIGTERM');
process.exit(1);
}
}, LAUNCH_TIMEOUT_MS);
proc.on('error', (err) => {
console.log('❌ Failed to start Electron:', err.message);
process.exit(1);
});
proc.on('exit', (code, signal) => {
if (code !== null && code !== 0 && !signal) {
console.log(`❌ Electron exited with code ${code}`);
process.exit(1);
}
});
EOF
node test-launch.js
rm test-launch.js
timeout-minutes: 3
test-summary:
name: Test Summary
runs-on: ubuntu-latest
if: always()
needs: [test-electron-framework, test-apps-integration, test-apps-functional, test-apps-build, dependency-audit, test-electron-runtime]
steps:
- name: Check test results
run: |
echo "=========================================="
echo " ELECTRON TEST RESULTS "
echo "=========================================="
echo ""
echo "Test Electron Framework: ${{ needs.test-electron-framework.result }}"
echo "Test Apps Integration: ${{ needs.test-apps-integration.result }}"
echo "Test Apps Functionality: ${{ needs.test-apps-functional.result }}"
echo "Test Apps Build: ${{ needs.test-apps-build.result }}"
echo "Test Electron Runtime: ${{ needs.test-electron-runtime.result }}"
echo "Dependency Audit: ${{ needs.dependency-audit.result }}"
echo ""
FAILED=false
if [[ "${{ needs.test-electron-framework.result }}" == "failure" ]]; then
echo "❌ FAILED: Electron Framework tests"
FAILED=true
fi
if [[ "${{ needs.test-apps-integration.result }}" == "failure" ]]; then
echo "❌ FAILED: Apps Integration tests"
FAILED=true
fi
if [[ "${{ needs.test-apps-functional.result }}" == "failure" ]]; then
echo "❌ FAILED: Apps Functional tests"
FAILED=true
fi
if [[ "${{ needs.test-apps-build.result }}" == "failure" ]]; then
echo "❌ FAILED: Apps Build tests - dependencies may be broken"
FAILED=true
fi
if [[ "${{ needs.test-electron-runtime.result }}" == "failure" ]]; then
echo "❌ FAILED: Electron Runtime tests - apps crash on startup"
FAILED=true
fi
echo ""
if [[ "$FAILED" == "true" ]]; then
echo "=========================================="
echo " ❌ SOME ELECTRON TESTS FAILED "
echo "=========================================="
echo ""
echo "If this is a Dependabot PR, the dependency update"
echo "may have introduced breaking changes."
exit 1
else
echo "=========================================="
echo " ✅ ALL ELECTRON TESTS PASSED "
echo "=========================================="
fi