Skip to content

Commit e1fb04d

Browse files
author
echoVic
committed
ci: 重构 CI 工作流并添加核心回归测试
- 将测试工作流拆分为质量门和核心回归测试门 - 添加 headless 核心回归测试套件 - 优化 CI 配置和脚本执行方式 - 扩展测试覆盖范围包括 web 端测试 - 改进 Bun 运行时检查和错误处理
1 parent 0ae38b7 commit e1fb04d

10 files changed

Lines changed: 308 additions & 215 deletions

File tree

.github/workflows/ci.yml

Lines changed: 215 additions & 201 deletions
Large diffs are not rendered by default.

biome.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"files": {
55
"ignoreUnknown": false,
66
"includes": [
7-
"packages/*/src/**/*",
8-
"packages/*/tests/**/*",
7+
"packages/**/src/**/*",
8+
"packages/**/tests/**/*",
9+
"packages/**/vitest.config.ts",
910
"*.ts",
1011
"*.tsx",
1112
"*.js",
@@ -89,6 +90,19 @@
8990
}
9091
}
9192
},
93+
"css": {
94+
"parser": {
95+
"cssModules": false,
96+
"allowWrongLineComments": false,
97+
"tailwindDirectives": true
98+
},
99+
"linter": {
100+
"enabled": true
101+
},
102+
"formatter": {
103+
"enabled": true
104+
}
105+
},
92106
"javascript": {
93107
"formatter": {
94108
"quoteStyle": "single",
@@ -110,10 +124,10 @@
110124
"overrides": [
111125
{
112126
"includes": [
113-
"packages/*/tests/**/*",
127+
"packages/**/tests/**/*",
114128
"**/*.test.ts",
115129
"**/*.spec.ts",
116-
"packages/*/src/**/*test*"
130+
"packages/**/src/**/*test*"
117131
],
118132
"linter": {
119133
"rules": {

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@
88
"dev": "pnpm -r --parallel dev",
99
"dev:cli": "pnpm --filter blade-code dev",
1010
"dev:web": "pnpm --filter blade-code dev:serve & VITE_API_TARGET=http://localhost:4097 pnpm -C packages/cli/web dev",
11-
"build": "pnpm -r build",
11+
"build": "pnpm build:cli && pnpm build:vscode",
1212
"build:cli": "pnpm --filter blade-code build",
1313
"build:vscode": "pnpm --filter blade-vscode build",
1414
"test": "pnpm --filter blade-code test",
1515
"test:all": "pnpm --filter blade-code test:all",
1616
"test:unit": "pnpm --filter blade-code test:unit",
1717
"test:integration": "pnpm --filter blade-code test:integration",
1818
"test:cli": "pnpm --filter blade-code test:cli",
19+
"test:web": "pnpm --filter blade-web test",
20+
"test:headless-core": "pnpm --filter blade-code test:headless-core",
1921
"test:coverage": "pnpm --filter blade-code test:coverage",
2022
"test:watch": "pnpm --filter blade-code test:watch",
2123
"lint": "pnpm -r lint",
24+
"lint:web": "pnpm --filter blade-web lint",
2225
"lint:fix": "pnpm -r lint:fix",
2326
"format": "biome format --write packages",
2427
"format:check": "biome format packages",
2528
"check": "biome check packages",
2629
"check:fix": "biome check --write packages",
2730
"type-check": "pnpm -r type-check",
31+
"type-check:web": "pnpm --filter blade-web type-check",
2832
"clean": "pnpm -r exec rm -rf dist node_modules/.cache coverage",
2933
"clean:all": "rm -rf node_modules packages/*/node_modules pnpm-lock.yaml",
3034
"preflight": "pnpm clean && pnpm install && pnpm format && pnpm lint && pnpm build && pnpm type-check && pnpm test:all",
@@ -60,5 +64,6 @@
6064
"@biomejs/biome": "^2.2.4",
6165
"knip": "^5.80.0",
6266
"typescript": "^5.9.2"
63-
}
67+
},
68+
"packageManager": "pnpm@10.5.2+sha512.da9dc28cd3ff40d0592188235ab25d3202add8a207afbedc682220e4a0029ffbff4562102b9e6e46b4e3f9e8bd53e6d05de48544b0c57d4b0179e22c76d1199b"
6469
}

packages/cli/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
"README.md"
1414
],
1515
"scripts": {
16-
"dev": "bun --watch src/blade.tsx",
17-
"dev:serve": "bun --watch src/blade.tsx serve --port 4097",
18-
"build": "rm -rf dist && bun run scripts/build.ts",
19-
"start": "bun run dist/blade.js",
16+
"dev": "node scripts/run-bun.js --watch src/blade.tsx",
17+
"dev:serve": "node scripts/run-bun.js --watch src/blade.tsx serve --port 4097",
18+
"build": "rm -rf dist && node scripts/run-bun.js run scripts/build.ts",
19+
"start": "node scripts/run-bun.js run dist/blade.js",
2020
"test": "node scripts/test.js",
2121
"test:all": "vitest run --config vitest.config.ts",
2222
"test:unit": "node scripts/test.js unit",
2323
"test:integration": "node scripts/test.js integration",
2424
"test:cli": "node scripts/test.js cli",
25+
"test:headless-core": "node scripts/test.js headlessCore",
2526
"test:e2e": "node scripts/test.js e2e",
2627
"test:performance": "node scripts/test.js performance",
2728
"test:snapshot": "node scripts/test.js snapshot",

packages/cli/scripts/run-bun.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env node
2+
3+
import { spawn, spawnSync } from 'node:child_process';
4+
5+
const args = process.argv.slice(2);
6+
7+
const check = spawnSync('bun', ['--version'], {
8+
stdio: 'ignore',
9+
shell: process.platform === 'win32',
10+
});
11+
12+
if (check.status !== 0) {
13+
console.error('Bun is required to run this command, but it is not available on PATH.');
14+
console.error('Install Bun from https://bun.sh or ensure setup-bun runs before this step.');
15+
process.exit(check.status ?? 1);
16+
}
17+
18+
const child = spawn('bun', args, {
19+
stdio: 'inherit',
20+
shell: process.platform === 'win32',
21+
});
22+
23+
child.on('exit', (code, signal) => {
24+
if (signal) {
25+
process.kill(process.pid, signal);
26+
return;
27+
}
28+
29+
process.exit(code ?? 0);
30+
});
31+
32+
child.on('error', (error) => {
33+
console.error('Failed to start Bun:', error.message);
34+
process.exit(1);
35+
});

packages/cli/scripts/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ const testTypes = {
2323
project: 'cli',
2424
timeout: 60000,
2525
},
26+
headlessCore: {
27+
name: 'Headless 核心回归测试',
28+
project: null,
29+
timeout: 120000,
30+
files: [
31+
'tests/unit/cli/headless.test.ts',
32+
'tests/unit/cli/headless-events.test.ts',
33+
'tests/integration/cli/blade-help.test.ts',
34+
'tests/unit/agent-runtime/agent/session-runtime.test.ts',
35+
'tests/unit/agent-runtime/agent/subagent-registry.test.ts',
36+
'tests/unit/agent-runtime/server/session-routes.test.ts',
37+
'tests/unit/agent-runtime/acp/session.test.ts',
38+
],
39+
},
2640
e2e: {
2741
name: 'E2E 测试',
2842
project: 'e2e',
@@ -61,6 +75,7 @@ function printUsage() {
6175
unit 运行单元测试
6276
integration 运行集成测试
6377
cli 运行 CLI 行为测试
78+
headlessCore 运行 headless 与核心 runtime 回归测试
6479
e2e 运行端到端测试
6580
performance 运行性能测试
6681
snapshot 运行快照测试
@@ -113,6 +128,10 @@ function runTest(testType, options = {}) {
113128
baseArgs.push('--project', config.project);
114129
}
115130

131+
if (config.files) {
132+
baseArgs.push(...config.files.map(f => path.resolve(__dirname, '..', f)));
133+
}
134+
116135
if (options.coverage) {
117136
baseArgs.push('--coverage');
118137
}

packages/cli/web/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "vite build",
8-
"preview": "vite preview"
8+
"preview": "vite preview",
9+
"test": "pnpm -C .. exec vitest run --config web/vitest.config.ts",
10+
"type-check": "tsc --noEmit -p tsconfig.json",
11+
"lint": "pnpm -C .. exec biome lint web/src web/tests web/vitest.config.ts"
912
},
1013
"dependencies": {
1114
"@fontsource/jetbrains-mono": "^5.2.8",

packages/cli/web/src/components/chat/ChatMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ function ConfirmationSection({ confirmation, messageId }: { confirmation: AgentR
324324
...confirmation,
325325
status: approved ? 'approved' : 'denied',
326326
})
327-
} catch (error) {
327+
} catch (_error) {
328328
setConfirmation(messageId, {
329329
...confirmation,
330330
status: approved ? 'approved' : 'denied',

packages/cli/web/src/store/session/handlers/eventHandlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ const handleThinkingDelta: EventHandler = (props, get) => {
158158
appendThinking(currentAssistantMessageId, props.delta as string)
159159
}
160160

161-
const handleThinkingCompleted: EventHandler = () => {}
161+
const handleThinkingCompleted: EventHandler = () => {
162+
// Thinking deltas are applied incrementally, so completion is a no-op here.
163+
}
162164

163165
const handleToolStart: EventHandler = (props, get, set) => {
164166
const { currentSessionId, appendToolCall, setHasToolCalls, setSubagent } = get()

packages/cli/web/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
},
2323
"types": ["node"]
2424
},
25-
"include": ["src"],
25+
"include": ["src", "tests", "vitest.config.ts"],
2626
"references": [{ "path": "./tsconfig.node.json" }]
2727
}

0 commit comments

Comments
 (0)