Merge branch 'master' into opt/win-ssache
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 3m50s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 3m33s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m0s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m13s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 4m15s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 4m25s
Project CI / Frontend tests (pull_request) Successful in 3m59s
Project CI / Repository checks (pull_request) Successful in 3m18s
Project CI / Native shell tests (pull_request) Successful in 6m14s
Project CI / Backend tests (pull_request) Successful in 7m6s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m57s

This commit is contained in:
2026-09-14 17:38:17 +08:00
9 changed files with 354 additions and 90 deletions
+57 -13
View File
@@ -87,16 +87,22 @@ const aiGameCreatorViteConfigSource = fs.readFileSync(
// - agc-webAI 游戏创作壳的前端门禁(typecheck 与壳内测试,不触碰 Cargo)。
// - agc-rust-cratesAGC 壳依赖的共享 / 平台 crate 测试(server-rs workspace 加两个
// 无锁独立 crate),只需 server-rs 侧的依赖预热。
// - agc-rust-shellAGC 壳自身的 Rust 门禁(bin target 单测按名单分片并行、片内保持
// `--test-threads=1`)与会用 `src-tauri/Cargo.toml` spawn `cargo run` 的 agent-run
// smoke,只需 AGC 壳自己的依赖预热
// - agc-rust-shard-1..4AGC 壳自身的 Rust bin target 单测按名单切成 4 片,一片一个
// 分组(CI 里就是一个 job),片内仍保持 `--test-threads=1`;每个分片分组都会做一次
// 「片并集等于全集且互斥」的自校验
// - agc-rust-smoke:会用 `src-tauri/Cargo.toml` spawn `cargo run` 的 agent-run smoke。
// 与分片分开,免得把已经压到 4 分钟级的片 job 拖长。
// - release:发布构建 smoke 和依赖发布产物的落盘断言。
const nativeShellGateGroups = [
'contract',
'shells',
'agc-web',
'agc-rust-crates',
'agc-rust-shell',
'agc-rust-shard-1',
'agc-rust-shard-2',
'agc-rust-shard-3',
'agc-rust-shard-4',
'agc-rust-smoke',
'release',
];
const requestedNativeShellGroups = readRequestedNativeShellGroups(
@@ -2314,9 +2320,9 @@ const steps = [
},
// AI 游戏创作壳原先一步串完 typecheck、壳内测试、共享 / 平台 crate 测试和
// 串行壳测试,CI 因此只有一条 10 分钟以上的长尾。这里按同一组命令切成
// web、rust-crates、rust-shell 三段,顺序与 `npm run ai-game-creator-shell:check`
// 完全一致,但允许 CI 把三段放进不同 job 并行执行本地全量运行仍然是
// web -> rust(crates -> shell) -> smoke 原顺序。
// web、rust-crates、rust 分片、smoke 四段,整体顺序与 `npm run ai-game-creator-shell:check`
// 完全一致;CI 把每段(以及每个 rust 分片)放进不同 job 并行执行本地全量运行仍然是
// web -> rust(crates -> shards) -> smoke 原顺序。
{
group: 'agc-web',
label: 'ai-game-creator-shell-check-web',
@@ -2330,15 +2336,53 @@ const steps = [
args: ['run', 'ai-game-creator-shell:check:rust:crates'],
},
{
group: 'agc-rust-shell',
label: 'ai-game-creator-shell-check-rust-shell',
group: 'agc-rust-shard-1',
label: 'ai-game-creator-shell-check-rust-shard-1',
command: npmCommand,
args: ['run', 'ai-game-creator-shell:check:rust:shell'],
args: [
'run',
'ai-game-creator-shell:check:rust:shell',
'--',
'--shard-index=1',
],
},
// agent-run smoke 会用 `src-tauri/Cargo.toml` spawn `cargo run`,因此与壳测试同组,
// 保证它落在已经预热 AGC 壳 Cargo 依赖的 job 里。
{
group: 'agc-rust-shell',
group: 'agc-rust-shard-2',
label: 'ai-game-creator-shell-check-rust-shard-2',
command: npmCommand,
args: [
'run',
'ai-game-creator-shell:check:rust:shell',
'--',
'--shard-index=2',
],
},
{
group: 'agc-rust-shard-3',
label: 'ai-game-creator-shell-check-rust-shard-3',
command: npmCommand,
args: [
'run',
'ai-game-creator-shell:check:rust:shell',
'--',
'--shard-index=3',
],
},
{
group: 'agc-rust-shard-4',
label: 'ai-game-creator-shell-check-rust-shard-4',
command: npmCommand,
args: [
'run',
'ai-game-creator-shell:check:rust:shell',
'--',
'--shard-index=4',
],
},
// agent-run smoke 会用 `src-tauri/Cargo.toml` spawn `cargo run`,因此单独一个分组,
// 落在同样预热了 AGC 壳 Cargo 依赖的 job 里。
{
group: 'agc-rust-smoke',
label: 'ai-game-creator-shell-agent-run-smoke',
command: npmCommand,
args: ['run', 'ai-game-creator-shell:agent-run:smoke'],
+57 -16
View File
@@ -41,16 +41,24 @@ const jobNames = [
'backend-tests',
'native-shell-tests',
'ai-game-creator-shell-web-tests',
'ai-game-creator-shell-rust-tests',
'ai-game-creator-shell-rust-shard-1',
'ai-game-creator-shell-rust-shard-2',
'ai-game-creator-shell-rust-shard-3',
'ai-game-creator-shell-rust-shard-4',
'ai-game-creator-shell-rust-smoke',
'ai-game-creator-shell-rust-crates',
] as const;
// 这个 job 是纯 cargo 门禁:AGC 壳的 Rust 套件与 agent-run smoke 只用 cargo 与
// 这个 job 是纯 cargo 门禁:AGC 壳的 Rust 分片与 agent-run smoke 只用 cargo 与
// node 内建模块(smoke 脚本只 import `node:*`),crate 级测试只跑 cargo 命令,
// 都不需要 node_modules。省掉两份 `npm ci`(各 1~3 分钟)是把客户端 Rust 关键路径
// 都不需要 node_modules。省掉这些 `npm ci`(各 1~3 分钟)是把客户端 Rust 关键路径
// 压到 7 分钟以内的前提,因此这里显式允许它们不装 npm 依赖。
const jobsWithoutNpmInstall: readonly string[] = [
'ai-game-creator-shell-rust-tests',
'ai-game-creator-shell-rust-shard-1',
'ai-game-creator-shell-rust-shard-2',
'ai-game-creator-shell-rust-shard-3',
'ai-game-creator-shell-rust-shard-4',
'ai-game-creator-shell-rust-smoke',
'ai-game-creator-shell-rust-crates',
];
@@ -69,7 +77,11 @@ const nativeShellGateGroupScripts = {
shells: 'npm run check:native-shells:shells',
'agc-web': 'npm run check:native-shells:agc-web',
'agc-rust-crates': 'npm run check:native-shells:agc-rust-crates',
'agc-rust-shell': 'npm run check:native-shells:agc-rust-shell',
'agc-rust-shard-1': 'npm run check:native-shells:agc-rust-shard-1',
'agc-rust-shard-2': 'npm run check:native-shells:agc-rust-shard-2',
'agc-rust-shard-3': 'npm run check:native-shells:agc-rust-shard-3',
'agc-rust-shard-4': 'npm run check:native-shells:agc-rust-shard-4',
'agc-rust-smoke': 'npm run check:native-shells:agc-rust-smoke',
release: 'npm run check:native-shells:release',
} as const;
@@ -391,7 +403,7 @@ describe('project CI workflow', () => {
nativeShellGateScript.indexOf('const nativeShellGateGroups = ['),
),
)
.matchAll(/'([a-z-]+)'/gu),
.matchAll(/'([a-z0-9-]+)'/gu),
].map((match) => match[1]);
expect(declaredGroups).toEqual(Object.keys(nativeShellGateGroupScripts));
@@ -405,16 +417,40 @@ describe('project CI workflow', () => {
expect(webJob).toContain('run: npm run check:native-shells:agc-web');
expect(webJob).not.toContain('cargo fetch');
const rustJob = jobSection('ai-game-creator-shell-rust-tests');
expect(rustJob).toContain(
'run: npm run check:native-shells:agc-rust-shell',
// 壳 bin 单测按名单分 4 片,一片一个 job:每个片 job 只跑自己那片,且只预热 AGC 壳
// 自己那份锁定依赖(server-rs 那份归 crate 级 job)。
for (const [index, jobName] of [
[1, 'ai-game-creator-shell-rust-shard-1'],
[2, 'ai-game-creator-shell-rust-shard-2'],
[3, 'ai-game-creator-shell-rust-shard-3'],
[4, 'ai-game-creator-shell-rust-shard-4'],
] as const) {
const shardJob = jobSection(jobName);
expect(shardJob).toContain(
`run: npm run check:native-shells:agc-rust-shard-${index}`,
);
expect(shardJob).toContain(
'apps/ai-game-creator-shell/src-tauri/Cargo.toml',
);
expect(shardJob).toContain('cargo fetch --locked');
expect(shardJob).not.toContain('server-rs/Cargo.toml');
}
// 整套用例不能再作为一条命令串行跑完:每个片 job 都必须落到分片运行器的
// `--shard-index` 上,4 个 index 各一次。
for (const index of [1, 2, 3, 4]) {
expect(nativeShellGateScript).toContain(`'--shard-index=${index}'`);
}
expect(
nativeShellGateScript.match(/ai-game-creator-shell:check:rust:shell/gu),
).toHaveLength(4);
const smokeJob = jobSection('ai-game-creator-shell-rust-smoke');
expect(smokeJob).toContain(
'run: npm run check:native-shells:agc-rust-smoke',
);
expect(rustJob).toContain(
'apps/ai-game-creator-shell/src-tauri/Cargo.toml',
);
expect(rustJob).toContain('cargo fetch --locked');
// 壳 job 只预热 AGC 壳自己那份锁定依赖:server-rs 那份归 crate 级 job。
expect(rustJob).not.toContain('server-rs/Cargo.toml');
expect(smokeJob).toContain('cargo fetch --locked');
expect(smokeJob).not.toContain('server-rs/Cargo.toml');
const cratesJob = jobSection('ai-game-creator-shell-rust-crates');
expect(cratesJob).toContain(
@@ -445,8 +481,9 @@ describe('project CI workflow', () => {
'node apps/ai-game-creator-shell/scripts/run-rust-shell-test-shards.mjs --shards=4',
);
// 整套用例不再作为一条 `cargo test -- --test-threads=1` 命令串行跑:CI 与本地都走
// 分片运行器,片内串行、片间并行
// 分片运行器,片内串行,片与片之间靠 job 级并发摊开
expect(workflow).not.toContain('-- --test-threads=1');
expect(workflow).not.toMatch(/^ {8}run: .*--test-threads/mu);
});
it('keeps the shell shard runner exhaustive over discovered tests', () => {
@@ -464,6 +501,10 @@ describe('project CI workflow', () => {
expect(shardRunner).toContain("'--test-threads=1'");
expect(shardRunner).toContain('TMPDIR: shardTmpDirectory');
expect(shardRunner).toContain("'--exact'");
// `--shard-index` 是 CI 的「一个 job 一片」入口:只跑指定片,但覆盖自校验照旧
// 针对 `--list` 全集执行,所以改分片规则仍然会在每个 job 上暴露。
expect(shardRunner).toContain("case 'shard-index':");
expect(shardRunner).toContain('must be within --shards');
});
it('prefetches the excluded standalone Rust crates before the shared crate gates', () => {