From 4b048f97024407a810a612d7edcf6b4c70da4f83 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sat, 1 Aug 2026 22:39:39 +0400 Subject: [PATCH] chore: ci --- src-tauri/tests/common/mod.rs | 16 ++++++++++++++++ src-tauri/tests/donut_proxy_integration.rs | 6 ++---- src-tauri/tests/test_harness/mod.rs | 8 ++------ src-tauri/tests/vpn_integration.rs | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src-tauri/tests/common/mod.rs b/src-tauri/tests/common/mod.rs index 31e3280..7368250 100644 --- a/src-tauri/tests/common/mod.rs +++ b/src-tauri/tests/common/mod.rs @@ -1,6 +1,22 @@ use std::path::PathBuf; use std::process::Command; +/// Whether Docker can run the Linux images these fixtures are built from. +/// +/// `docker version` succeeding is not enough: the Windows CI runner ships a +/// daemon in Windows-container mode, which answers that command happily and +/// then rejects the fixtures with `unknown capability: "CAP_NET_ADMIN"`. +#[allow(dead_code)] +pub fn docker_supports_linux_containers() -> bool { + Command::new("docker") + .args(["version", "--format", "{{.Server.Os}}"]) + .output() + .map(|output| { + output.status.success() && String::from_utf8_lossy(&output.stdout).trim() == "linux" + }) + .unwrap_or(false) +} + /// Utility functions for integration tests pub struct TestUtils; diff --git a/src-tauri/tests/donut_proxy_integration.rs b/src-tauri/tests/donut_proxy_integration.rs index 356f699..93eb98b 100644 --- a/src-tauri/tests/donut_proxy_integration.rs +++ b/src-tauri/tests/donut_proxy_integration.rs @@ -1612,10 +1612,8 @@ async fn test_local_proxy_with_shadowsocks_upstream( let binary_path = setup_test().await?; let mut tracker = ProxyTestTracker::new(binary_path.clone()); - // Check Docker availability - let docker_check = std::process::Command::new("docker").arg("version").output(); - if docker_check.map(|o| !o.status.success()).unwrap_or(true) { - eprintln!("skipping Shadowsocks e2e test because Docker is unavailable"); + if !common::docker_supports_linux_containers() { + eprintln!("skipping Shadowsocks e2e test because Docker cannot run Linux containers"); return Ok(()); } diff --git a/src-tauri/tests/test_harness/mod.rs b/src-tauri/tests/test_harness/mod.rs index be3300d..9e094eb 100644 --- a/src-tauri/tests/test_harness/mod.rs +++ b/src-tauri/tests/test_harness/mod.rs @@ -24,13 +24,9 @@ fn has_external_wireguard_service() -> bool { std::env::var("VPN_TEST_WG_HOST").is_ok() } -/// Check if Docker is available +/// Check if Docker can run the Linux fixtures this harness needs pub fn is_docker_available() -> bool { - Command::new("docker") - .arg("version") - .output() - .map(|o| o.status.success()) - .unwrap_or(false) + crate::common::docker_supports_linux_containers() } /// Start a WireGuard test server and return client config diff --git a/src-tauri/tests/vpn_integration.rs b/src-tauri/tests/vpn_integration.rs index 14c8d4e..e7416a4 100644 --- a/src-tauri/tests/vpn_integration.rs +++ b/src-tauri/tests/vpn_integration.rs @@ -775,7 +775,7 @@ async fn test_wireguard_traffic_flows_through_donut_proxy( cleanup_runtime().await; if !test_harness::is_docker_available() { - eprintln!("skipping WireGuard e2e test because Docker is unavailable"); + eprintln!("skipping WireGuard e2e test because Docker cannot run Linux containers"); return Ok(()); }