From 7d98ae7b611e7fdcf0f74a6775b9a8d719ee012b Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Fri, 20 Nov 2026 13:44:24 +0800 Subject: [PATCH] ci: remove CLI functional tests from automated workflows --- .github/workflows/ci.yml | 48 ++++------- .github/workflows/nightly-artifacts.yml | 8 -- .../rust-build-dependency-boundaries.md | 6 +- scripts/check-github-config.mjs | 16 ---- scripts/check-github-config.test.mjs | 80 ++++++++++--------- 5 files changed, 60 insertions(+), 98 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cc01cb565..921216a584 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,9 +119,9 @@ jobs: "$test_root/openbitfun-minisign-0.12/bin/minisign" -v - # ── CLI: independent tests ───────────────────────────────────────── - cli-test: - name: CLI Tests (${{ matrix.os }}) + # ── Runtime component tests ───────────────────────────────────────── + runtime-test: + name: Runtime Tests (${{ matrix.os }}) needs: build-impact if: ${{ !cancelled() && needs.build-impact.outputs.rust_required != 'false' }} runs-on: ${{ matrix.os }} @@ -137,11 +137,8 @@ jobs: # PR latency; release and Nightly matrices retain both architectures. - os: macos-15 cache_key: macos-arm64 - # Keep headroom for a cold macOS CLI build. + # Keep headroom for a cold macOS build. timeout_minutes: 75 - - os: windows-latest - cache_key: windows - timeout_minutes: 30 steps: - uses: actions/checkout@v5 @@ -166,32 +163,19 @@ jobs: - uses: swatinem/rust-cache@v2 with: - shared-key: "cli-ci-v3-${{ github.base_ref || github.ref_name }}-${{ matrix.cache_key }}" + shared-key: "runtime-ci-v1-${{ github.base_ref || github.ref_name }}-${{ matrix.cache_key }}" cache-bin: false # PRs restore trusted caches but never publish merge-ref artifacts. save-if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/1.0.0-explore') }} cache-on-failure: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/1.0.0-explore') }} - - name: Run CLI and ACP tests on macOS + - name: Run ACP tests on macOS if: runner.os == 'macOS' - run: cargo test --locked -p openbitfun-cli -p openbitfun-acp + run: cargo test --locked -p openbitfun-acp - - name: Run CLI, ACP, and agent runtime tests + - name: Run ACP and agent runtime tests if: runner.os == 'Linux' - run: cargo test --locked -p openbitfun-cli -p openbitfun-acp -p openbitfun-agent-runtime - - # ConPTY is a Windows-only execution path. Keep its interactive contracts - # serialized: concurrent native PTYs contend on hosted runners and used to - # race action delivery, TUI restoration, and output observation in Nightly. - - name: Run Windows CLI terminal contracts - if: runner.os == 'Windows' - run: cargo test --locked -p openbitfun-cli --test terminal_process_contracts -- --test-threads=1 - - # Windows file replacement and process ownership differ from POSIX. The - # terminal process target does not run these daemon and TUI unit tests. - - name: Run Windows CLI daemon and QR regressions - if: runner.os == 'Windows' - run: "cargo test --locked -p openbitfun-cli --bin openbitfun -- daemon:: ui::tool_cards::tests::" + run: cargo test --locked -p openbitfun-acp -p openbitfun-agent-runtime - name: Run SDK Host tests if: runner.os == 'Linux' @@ -511,16 +495,16 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 if: ${{ always() }} - needs: [build-impact, cli-test, rust-build-check, package-impact-contract] + needs: [build-impact, runtime-test, rust-build-check, package-impact-contract] steps: - - name: Verify Rust and CLI result + - name: Verify Rust build and runtime test results shell: pwsh env: RUST_REQUIRED: ${{ needs.build-impact.outputs.rust_required }} PR_PRODUCER_REQUIRED: ${{ needs.build-impact.outputs.pr_producer_required }} EVENT_NAME: ${{ github.event_name }} IMPACT_RESULT: ${{ needs.build-impact.result }} - CLI_RESULT: ${{ needs.cli-test.result }} + RUNTIME_RESULT: ${{ needs.runtime-test.result }} RUST_RESULT: ${{ needs.rust-build-check.result }} BUILD_RESULT: ${{ needs.package-impact-contract.result }} run: | @@ -531,13 +515,13 @@ jobs: switch ($env:RUST_REQUIRED) { 'false' { - if ($env:CLI_RESULT -ne 'skipped' -or $env:RUST_RESULT -ne 'skipped') { - throw "Expected skipped Rust/CLI jobs; CLI=$env:CLI_RESULT Rust=$env:RUST_RESULT" + if ($env:RUNTIME_RESULT -ne 'skipped' -or $env:RUST_RESULT -ne 'skipped') { + throw "Expected skipped Rust build and runtime jobs; Runtime=$env:RUNTIME_RESULT Rust=$env:RUST_RESULT" } } 'true' { - if ($env:CLI_RESULT -ne 'success' -or $env:RUST_RESULT -ne 'success') { - throw "Expected successful Rust and CLI jobs; CLI=$env:CLI_RESULT Rust=$env:RUST_RESULT" + if ($env:RUNTIME_RESULT -ne 'success' -or $env:RUST_RESULT -ne 'success') { + throw "Expected successful Rust build and runtime jobs; Runtime=$env:RUNTIME_RESULT Rust=$env:RUST_RESULT" } } default { diff --git a/.github/workflows/nightly-artifacts.yml b/.github/workflows/nightly-artifacts.yml index 564a2c97bc..b70bc976eb 100644 --- a/.github/workflows/nightly-artifacts.yml +++ b/.github/workflows/nightly-artifacts.yml @@ -223,14 +223,6 @@ jobs: - name: Verify projected Cargo metadata run: cargo metadata --locked --no-deps - - name: Run Windows CLI terminal contracts - if: runner.os == 'Windows' - env: - CARGO_INCREMENTAL: "0" - CARGO_PROFILE_DEV_DEBUG: "0" - CARGO_PROFILE_TEST_DEBUG: "0" - run: cargo test --locked -p openbitfun-cli --test terminal_process_contracts -- --test-threads=1 - - name: Select Xcode for macOS Icon Composer assets if: runner.os == 'macOS' shell: bash diff --git a/docs/architecture/rust-build-dependency-boundaries.md b/docs/architecture/rust-build-dependency-boundaries.md index 03a7ee3676..1eacd94a7e 100644 --- a/docs/architecture/rust-build-dependency-boundaries.md +++ b/docs/architecture/rust-build-dependency-boundaries.md @@ -228,11 +228,11 @@ CI 负责 workspace 级检查、真实产品 feature 组合、跨平台、完整 ### 7.1 Hosted CI 关键路径与缓存 -- 日常 Rust/CLI 验证保留 Linux、Windows 和 macOS 三个平台,macOS 固定使用标准 Apple Silicon macOS 15 runner(`macos-15`),缩短 PR 的阻塞路径。CLI 与 Rust 使用相同平台矩阵,Rust 缓存键必须区分 runner 架构。日常验证提供 Apple Silicon 原生测试证据;macOS x64 仍由发布和 Nightly workflow 的矩阵拥有。 +- 日常 Rust 构建检查保留 Linux、Windows 和 macOS 三个平台,macOS 固定使用标准 Apple Silicon macOS 15 runner(`macos-15`),缩短 PR 的阻塞路径。ACP 测试在 Linux 和 macOS 上运行,Agent Runtime、SDK Host 和终端清理测试在 Linux 上运行。自动化流程跳过 CLI 功能测试,打包时继续验证安装和启动。Rust 缓存键必须区分 runner 架构。日常验证提供 Apple Silicon 原生测试证据;macOS x64 仍由发布和 Nightly workflow 的矩阵拥有。 - 验证 job 只依赖自身的编译期前置条件。Tauri `check`/`test` 只要求配置中的前端和资源目录存在时,Rust job 自行创建空目录,不等待或传递可发布前端产物;真实静态资源仍由前端构建和产品打包 owner 负责。 -- Rust/CLI 影响分类必须保守且 fail-closed:只有活动路径全部位于 `src/web-ui/**` 时才允许跳过 Rust 与 CLI matrix;仓库根目录/`docs/**` 的 Markdown 和 `png/**` 可作为已知中性伴随路径。其他嵌套 Markdown 可能是 `include_str!`/`include_bytes!` 输入,workflow 不得宽泛忽略全部 Markdown。空变更、非法或不可用 diff range、Rust/build 输入、CI 脚本、其他产品 surface 和所有未识别路径都必须运行完整验证,不能依赖易漏维护的“已知 Rust 目录”名单。PR 使用 base/head 的 merge-base range,只分类 PR 自身改动;`main` push 使用事件 before/head 的 direct range,保留 force-push 或回退提交的实际影响。 +- Rust 影响分类必须保守且 fail-closed:只有活动路径全部位于 `src/web-ui/**` 时才允许跳过 Rust 构建与运行时测试矩阵;仓库根目录/`docs/**` 的 Markdown 和 `png/**` 可作为已知中性伴随路径。其他嵌套 Markdown 可能是 `include_str!`/`include_bytes!` 输入,workflow 不得宽泛忽略全部 Markdown。空变更、非法或不可用 diff range、Rust/build 输入、CI 脚本、其他产品 surface 和所有未识别路径都必须运行完整验证,不能依赖易漏维护的“已知 Rust 目录”名单。PR 使用 base/head 的 merge-base range,只分类 PR 自身改动;`main` push 使用事件 before/head 的 direct range,保留 force-push 或回退提交的实际影响。 - “纯 Web”前提必须是可执行边界:影响分类 job 在计算 diff 前,从 Git 跟踪文件列表扫描全仓 `.rs`(包括 workspace 外 Installer 和根 build script)。除逐行精确登记的既有测试 fixture 外,非注释 Rust 源码不得出现 `web-ui` 路径 token;因此 `include_dir!`、编译嵌入、分段 `PathBuf::join` 和间接路径变量都会在分类前失败。Frontend job 同时显式运行边界 contract tests 和真实 repository boundary check;跨 surface 的命令注册和调用分别由 owner 测试看护。新增类似源码读取时应修复所有权,而不是给影响分类器追加隐式例外。 -- 可跳过的 matrix 必须汇总到一个稳定的 `Rust / CLI Validation` 结果:分类失败或输出缺失时下游按需要 Rust 处理;分类为 Web-only 时只接受 matrix 全部 skipped,分类为需要 Rust 时只接受全部 success。昂贵的 Rust/CLI 子 job 保留 `!cancelled()`,无 checkout 的轻量汇总使用 `always()` 检查上游 result,因此旧 run 被 concurrency 取消时明确失败而不是被当成 skipped success。 +- 可跳过的 matrix 必须汇总到一个稳定的 `Rust / CLI Validation` 结果:分类失败或输出缺失时下游按需要 Rust 处理;分类为 Web-only 时只接受 matrix 全部 skipped,分类为需要 Rust 时只接受全部 success。Rust 构建和运行时测试子 job 保留 `!cancelled()`,无 checkout 的轻量汇总使用 `always()` 检查上游 result,因此旧 run 被 concurrency 取消时明确失败而不是被当成 skipped success。 - 该汇总只保证已触发 CI run 内的稳定结果;在 workflow 仍忽略 `png/**` 时不能直接宣称为全局 required check。若未来接入 branch protection,必须先保证所有受保护提交都会产生该 check,或同步调整 trigger 覆盖。 - Pull Request 可以恢复可信分支产生的 Cargo 缓存,但不得写入 merge-ref 缓存。只有可信 `main` push 可以保存共享缓存;若依赖编译已经完成而后段测试失败,允许该可信构建保存依赖缓存,避免下一次跨平台构建无谓冷启动。 - 未先修改 Cargo manifest 的 PR/main 验证 job 以仓库提交的 `Cargo.lock` 为唯一解析结果并通过 `--locked` 验证,不在 cache restore 前重新生成 lockfile。依赖解析更新必须作为可评审的源码变更提交,不能让同一 commit 因上游兼容版本发布而自然产生新的 cache key;先改写版本号的发布 job 不属于该前提。 diff --git a/scripts/check-github-config.mjs b/scripts/check-github-config.mjs index 8849a1a49c..f412e1e169 100644 --- a/scripts/check-github-config.mjs +++ b/scripts/check-github-config.mjs @@ -312,22 +312,6 @@ function validateProductControlWorkflowGate() { errors.push('.github/workflows/ci.yml: ProductControl owner gate must remain blocking.'); } } - - const cliJob = workflow.jobs?.['cli-test']; - const cliSteps = Array.isArray(cliJob?.steps) ? cliJob.steps : []; - const cliCommands = cliSteps - .filter((step) => step?.run && step['continue-on-error'] !== true) - .map((step) => String(step.run)); - for (const required of [ - 'cargo test --locked -p openbitfun-cli -p openbitfun-acp', - 'cargo test --locked -p openbitfun-cli -p openbitfun-acp -p openbitfun-agent-runtime', - ]) { - if (!cliCommands.includes(required)) { - errors.push( - `.github/workflows/ci.yml: CLI ProductControl self-control coverage requires the blocking command ${JSON.stringify(required)}.`, - ); - } - } } for (const { relativePath, absolutePath } of yamlFiles) { diff --git a/scripts/check-github-config.test.mjs b/scripts/check-github-config.test.mjs index 85b1ec4462..646580a8b6 100644 --- a/scripts/check-github-config.test.mjs +++ b/scripts/check-github-config.test.mjs @@ -4,6 +4,7 @@ import { existsSync, mkdirSync, mkdtempSync, + readdirSync, readFileSync, rmSync, symlinkSync, @@ -280,7 +281,6 @@ jobs: assert.match(result.stderr, /interactive capability gate must run exactly/u); assert.match(result.stderr, /interactive capability gate must remain blocking/u); assert.match(result.stderr, /ProductControl owner\/delivery-profile gate is missing/u); - assert.match(result.stderr, /CLI ProductControl self-control coverage requires/u); }); test('rejects explicit setup-node node-version below the project baseline when node-version-file is valid', (t) => { @@ -415,6 +415,19 @@ jobs: assert.match(result.stdout, /GitHub YAML config check passed/); }); +test('workflows leave CLI functional tests to local runs', () => { + const directory = path.join(repoRoot, '.github/workflows'); + for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) { + const workflow = yaml.parse(readFileSync(path.join(directory, file), 'utf8')); + for (const job of Object.values(workflow.jobs)) { + for (const step of job.steps ?? []) { + const command = (step.run ?? '').replaceAll('\\\n', ' '); + assert.doesNotMatch(command, /\bcargo (?:test|nextest run)\b[^\n]*\bopenbitfun-cli\b/, file); + } + } + } +}); + test('keeps Rust CI independent, restore-only on PRs, and target-focused', () => { const workflow = yaml.parse( readFileSync(path.join(repoRoot, '.github/workflows/ci.yml'), 'utf8'), @@ -454,7 +467,7 @@ test('keeps Rust CI independent, restore-only on PRs, and target-focused', () => 'The frontend build must not upload an artifact with no consumer', ); - for (const jobName of ['cli-test', 'rust-build-check']) { + for (const jobName of ['runtime-test', 'rust-build-check']) { const job = workflow.jobs[jobName]; const cache = job.steps.find((step) => step.uses?.startsWith('swatinem/rust-cache@'), @@ -480,30 +493,23 @@ test('keeps Rust CI independent, restore-only on PRs, and target-focused', () => } } - const cliJob = workflow.jobs['cli-test']; + const runtimeJob = workflow.jobs['runtime-test']; assert.deepEqual( - cliJob.strategy.matrix.include.map((entry) => entry.os), - rustJob.strategy.matrix.os, - 'CLI and Rust validation must exercise the same Linux, Apple Silicon macOS, and Windows hosts', + runtimeJob.strategy.matrix.include.map((entry) => entry.os), + ['ubuntu-latest', 'macos-15'], ); - assert.equal( - cliJob.strategy.matrix.include.find((entry) => entry.os === 'macos-15').cache_key, - 'macos-arm64', - ); - assert.equal(cliJob['timeout-minutes'], '${{ matrix.timeout_minutes }}'); + const runtimeSteps = runtimeJob.steps.filter((step) => step.run?.startsWith('cargo test')); assert.deepEqual( - cliJob.strategy.matrix.include.map((entry) => entry.timeout_minutes), - [30, 75, 30], - 'Only the cold macOS CLI build needs a longer job budget', - ); - assert.ok( - cliJob.strategy.matrix.include.some((entry) => entry.os === 'windows-latest'), - 'Windows ConPTY contracts must run before Nightly', - ); - assert.equal( - cliJob.steps.find((step) => step.name === 'Run Windows CLI terminal contracts')?.run, - 'cargo test --locked -p openbitfun-cli --test terminal_process_contracts -- --test-threads=1', + runtimeSteps.filter((step) => step.if === "runner.os == 'macOS'").map((step) => step.run), + ['cargo test --locked -p openbitfun-acp'], ); + assert.ok(runtimeSteps.every((step) => step['continue-on-error'] !== true)); + const linuxCommands = runtimeSteps + .filter((step) => step.if === "runner.os == 'Linux'") + .map((step) => step.run); + assert.ok(linuxCommands.includes('cargo test --locked -p openbitfun-acp -p openbitfun-agent-runtime')); + assert.ok(linuxCommands.includes('cargo test --locked -p openbitfun-sdk-host -p openbitfun-sdk-host-app')); + assert.ok(linuxCommands.some((command) => command.startsWith('cargo test --locked -p terminal-core '))); const rustCache = rustJob.steps.find((step) => step.uses?.startsWith('swatinem/rust-cache@'), @@ -712,7 +718,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', ); } const impactJob = workflow.jobs['build-impact']; - const cliJob = workflow.jobs['cli-test']; + const runtimeJob = workflow.jobs['runtime-test']; const rustJob = workflow.jobs['rust-build-check']; const buildJob = workflow.jobs['package-impact-contract']; const resultJob = workflow.jobs['rust-validation-result']; @@ -811,7 +817,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', ); assert.match(classify?.run ?? '', /--range-mode "\$RANGE_MODE"/); - for (const job of [cliJob, rustJob]) { + for (const job of [runtimeJob, rustJob]) { assert.equal(job.needs, 'build-impact'); assert.match(job.if, /!cancelled\(\)/); assert.doesNotMatch(job.if, /always\(\)/); @@ -839,9 +845,9 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', assert.equal(resultJob.if, '${{ always() }}'); assert.deepEqual( [...resultJob.needs].sort(), - ['build-impact', 'cli-test', 'package-impact-contract', 'rust-build-check'], + ['build-impact', 'package-impact-contract', 'runtime-test', 'rust-build-check'], ); - const verify = resultJob.steps.find((step) => step.name === 'Verify Rust and CLI result'); + const verify = resultJob.steps.find((step) => step.name === 'Verify Rust build and runtime test results'); assert.equal(verify?.env?.RUST_REQUIRED, '${{ needs.build-impact.outputs.rust_required }}'); assert.equal( verify?.env?.PR_PRODUCER_REQUIRED, @@ -849,7 +855,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', ); assert.equal(verify?.env?.EVENT_NAME, '${{ github.event_name }}'); assert.equal(verify?.env?.IMPACT_RESULT, '${{ needs.build-impact.result }}'); - assert.equal(verify?.env?.CLI_RESULT, '${{ needs.cli-test.result }}'); + assert.equal(verify?.env?.RUNTIME_RESULT, '${{ needs.runtime-test.result }}'); assert.equal(verify?.env?.RUST_RESULT, '${{ needs.rust-build-check.result }}'); assert.equal( verify?.env?.BUILD_RESULT, @@ -857,7 +863,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', ); assert.equal(verify?.shell, 'pwsh'); assert.match(verify?.run ?? '', /successful impact-selected producer jobs/i); - assert.match(verify?.run ?? '', /successful Rust and CLI jobs/i); + assert.match(verify?.run ?? '', /successful Rust build and runtime jobs/i); const dshJob = workflow.jobs['dsh-profile-windows']; assert.equal(dshJob.needs, 'build-impact'); @@ -871,7 +877,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', producerRequired: 'true', eventName: 'pull_request', impactResult, - cliResult: 'success', + runtimeResult: 'success', rustResult: 'success', buildResult: 'success', expectedSuccess: false, @@ -880,7 +886,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', for (const rustRequired of ['false', 'true']) { for (const producerRequired of ['false', 'true']) { for (const eventName of ['pull_request', 'push']) { - for (const cliResult of statuses) { + for (const runtimeResult of statuses) { for (const rustResult of statuses) { for (const buildResult of statuses) { const packageExpected = eventName === 'pull_request' @@ -890,14 +896,14 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', producerRequired, eventName, impactResult: 'success', - cliResult, + runtimeResult, rustResult, buildResult, expectedSuccess: (packageExpected ? buildResult === 'success' : buildResult === 'skipped') && (rustRequired === 'false' - ? cliResult === 'skipped' && rustResult === 'skipped' - : cliResult === 'success' && rustResult === 'success'), + ? runtimeResult === 'skipped' && rustResult === 'skipped' + : runtimeResult === 'success' && rustResult === 'success'), }); } } @@ -910,7 +916,7 @@ test('gates fast checks and PR packaging behind one fail-closed build decision', producerRequired: 'false', eventName: 'push', impactResult: 'success', - cliResult: 'skipped', + runtimeResult: 'skipped', rustResult: 'skipped', buildResult: 'success', expectedSuccess: false, @@ -930,7 +936,7 @@ foreach ($case in $cases) { $env:PR_PRODUCER_REQUIRED = [string]$case.producerRequired $env:EVENT_NAME = [string]$case.eventName $env:IMPACT_RESULT = [string]$case.impactResult - $env:CLI_RESULT = [string]$case.cliResult + $env:RUNTIME_RESULT = [string]$case.runtimeResult $env:RUST_RESULT = [string]$case.rustResult $env:BUILD_RESULT = [string]$case.buildResult $succeeded = $true @@ -1069,10 +1075,6 @@ test('nightly validates generated inputs and projected lockfiles before packagin false, 'nightly must not hide stale committed lockfiles by regenerating them ad hoc', ); - assert.equal( - steps.find((step) => step.name === 'Run Windows CLI terminal contracts')?.run, - 'cargo test --locked -p openbitfun-cli --test terminal_process_contracts -- --test-threads=1', - ); }); test('nightly orchestrates the shared build before the separately privileged publish', () => {