Skip to content

Commit 0516dde

Browse files
committed
Add formatting check to CI
Add code to the CI script, guarded on env var `DO_FMT` to run the formatter. Add a formatting job to the nightly CI job as a separate step, in a similar fashion to how the other nightly steps are done.
1 parent c7807df commit 0516dde

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.github/workflows/rust.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
toolchain: nightly
1919
override: true
2020
components: rust-src
21+
- name: Check formatting
22+
env:
23+
DO_FMT: true
24+
run: ./contrib/test.sh
2125
- name: Running address sanitizer
2226
env:
2327
DO_ASAN: true

contrib/test.sh

+9
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ if [ "$DO_ASAN" = true ]; then
8888
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
8989
fi
9090

91+
# Run formatter if told to.
92+
if [ "$DO_FMT" = true ]; then
93+
if [ "$NIGHTLY" = false ]; then
94+
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
95+
exit 1
96+
fi
97+
rustup component add rustfmt
98+
cargo fmt --check || exit 1
99+
fi
91100

92101
# Bench if told to, only works with non-stable toolchain (nightly, beta).
93102
if [ "$DO_BENCH" = true ]

0 commit comments

Comments
 (0)