Skip to content

Commit 02ab0ab

Browse files
committed
Add Linux checks to checker script
To avoid CI failing if checker script passes on macOS locally
1 parent 21fc1b7 commit 02ab0ab

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

apps/desktop/src-tauri/src/mcp/tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ fn test_no_duplicate_tool_names() {
132132
#[test]
133133
fn test_resource_count() {
134134
let resources = get_all_resources();
135+
#[cfg(target_os = "macos")]
135136
assert_eq!(resources.len(), 8, "Expected 8 resources");
137+
#[cfg(not(target_os = "macos"))]
138+
assert_eq!(resources.len(), 7, "Expected 7 resources");
136139
}
137140

138141
#[test]
@@ -294,6 +297,7 @@ fn test_volume_tools_exist() {
294297
assert_eq!(volume_tools.len(), 2, "Expected 2 volume tools");
295298
}
296299

300+
#[cfg(target_os = "macos")]
297301
#[test]
298302
fn test_volumes_resource_exists() {
299303
// volume_list is now a resource (cmdr://volumes), not a tool

scripts/check/registry.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func getCheckByName(name string) Check {
2121
return &CargoUdepsCheck{}
2222
case "rust-tests":
2323
return &RustTestsCheck{}
24+
case "rust-tests-linux":
25+
return &RustTestsLinuxCheck{}
2426
// Desktop/Svelte checks
2527
case "prettier":
2628
return &PrettierCheck{}
@@ -88,6 +90,7 @@ func getRustChecks() []Check {
8890
&CargoDenyCheck{},
8991
&CargoUdepsCheck{},
9092
&RustTestsCheck{},
93+
&RustTestsLinuxCheck{},
9194
}
9295
}
9396

@@ -139,6 +142,8 @@ func getCheckCLIName(check Check) string {
139142
return "svelte-tests"
140143
}
141144
return "tests"
145+
case "tests (linux)":
146+
return "rust-tests-linux"
142147
case "e2e tests":
143148
return "e2e-tests"
144149
case "prettier (website)":

scripts/check/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func showUsage() {
3030
fmt.Println(" go run ./scripts/check --ci # CI mode (no auto-fix)")
3131
fmt.Println()
3232
fmt.Println("Available check names:")
33-
fmt.Println(" Desktop/Rust: rustfmt, clippy, cargo-audit, cargo-deny, rust-tests")
33+
fmt.Println(" Desktop/Rust: rustfmt, clippy, cargo-audit, cargo-deny, rust-tests, rust-tests-linux")
3434
fmt.Println(" Desktop/Svelte: prettier, eslint, stylelint, svelte-check, knip, svelte-tests, e2e-tests")
3535
fmt.Println(" Website: website-prettier, website-eslint, website-typecheck, website-build")
3636
fmt.Println(" License server: license-server-prettier, license-server-eslint, license-server-typecheck, license-server-tests")

scripts/check/rust_checks.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,45 @@ func (c *RustTestsCheck) Run(ctx *CheckContext) error {
165165
return nil
166166
}
167167

168+
// RustTestsLinuxCheck runs Rust tests in a Linux Docker container.
169+
// This catches platform-specific issues (e.g., #[cfg(target_os = "macos")]) before CI.
170+
type RustTestsLinuxCheck struct{}
171+
172+
func (c *RustTestsLinuxCheck) Name() string {
173+
return "tests (Linux)"
174+
}
175+
176+
func (c *RustTestsLinuxCheck) Run(ctx *CheckContext) error {
177+
rustDir := filepath.Join(ctx.RootDir, "apps", "desktop", "src-tauri")
178+
179+
// Check if Docker is available
180+
if !commandExists("docker") {
181+
fmt.Printf("%sSKIPPED%s (Docker not installed)\n", colorYellow, colorReset)
182+
return nil
183+
}
184+
185+
// Check if Docker daemon is running
186+
checkCmd := exec.Command("docker", "info")
187+
if _, err := runCommand(checkCmd, true); err != nil {
188+
fmt.Printf("%sSKIPPED%s (Docker not running)\n", colorYellow, colorReset)
189+
return nil
190+
}
191+
192+
// Run tests in a Rust container
193+
cmd := exec.Command("docker", "run", "--rm",
194+
"-v", rustDir+":/app",
195+
"-w", "/app",
196+
"rust:latest",
197+
"sh", "-c", "cargo test --no-fail-fast")
198+
output, err := runCommand(cmd, true)
199+
if err != nil {
200+
fmt.Println()
201+
fmt.Print(indentOutput(output, " "))
202+
return fmt.Errorf("rust tests failed on Linux")
203+
}
204+
return nil
205+
}
206+
168207
// CargoUdepsCheck detects unused dependencies.
169208
type CargoUdepsCheck struct{}
170209

0 commit comments

Comments
 (0)