Skip to content

Commit 64ed860

Browse files
committed
ci: Only invoke rustup if running in CI
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.
1 parent 0189456 commit 64ed860

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ci/style.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
set -eux
44

5+
if [ -n "${CI:-}" ]; then
6+
rustup toolchain install nightly -c rustfmt --allow-downgrade
7+
rustup override set nightly
8+
9+
check="--check"
10+
fi
11+
512
rustc ci/style.rs && ./style src
613

7-
rustup toolchain install nightly -c rustfmt --allow-downgrade
8-
rustup override set nightly
914
command -v rustfmt
1015
rustfmt -V
11-
cargo fmt --all -- --check
16+
cargo fmt --all -- ${check:+"$check"}
1217

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

0 commit comments

Comments
 (0)