Skip to content

Commit

Permalink
ci: Only invoke rustup if running in CI
Browse files Browse the repository at this point in the history
The script shouldn't need to update `rustfmt` every time it gets run.

Additionally, only pass `--check` when in CI so this script can be used
for invoking the formatter locally.

(backport <rust-lang#4107>)
(cherry picked from commit 64ed860)
  • Loading branch information
tgross35 committed Nov 19, 2024
1 parent ca8dcbf commit 818255b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ci/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

set -ex

if [ -n "${CI:-}" ]; then
rustup toolchain install nightly -c rustfmt --allow-downgrade
rustup override set nightly

check="--check"
fi

rustc ci/style.rs && ./style src

rustup toolchain install nightly -c rustfmt --allow-downgrade
rustup override set nightly
command -v rustfmt
rustfmt -V
cargo fmt --all -- --check
cargo fmt --all -- ${check:+"$check"}

if shellcheck --version ; then
find . -name '*.sh' -print0 | xargs -0 shellcheck
Expand Down

0 comments on commit 818255b

Please # to comment.