Skip to content

Commit fd32211

Browse files
committed
fix(ci): Windows 目标 clippy 不再编译自带的 SQLite,补上停摆期间漏检的告警 (Refs 1lck/Lithe-IDEA#2231)
#154 给 lithe-remote 加了 motty(bundled rusqlite),lithe-workspace 默认 打开它。从那以后,“Lint for Windows” 在 Linux runner 上编译 SQLite 的 C 源码时找不到 MSVC 的 lib.exe,所有 PR 的 Rust Core / Linux 和 gate 都失败。 - 这个步骤加 LIBSQLITE3_SYS_USE_PKG_CONFIG=1:libsqlite3-sys 只复制预生成 绑定、输出链接指令,不编译 C 源码。clippy 不链接,检查结果不变。 - 步骤停摆期间漏进来的告警:ssh_configuration 测试里只给 Unix 测试用的 Directory::write、lines、DEFAULTS 加 #[cfg(unix)]。 - CONTRIBUTING 的本地 Windows clippy 命令同样加上这个变量。
1 parent 18feb4a commit fd32211

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎.github/workflows/rust-core.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ jobs:
111111
cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --all-features -- -D warnings
112112
# Code behind cfg(windows) compiles only for Windows. Checking it here
113113
# finds its errors without a Windows runner; default features only,
114-
# because the remote server feature targets Unix hosts.
114+
# because the remote server feature targets Unix hosts. Clippy only
115+
# checks and never links, so SQLite (bundled for the Motty import) is
116+
# told to link a system library instead of compiling its C source,
117+
# which needs the MSVC tools that a Linux runner does not have.
115118
- name: Lint for Windows
119+
env:
120+
LIBSQLITE3_SYS_USE_PKG_CONFIG: "1"
116121
run: |
117122
read -ra packages <<< "$PACKAGES"
118123
cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --target x86_64-pc-windows-msvc -- -D warnings

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ node --test scripts/rust-core/*.test.mjs # CI 脚本自己的
6363
cargo test --manifest-path rust/Cargo.toml -p lithe-platform -p lithe-platform-tests # 在 macOS 或 Windows 上运行平台测试
6464
```
6565

66-
手边没有 Windows 时,至少运行一次 `cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings`,确认 Windows 代码能编译。
66+
手边没有 Windows 时,至少运行一次 `LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings`,确认 Windows 代码能编译。环境变量让 SQLite 改为链接系统库、不编译自带的 C 源码:编译它需要 MSVC 工具,macOS 和 Linux 上没有;clippy 只检查不链接,不受影响。
6767

6868
---
6969

@@ -132,4 +132,4 @@ node --test scripts/rust-core/*.test.mjs # the CI scripts' own
132132
cargo test --manifest-path rust/Cargo.toml -p lithe-platform -p lithe-platform-tests # platform tests on macOS or Windows
133133
```
134134

135-
Without a Windows host, at least run `cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings` to confirm the Windows code compiles.
135+
Without a Windows host, at least run `LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings` to confirm the Windows code compiles. The variable makes SQLite link a system library instead of compiling its bundled C source, which needs the MSVC tools that macOS and Linux do not have; clippy only checks and never links, so this does not matter.

‎rust/crates/workspace/src/ssh_configuration/tests.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ impl Directory {
1818
Self(path)
1919
}
2020

21+
// Writing files, `lines` and `DEFAULTS` serve only the tests that run
22+
// `fake_ssh`, a shell script, so they are Unix only like those tests.
23+
#[cfg(unix)]
2124
fn write(&self, relative: &str, text: &str) {
2225
let path = self.0.join(relative);
2326
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
@@ -53,10 +56,12 @@ fn fake_ssh(directory: &Directory, configured: &str, baseline: &str) -> String {
5356
program.display().to_string()
5457
}
5558

59+
#[cfg(unix)]
5660
fn lines(values: &[&str]) -> String {
5761
values.join("\n")
5862
}
5963

64+
#[cfg(unix)]
6065
const DEFAULTS: &[&str] = &[
6166
"user localdev",
6267
"port 22",

0 commit comments

Comments
 (0)