diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 833bd6c..d44c005 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,6 +18,10 @@ jobs: toolchain: nightly override: true components: rust-src + - name: Check formatting + env: + DO_FMT: true + run: ./contrib/test.sh - name: Running address sanitizer env: DO_ASAN: true diff --git a/contrib/test.sh b/contrib/test.sh index 8bc9946..1d1a686 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -88,6 +88,15 @@ if [ "$DO_ASAN" = true ]; then cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" fi +# Run formatter if told to. +if [ "$DO_FMT" = true ]; then + if [ "$NIGHTLY" = false ]; then + echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)" + exit 1 + fi + rustup component add rustfmt + cargo fmt --check || exit 1 +fi # Bench if told to, only works with non-stable toolchain (nightly, beta). if [ "$DO_BENCH" = true ]