ci: expose toolchain bin on PATH for cargo fmt/clippy

This commit is contained in:
Chummy 2026-03-03 07:16:03 +08:00 committed by Chum Yin
parent 0453519e1c
commit ffb05e7392

View File

@ -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