From ffb05e739267284e60a6c494c5be773a6392a5d7 Mon Sep 17 00:00:00 2001 From: Chummy Date: Tue, 3 Mar 2026 07:16:03 +0800 Subject: [PATCH] ci: expose toolchain bin on PATH for cargo fmt/clippy --- scripts/ci/rust_quality_gate.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/ci/rust_quality_gate.sh b/scripts/ci/rust_quality_gate.sh index 36d57b81b..121204c3a 100755 --- a/scripts/ci/rust_quality_gate.sh +++ b/scripts/ci/rust_quality_gate.sh @@ -7,6 +7,27 @@ if [ "${1:-}" = "--strict" ]; then MODE="strict" fi +ensure_toolchain_bin_on_path() { + local toolchain_bin="" + + if [ -n "${CARGO:-}" ]; then + toolchain_bin="$(dirname "${CARGO}")" + elif [ -n "${RUSTC:-}" ]; then + toolchain_bin="$(dirname "${RUSTC}")" + fi + + if [ -z "$toolchain_bin" ] || [ ! -d "$toolchain_bin" ]; then + return 0 + fi + + case ":$PATH:" in + *":${toolchain_bin}:"*) ;; + *) export PATH="${toolchain_bin}:$PATH" ;; + esac +} + +ensure_toolchain_bin_on_path + run_cargo_tool() { local subcommand="$1" shift