Repository navigation
ci(rust-core): 只运行受影响 crate 的 Rust Core CI 与平台测试放置规范 - #50
Merged
Merged
Conversation
- 新增 .github/workflows/rust-core.yml:Select crates 选出改动的 crate 及其所有反向依赖;Linux 对选中的 crate 跑 fmt、日志事件目录、注释规范、 clippy(全部 feature 与 Windows 目标)和测试;macOS/Windows 只测试声明了 该主机的 crate,Draft PR 不跑,Linux 通过后才跑;Rust Core gate 汇总结果, 不设路径过滤,便于设为必过检查。只缓存下载的依赖。 - 新增 scripts/rust-core/affected-crates.mjs:读取 cargo metadata,按改动 文件和 [package.metadata.lithe-ci] 的 hosts / test-features 生成各主机的 cargo 参数。 - 新增 scripts/rust-core/verify-platform-tests.mjs:解析 cfg、cfg_attr、 mod 声明和 #![cfg],测试在所属 crate 的每台 CI 主机上都被编译掉或忽略时失败。 - lithe-platform、lithe-platform-tests 声明 macOS 与 Windows,lithe-remote 声明 macOS 并以 server feature 测试。 - 注释规范脚本可只对指定 crate 运行 Rustdoc,文本检查仍覆盖全部 crate。 - 新增 CONTRIBUTING.md:平台差异写成数据、平台测试放在哪里、主机声明和 CI 选择规则;README 与 scripts/rust-core/README.md 同步。
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 05:28
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Rust Core 之前没有任何 CI 运行 fmt、clippy、测试、注释规范和日志事件目录检查;PR 上只有 Plugin SDKs 工作流。本 PR 新增
Rust Core工作流。它只构建、检查和测试受改动影响的 crate;macOS 和 Windows 只测试声明了该主机的 crate。同时新增开发者规范CONTRIBUTING.md,规定平台测试必须放进lithe-platform-tests,不能散落在其他 crate 里,并用脚本检查。接在 #48 之后:#48 把平台规则改成了数据,并把平台专属测试搬进了
lithe-platform-tests。改动
工作流
.github/workflows/rust-core.ymlcargo fmt --check(全部 crate)、日志事件目录检查、注释规范(Rustdoc 只构建选中的 crate)、clippy--all-features、Windows 目标 clippy(只用默认 feature)、cargo test(启用test-features)cargo testpull_request(opened、synchronize、reopened、ready_for_review)和手动运行;手动运行检查全部 crate。不设路径过滤,所以每个 PR 都会报告Rust Core gate。target:现有的 sdk-e2e 缓存已经占用 10 GB 配额中的 5.1 GB。CARGO_INCREMENTAL=0和CARGO_PROFILE_DEV_DEBUG=line-tables-only,减少编译时间和磁盘占用。选择 crate:
scripts/rust-core/affected-crates.mjscargo metadata --no-deps(不需要网络)。选中的 crate 是改动文件所在的 crate,加上所有直接或间接依赖它的 crate;各种依赖都算,包括 dev-dependency。rust/下不属于某个 crate 的文件(workspace 清单、Cargo.lock、fixtures/、contracts/、logging/)、shared/plugins/contract/、scripts/rust-core/、scripts/logging/,以及工作流本身。shared/plugins/sdk/e2e/只选中lithe-core。文档和 SDK 不选中任何 crate。--base HEAD^1),--no-renames让移动的文件把原路径也算进来。Cargo.toml里声明:lithe-platform和lithe-platform-tests:macOS 与 Windows。lithe-remote:macOS,并启用serverfeature。它的服务端运行在 Linux 和 macOS 主机上,集成测试要启动本包的lithe-remote-server(CARGO_BIN_EXE_*只对同一个包可见),所以搬不进lithe-platform-tests。用当前 workspace 实际计算的结果:
platform-tests/lsp-engine/src/tests.rslithe-lsp-engine、lithe-core)git-host/src/lib.rslithe-platform-testslithe-platform-testsplatform/src/paths.rsCargo.lock或工作流平台测试放置检查:
scripts/rust-core/verify-platform-tests.mjsmod x;(包括#[path])、内联mod、文件开头的#![cfg],以及cfg_attr(…, test)和cfg_attr(…, ignore)。cfg的结果:真、假、未知。feature 这类无法确定的条件算作“可能运行”。--list列出所有只在部分主机运行的测试。当前全部 52 个 crate 都通过检查。其他
verify-rust-core-comments.sh [crate-directory ...]:Rustdoc 只构建参数指定的 crate,文本检查仍覆盖全部 crate;目录不存在时退出码为 2。CONTRIBUTING.md,中英双语,内容包括:平台差异写成数据、平台测试的放置规则(按顺序判断的五条)、主机声明、CI 的选择规则和本地命令。README 和scripts/rust-core/README.md已同步。规则取舍(请评审确认)
#[cfg(unix)]测试分布在 core、workspace、project、git、lsp-engine、project-generators、remote 中。它们用符号链接、权限位或假的 ssh 脚本当夹具,验证本 crate 自己的逻辑,Linux 上会运行。规范允许这类测试留在原 crate(第 3 条);Windows 上应有的另一种结果写进lithe-platform-tests。cfg!(windows),都是给夹具路径加C:盘符,让它在本机算绝对路径,不是按系统切换预期结果。规范允许这种用法(第 4 条);按系统切换预期结果的断言要放进lithe-platform-tests。这两条要看测试的意图,脚本判断不了,由评审把关。验证
node --test scripts/rust-core/*.test.mjs:16 个全部通过。verify-platform-tests.mjs:52 个 crate 通过。$GITHUB_OUTPUT检查了输出内容,以及 bash 数组对参数的拆分。cargo test --workspace --features lithe-remote/server --no-run编译通过。-p lithe-platform -p lithe-remote -p lithe-platform-tests --features lithe-remote/server):140 个全部通过。cargo fmt --check和测试稳定性门禁都通过。lithe-platform和lithe-platform-tests的测试。合入后建议
把
Rust Core gate加进 main 规则集的必过检查。本 PR 没有改规则集。