From 3c225acf43cf21c9594d8f877e7d48b05fea564b Mon Sep 17 00:00:00 2001 From: Gilad Chase Date: Tue, 24 Dec 2024 10:57:19 +0200 Subject: [PATCH] feat: reinstate rustfmt script, detach from CI --- scripts/rust_fmt.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/rust_fmt.sh diff --git a/scripts/rust_fmt.sh b/scripts/rust_fmt.sh new file mode 100644 index 0000000000..b63f824b87 --- /dev/null +++ b/scripts/rust_fmt.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -euo pipefail + +if [[ -n "${CI:-}" ]]; then + echo "This script should not be run in a CI environment, as it installs toolchains out of cache." + exit 1 +fi + +SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" +TOOLCHAIN=$(grep "EXTRA_RUST_TOOLCHAINS:" "${SCRIPT_DIR}"/../.github/workflows/main.yml | awk '{print $2}') + +function install_rustfmt() { + rustup toolchain install "${TOOLCHAIN}" + rustup component add --toolchain "${TOOLCHAIN}" rustfmt +} + +rustup toolchain list | grep -q "${TOOLCHAIN}" || install_rustfmt + +cargo +"${TOOLCHAIN}" fmt --all -- "$@"