Skip to content

CI:rustfmt、clippy 和测试,修复 clippy 警告并让测试远离真实内核 - #8

Merged
aprylewu merged 3 commits into
mainfrom
claude/ci
Oct 23, 2026
Merged

aprylewu merged 3 commits into
mainfrom
claude/ci

Conversation

@aprylewu

Copy link
Copy Markdown
Contributor

本 PR 加上 GitHub Actions CI,并把代码修到能通过 cargo clippy -D warnings。

CI(4f0bcd0)

  • 触发:针对 main 的 pull request 和 push 到 main。只改了 *.md、docs/、assets/ 或 LICENSE 时跳过。也可以手动运行(workflow_dispatch)。
  • lint job(Linux):cargo fmt --check;Linux 的 clippy;从 Linux 交叉检查两个 macOS target(aarch64 跑 clippy,x86_64 跑 check)。项目没有 C 依赖,所以不用花 macOS runner 的分钟数。
  • test job:Linux 上运行 cargo test --all-targets --locked 和 release 构建。macOS 测试只在手动运行和带 macos 标签的 PR 上跑(仓库是私有的,macOS 分钟数按约 10 倍计费)。
  • 工具链固定为 1.99.1,需要手动升级,免得新版 clippy 新增的 lint 让无关 PR 失败。两个 action 都固定到具体 commit SHA(checkout v7.0.1、rust-cache v2.9.3,已对照 tag 核实)。
  • 安全检查:测试前在 PATH 最前面放 networksetup 和 gsettings 的替身。替身会记录调用并返回失败;测试之后如果有任何调用记录,job 就失败(AGENTS.md 规定测试不能动系统代理)。
  • 因为有 paths-ignore,不要把这些 job 设成 required status check:被跳过的 workflow 会让 required check 一直 Pending,从而卡住 PR。
  • AGENTS.md 补充了 lint 命令和 CI 的说明。

clippy 和测试隔离(d9da523)

  • 修复 Rust 1.99.1 报出的 clippy lint:struct update 语法、repeat_n、as_chunks、迭代器循环、多余的 to_string、LineEditor::is_empty。
  • RELOAD_UNCERTAIN 从全局 AtomicBool 改成按 config.yaml 路径记录。这样并行测试里,一个测试标记了自己的文件,不会影响别的测试。
  • 测试用的 offline_app 把控制器地址设为 127.0.0.1:1,测试遗留的 worker 不会连到 127.0.0.1:9090 上真实的内核。
  • macOS 上的 networksetup 改为从 PATH 查找(原来是 /usr/sbin/networksetup),CI 的替身才能拦截到。

其他(a18e2dd)

  • .gitignore 忽略 macOS 的 AppleDouble 文件(._*)。

验证

  • 本地(Linux x86_64,Rust 1.99.1):cargo fmt --check 和 cargo clippy --all-targets --locked -- -D warnings 通过;cargo test --all-targets --locked 331 通过、16 ignored;测试期间替身没有记录到任何 networksetup / gsettings 调用。
  • 本地没有跑 macOS target 的 clippy 和 check,交给本 PR 的 CI。
  • 仓库里目前还没有 macos 标签,要在 PR 上跑 macOS 测试需要先创建这个标签。

🤖 Generated with Claude Code

aprylewu and others added 3 commits October 22, 2026 23:49
- Fix the clippy lints Rust 1.99.1 reports (struct update syntax,
  repeat_n, as_chunks, iterator loops, a needless to_string, is_empty).
- RELOAD_UNCERTAIN is now keyed by config.yaml path, so a test that
  marks its own file uncertain cannot leak the flag into another test
  running in parallel.
- offline_app points the controller at 127.0.0.1:1, so a worker a test
  leaves running cannot reach a real core on 127.0.0.1:9090.
- networksetup is looked up on PATH, so CI can shadow it with a stub
  that records and fails any call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pull requests and pushes to main that change code run rustfmt, clippy
for Linux, clippy and check for both macOS targets from Linux, tests on
Linux and a release build. macOS tests run only on manual runs and on
pull requests labelled "macos". The toolchain is pinned to 1.99.1, and
the test job fails if anything ran networksetup or gsettings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aprylewu aprylewu added the macos CI also runs the tests on macOS label Oct 22, 2026
@aprylewu
aprylewu merged commit eecd41c into main Oct 23, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macos CI also runs the tests on macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant