build: enforce pinned tool versions
0786575ac5bae9dda4fc00747ee957da5d63ef89
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
xtask/src/main.rs
Modified+33 / −20 text lines
2929const PUP_VERSION: &str = "0.1.8";const PUP_VERSION: &str = "0.1.8"; 32-const NEXTEST_VERSION: &str = "0.9.144"; 32+const NEXTEST_VERSION: &str = "0.9.146"; 3535const BINSTALL_VERSION: &str = "1.23.0";const BINSTALL_VERSION: &str = "1.23.0"; 36+const MACHETE_VERSION: &str = "0.9.2"; 3637const DENY_VERSION: &str = "0.20.2";const DENY_VERSION: &str = "0.20.2"; 3738const AUDIT_VERSION: &str = "0.22.2";const AUDIT_VERSION: &str = "0.22.2"; 3839const CRATES: &[&str] = &[const CRATES: &[&str] = &[ 162163fn cargo_machete() -> ExitCode {fn cargo_machete() -> ExitCode { 163- let installed = tool_present_bin("cargo-machete", "--version", || { 164- cargo(&["install", "--locked", "cargo-machete"]) 164+ let installed = tool_present_bin("cargo-machete", MACHETE_VERSION, || { 166173 if installed != ExitCode::SUCCESS { if installed != ExitCode::SUCCESS { 167174 return installed; return installed; 214221fn install_machete() -> ExitCode {fn install_machete() -> ExitCode { 215- tool_present_bin("cargo-machete", "--version", || { 216- cargo(&["install", "--locked", "cargo-machete"]) 222+ tool_present_bin("cargo-machete", MACHETE_VERSION, || { 220233fn install_deny() -> ExitCode {fn install_deny() -> ExitCode { 221- tool_present_bin("cargo-deny", "--version", || { 234+ tool_present_bin("cargo-deny", DENY_VERSION, || { 223236 "binstall", "binstall", 224237 "--no-confirm", "--no-confirm", 230243fn install_audit() -> ExitCode {fn install_audit() -> ExitCode { 231- tool_present_bin("cargo-audit", "--version", || { 244+ tool_present_bin("cargo-audit", AUDIT_VERSION, || { 233246 "binstall", "binstall", 234247 "--no-confirm", "--no-confirm", 240253fn install_binstall() -> ExitCode {fn install_binstall() -> ExitCode { 241- tool_present(&["binstall", "--help"], || { 254+ tool_present_bin("cargo-binstall", BINSTALL_VERSION, || { 243256 "install", "install", 244257 "cargo-binstall", "cargo-binstall", 254267fn install_nextest() -> ExitCode {fn install_nextest() -> ExitCode { 255- tool_present(&["nextest", "--version"], || { 268+ tool_present_bin("cargo-nextest", NEXTEST_VERSION, || { 257270 "binstall", "binstall", 258271 &format!("cargo-nextest@{NEXTEST_VERSION}"), &format!("cargo-nextest@{NEXTEST_VERSION}"), 316-fn tool_present_bin(program: &str, flag: &str, install: impl FnOnce() -> ExitCode) -> ExitCode { 317- match Command::new(program) 319- .stdout(std::process::Stdio::null()) 329+fn tool_present_bin(program: &str, version: &str, install: impl FnOnce() -> ExitCode) -> ExitCode { 330+ let probe = Command::new(program) 332+ .stdout(std::process::Stdio::piped()) 320333 .stderr(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) 323- Ok(status) if status.success() => ExitCode::SUCCESS, 335+ let pinned = probe.is_ok_and(|output| { 336+ output.status.success() && String::from_utf8_lossy(&output.stdout).contains(version) 338+ if pinned { ExitCode::SUCCESS } else { install() } 328341fn cargo_doc() -> ExitCode {fn cargo_doc() -> ExitCode {