-
Notifications
You must be signed in to change notification settings - Fork 7
455 lines (382 loc) · 15.9 KB
/
Copy pathtest.yml
File metadata and controls
455 lines (382 loc) · 15.9 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
name: Test Suite
on:
push:
branches: [main, develop, 'feat/**', 'release/**', 'hotfix/**']
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
pull_request:
branches: [main, develop, 'release/**', 'hotfix/**']
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
workflow_dispatch:
permissions:
contents: read
env:
NODE_VERSION: '20'
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
# ─── Unit Tests (fast, every push) ───
unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: TypeScript check
run: npx tsc -b --noEmit packages/web
- name: Run unit tests
run: npm test
- name: Build web
run: npm run build
package-install-smoke:
name: Packaged Install Smoke (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Verify npm publish would succeed
shell: bash
run: |
OUTPUT=$(npm publish --dry-run 2>&1)
echo "$OUTPUT"
echo "$OUTPUT" | grep -q 'npm notice name:'
- name: Pack published tarball
id: pack
run: node tests/install/github-actions.mjs pack-output
- name: Install tarball globally
run: npm install -g "./${{ steps.pack.outputs.tarball }}"
- name: Locate installed CLI binary
id: binary
run: node tests/install/github-actions.mjs binary-output
- name: Smoke test packaged install
env:
CLAWMASTER_BINARY: ${{ steps.binary.outputs.path }}
run: node tests/install/package-install-smoke.mjs
- name: Wizard install smoke test
if: runner.os != 'Windows'
env:
CLAWMASTER_BINARY: ${{ steps.binary.outputs.path }}
run: node tests/install/wizard-install-smoke.mjs
# ─── Tauri Rust Check (fast type-check, no codegen) ───
tauri-check:
name: Tauri Cargo Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- uses: ./.github/actions/setup-rust
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install Linux system deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libayatana-appindicator3-dev \
libgtk-3-dev \
librsvg2-dev \
libssl-dev \
libwebkit2gtk-4.1-dev \
libxdo-dev
- run: npm ci
- name: Prepare Tauri resources and build web
run: npm run prepare:tauri-memory-plugin && npm run build
- name: Cargo check (type-check without codegen)
working-directory: src-tauri
run: cargo check --all-targets
# ─── Backend Integration Tests ───
backend:
name: Backend Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Start backend
run: |
npm run dev:backend &
sleep 3
- name: Health check
run: |
curl -sf http://localhost:16224/api/system/detect | head -c 200
echo ""
- name: Test API endpoints
run: |
set -e
echo "=== /api/system/detect ==="
curl -sf http://localhost:16224/api/system/detect | python3 -m json.tool | head -20
echo "=== /api/config ==="
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:16224/api/config)
echo "Config endpoint: HTTP $HTTP_CODE"
echo "=== /api/gateway/status ==="
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:16224/api/gateway/status)
echo "Gateway status: HTTP $HTTP_CODE"
echo "=== /api/logs ==="
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:16224/api/logs)
echo "Logs endpoint: HTTP $HTTP_CODE"
echo "=== /api/storage/status ==="
curl -sf http://localhost:16224/api/storage/status | python3 -m json.tool
echo "All backend endpoints responding"
backend-windows:
name: Backend Unit Tests (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Run backend tests
run: npm test --workspace=@openclaw-manager/backend
- name: Build backend
run: npm run build --workspace=@openclaw-manager/backend
- name: Start built backend smoke check
shell: pwsh
run: |
$log = Join-Path $env:RUNNER_TEMP 'backend-native.log'
$err = Join-Path $env:RUNNER_TEMP 'backend-native.err.log'
$proc = Start-Process node `
-ArgumentList 'packages/backend/dist/index.js' `
-RedirectStandardOutput $log `
-RedirectStandardError $err `
-PassThru
try {
Start-Sleep -Seconds 5
$response = Invoke-RestMethod -Uri 'http://127.0.0.1:16224/api/system/detect'
if (-not $response.runtime) {
throw 'Missing runtime information from backend detect endpoint'
}
} finally {
if ($proc -and -not $proc.HasExited) {
Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue
}
if (Test-Path $log) {
Get-Content $log
}
if (Test-Path $err) {
Get-Content $err
}
}
# ─── Ollama Integration Tests ───
ollama:
name: Ollama Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Install Ollama
run: |
curl -fsSL https://ollama.com/install.sh | sh
echo "Ollama installed: $(ollama --version)"
- name: Start Ollama server
run: |
ollama serve &
sleep 3
# Verify server is running
curl -sf http://localhost:11434/api/tags | head -c 100
echo ""
echo "Ollama server running"
- name: Pull a small test model
run: |
# Pull smallest available model for CI speed
ollama pull tinyllama:latest
echo "Model pulled successfully"
timeout-minutes: 5
- name: Verify model is available
run: |
ollama list
echo "---"
# Verify via API
curl -sf http://localhost:11434/api/tags | python3 -m json.tool
- name: Test model inference
run: |
# Quick inference test
RESPONSE=$(curl -sf http://localhost:11434/api/generate -d '{
"model": "tinyllama:latest",
"prompt": "Say hello in one word.",
"stream": false
}' | python3 -c "import sys,json; print(json.load(sys.stdin).get('response','')[:100])")
echo "Model response: $RESPONSE"
[ -n "$RESPONSE" ] && echo "PASS: Model inference works" || { echo "FAIL: Empty response"; exit 1; }
timeout-minutes: 2
- name: Start backend with Ollama
run: |
npm run dev:backend &
sleep 3
- name: Test Ollama adapter via backend
run: |
set -e
echo "=== Detect Ollama ==="
curl -sf http://localhost:16224/api/exec -X POST \
-H 'Content-Type: application/json' \
-d '{"cmd":"ollama","args":["--version"]}' | python3 -m json.tool
echo "=== List models ==="
curl -sf http://localhost:16224/api/exec -X POST \
-H 'Content-Type: application/json' \
-d '{"cmd":"ollama","args":["list"]}' | python3 -m json.tool
echo "=== Ollama API tags ==="
curl -sf http://localhost:11434/api/tags | python3 -c "
import sys, json
data = json.load(sys.stdin)
models = data.get('models', [])
print(f'Models available: {len(models)}')
for m in models:
print(f' - {m[\"name\"]} ({m.get(\"size\",0)//1024//1024}MB)')
assert len(models) > 0, 'No models found'
print('PASS: Ollama integration verified')
"
- name: Run Ollama unit tests
run: npm test -- --reporter=verbose 2>&1 | grep -E "(PASS|FAIL|ollama)" || true
# ─── E2E Smoke Tests (Playwright) ───
e2e:
name: E2E Smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- run: npm ci
- name: Install Playwright
run: |
npm install --no-save playwright
npx playwright install chromium
- name: Start dev servers
run: |
npm run dev:web &
sleep 5
curl -sf http://localhost:16223/ > /dev/null
curl -sf http://localhost:16224/api/system/detect > /dev/null
echo "Both servers running"
- name: Smoke test — all 15 pages render
run: |
cat << 'SCRIPT' > _smoke.mjs
import { chromium } from 'playwright';
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
const paths = ['/', '/gateway', '/observe', '/mcp', '/channels', '/memory',
'/sessions', '/models', '/skills', '/agents', '/plugins',
'/config', '/docs', '/logs', '/settings'];
let pass = 0, fail = 0;
for (const p of paths) {
const name = p === '/' ? 'dashboard' : p.slice(1);
try {
await page.goto('http://localhost:16223' + p + '?demo=skip', { waitUntil: 'domcontentloaded', timeout: 15000 });
await page.waitForTimeout(3000);
const len = await page.evaluate(() => document.body.innerText.trim().length);
if (len > 50) { console.log('PASS ' + name); pass++; }
else { console.log('FAIL ' + name + ' (blank)'); fail++; }
} catch (e) { console.log('FAIL ' + name + ' — ' + e.message.slice(0, 60)); fail++; }
}
console.log(pass + '/' + (pass + fail) + ' pages rendered');
await browser.close();
process.exit(fail > 0 ? 1 : 0);
SCRIPT
node _smoke.mjs
- name: Wizard E2E — demo install flow
run: |
cat << 'SCRIPT' > _wizard_e2e.mjs
import { chromium } from 'playwright';
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
const BASE = 'http://localhost:16223';
let step = 0;
const ok = (msg) => console.log(`PASS [${++step}] ${msg}`);
const bail = (msg) => { console.error(`FAIL [${step + 1}] ${msg}`); process.exit(1); };
// Step 1: Navigate to wizard in demo mode
await page.goto(`${BASE}?demo=install`, { waitUntil: 'domcontentloaded', timeout: 15000 });
ok('Wizard loaded');
// Step 2: Wait for detection phase to complete → should auto-advance to provider step
await page.waitForSelector('text=配置 LLM 提供商', { timeout: 15000 })
.catch(() => page.waitForSelector('text=Configure LLM Provider', { timeout: 5000 }));
ok('Provider step rendered');
// Step 3: Gold sponsor (Wenxin) should be visible
const wenxin = await page.locator('text=文心大模型').or(page.locator('text=ERNIE')).first();
await wenxin.waitFor({ timeout: 5000 });
ok('Gold sponsor provider visible');
// Step 4: Select a tier-2 featured provider (DeepSeek). Anchored
// regex avoids accidentally matching "Custom (OpenAI Compatible)"
// in tier 3 when a looser selector like `text=OpenAI` would.
await page.locator('text=/^DeepSeek$/').first().click();
ok('DeepSeek selected');
// Step 5: API Key input should appear
const keyInput = page.locator('input[type="password"]');
await keyInput.waitFor({ timeout: 5000 });
ok('API Key input visible');
// Step 6: Enter a test key and validate
await keyInput.fill('sk-demo-test-key');
const validateBtn = page.locator('text=验证并继续').or(page.locator('text=Validate'));
await validateBtn.first().click();
ok('Validate clicked');
// Step 7: Model picker should appear after demo validation
const modelPicker = page.locator('text=选择默认模型').or(page.locator('text=Select Default Model'));
await modelPicker.first().waitFor({ timeout: 10000 });
ok('Model picker rendered');
// Step 8: Advance from model selection into the required gateway step
const nextBtn = page.locator('text=下一步').or(page.locator('text=Next'));
await nextBtn.first().waitFor({ timeout: 5000 });
await nextBtn.first().click();
ok('Advanced to gateway step');
// Step 9: Gateway step should be visible with a final enter action
const gatewayStep = page.locator('text=网关').or(page.locator('text=Gateway'));
await gatewayStep.first().waitFor({ timeout: 5000 });
const enterBtn = page.locator('text=进入管理大师').or(page.locator('text=Enter ClawMaster'));
await enterBtn.first().waitFor({ timeout: 5000 });
ok('Gateway step rendered');
// Step 10: Click enter → circle reveal animation → main app
await enterBtn.first().click();
await page.waitForTimeout(2000);
const mainVisible = await page.locator('.app-layout, [class*="Layout"], nav').first()
.isVisible().catch(() => false);
if (!mainVisible) bail('Main app layout not visible after circle reveal');
ok('Circle reveal → main app rendered');
// Step 11: Test skip flow
await page.goto(`${BASE}?demo=install`, { waitUntil: 'domcontentloaded', timeout: 15000 });
await page.waitForSelector('text=配置 LLM 提供商', { timeout: 15000 })
.catch(() => page.waitForSelector('text=Configure LLM Provider', { timeout: 5000 }));
const skipLink = page.locator('text=跳过剩余步骤').or(page.locator('text=Skip'));
await skipLink.first().click();
const skipGatewayStep = page.getByRole('heading', { name: /^(网关|Gateway|ゲートウェイ)$/ });
await skipGatewayStep.waitFor({ timeout: 5000 });
// Skip only needs to prove the wizard lands on the mandatory gateway step
// instead of the optional channel steps. The gateway status check is
// asynchronous, so button visibility is intentionally not asserted here.
ok('Skip flow reached mandatory gateway step');
console.log(`\nAll ${step} wizard E2E checks passed`);
await browser.close();
SCRIPT
node _wizard_e2e.mjs
- name: Run YAML UI tests (CI-safe suites)
run: node tests/ui/runner.mjs --suites 06,10,16,18