From 061873058ef7d6ac4feae6ac476b71bfef2b2b90 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 6 Jul 2026 20:09:26 +0000 Subject: [PATCH] ci: install rust toolchain from project config --- .gitea/workflows/ci.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 50b0897..649c0c5 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -22,15 +22,21 @@ jobs: - name: Checkout uses: actions/checkout@v5 - - name: Use preinstalled Rust toolchain + - name: Install Rust toolchain run: | set -eu - toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/1.96.1-x86_64-unknown-linux-gnu" + toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n1)" + if [ -z "$toolchain" ]; then + 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')" + toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}" toolchain_bin="$toolchain_dir/bin" if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then - echo "Rust 1.96.1 is not preinstalled at $toolchain_dir." >&2 - echo "Install it in the Gitea runner image/host before running CI:" >&2 - echo "rustup toolchain install 1.96.1 --profile minimal --component clippy --component rustfmt" >&2 + echo "Rust $toolchain was not installed at $toolchain_dir." >&2 exit 1 fi printf '%s\n' "$toolchain_bin" >> "$GITHUB_PATH" @@ -121,15 +127,21 @@ jobs: - name: Checkout uses: actions/checkout@v5 - - name: Use preinstalled Rust toolchain + - name: Install Rust toolchain run: | set -eu - toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/1.96.1-x86_64-unknown-linux-gnu" + toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n1)" + if [ -z "$toolchain" ]; then + 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')" + toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}" toolchain_bin="$toolchain_dir/bin" if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then - echo "Rust 1.96.1 is not preinstalled at $toolchain_dir." >&2 - echo "Install it in the Gitea runner image/host before running CI:" >&2 - echo "rustup toolchain install 1.96.1 --profile minimal --component clippy --component rustfmt" >&2 + echo "Rust $toolchain was not installed at $toolchain_dir." >&2 exit 1 fi printf '%s\n' "$toolchain_bin" >> "$GITHUB_PATH"