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.
This commit is contained in:
Tobin C. Harding 2022-11-22 08:54:24 +11:00
parent c7807dff9c
commit 0516ddeb8d
2 changed files with 13 additions and 0 deletions

View File

@ -18,6 +18,10 @@ jobs:
toolchain: nightly toolchain: nightly
override: true override: true
components: rust-src components: rust-src
- name: Check formatting
env:
DO_FMT: true
run: ./contrib/test.sh
- name: Running address sanitizer - name: Running address sanitizer
env: env:
DO_ASAN: true DO_ASAN: true

View File

@ -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" cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
fi 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). # Bench if told to, only works with non-stable toolchain (nightly, beta).
if [ "$DO_BENCH" = true ] if [ "$DO_BENCH" = true ]