From 3c6b41738748e8d47a208ae74ecdcc89c3f8b20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 19 Jan 2025 13:51:41 +0100 Subject: [PATCH] Add rustfmt to CI --- .github/workflows/rust.yml | 3 +++ .rustfmt.toml | 2 ++ .rustfmt_nightly.toml | 6 ++++++ justfile | 11 +++++++++++ 4 files changed, 22 insertions(+) create mode 100644 .rustfmt.toml create mode 100644 .rustfmt_nightly.toml create mode 100644 justfile diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 987609cc..38bac425 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,6 +24,9 @@ jobs: toolchain: ${{ matrix.rust }} components: clippy cache: true + - if: matrix.rust == 'stable' + run: cargo fmt -- --check + # test project with default + extra features - if: matrix.rust == 'stable' || matrix.rust == 'beta' run: cargo test --features image,ndarray,sop-class,rle,cli,jpegxl diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 00000000..68e6a267 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,2 @@ +newline_style = "Unix" +max_width = 100 \ No newline at end of file diff --git a/.rustfmt_nightly.toml b/.rustfmt_nightly.toml new file mode 100644 index 00000000..ea96b99e --- /dev/null +++ b/.rustfmt_nightly.toml @@ -0,0 +1,6 @@ +newline_style = "Unix" +max_width = 100 + +# Enable only with nightly channel via - cargo +nightly fmt +imports_granularity = "Crate" +group_imports = "StdExternalCrate" \ No newline at end of file diff --git a/justfile b/justfile new file mode 100644 index 00000000..ed030eab --- /dev/null +++ b/justfile @@ -0,0 +1,11 @@ +check: + cargo fmt -- --check + cargo clippy + +fix: + cargo fmt + cargo clippy --fix --allow-dirty --allow-staged + +fix_nightly: + cargo +nightly fmt -- --config-path .rustfmt_nightly.toml + #cargo +nightly clippy --fix --allow-dirty --allow-staged # To enable, after running format on nightly \ No newline at end of file