diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0fdca29..db6ef3c 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -48,9 +48,13 @@ jobs: echo "Unable to read Rust toolchain channel from rust-toolchain.toml" >&2 exit 1 fi - rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt - rustup default "$toolchain" - host="$(rustc -vV | sed -n 's/^host: //p')" + if ! rustup run "$toolchain" rustc --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" rustfmt --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo-clippy --version >/dev/null 2>&1; then + rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt + fi + host="$(rustup run "$toolchain" rustc -vV | sed -n 's/^host: //p')" toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}" toolchain_bin="$toolchain_dir/bin" if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then @@ -187,9 +191,13 @@ jobs: echo "Unable to read Rust toolchain channel from rust-toolchain.toml" >&2 exit 1 fi - rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt - rustup default "$toolchain" - host="$(rustc -vV | sed -n 's/^host: //p')" + if ! rustup run "$toolchain" rustc --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" rustfmt --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo-clippy --version >/dev/null 2>&1; then + rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt + fi + host="$(rustup run "$toolchain" rustc -vV | sed -n 's/^host: //p')" toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}" toolchain_bin="$toolchain_dir/bin" if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then @@ -266,9 +274,13 @@ jobs: echo "Unable to read Rust toolchain channel from rust-toolchain.toml" >&2 exit 1 fi - rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt - rustup default "$toolchain" - host="$(rustc -vV | sed -n 's/^host: //p')" + if ! rustup run "$toolchain" rustc --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" rustfmt --version >/dev/null 2>&1 || \ + ! rustup run "$toolchain" cargo-clippy --version >/dev/null 2>&1; then + rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt + fi + host="$(rustup run "$toolchain" rustc -vV | sed -n 's/^host: //p')" toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}" toolchain_bin="$toolchain_dir/bin" if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then