Enable formatting in CI

Enable formatting in CI by doing:

- Add a section to the `test.sh` scripts to run the formatter (guarded by
  the env variable `DO_FMT`) for all crates (bitcoin, hashes, internals).
- Add `DO_FMT` to the nightly `Tests` CI job.
This commit is contained in:
Tobin C. Harding 2022-09-30 11:56:12 +10:00
parent 61c560baba
commit c1360067e9
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
4 changed files with 31 additions and 0 deletions

View File

@ -53,6 +53,7 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
- name: Running test script
env:
DO_FMT: true
DO_BENCH: true
AS_DEPENDENCY: false
DO_NO_STD: true

View File

@ -111,6 +111,16 @@ then
)
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
fi
# Bench if told to, only works with non-stable toolchain (nightly, beta).
if [ "$DO_BENCH" = true ]
then

View File

@ -89,6 +89,16 @@ if [ "$DO_ASAN" = true ]; then
cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
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
fi
# Bench if told to, only works with non-stable toolchain (nightly, beta).
if [ "$DO_BENCH" = true ]
then

View File

@ -52,3 +52,13 @@ fi
if [ "$DO_DOCS" = true ]; then
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
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
fi