From 58adca25033cde749d4a4614035b5b45c581fa6c Mon Sep 17 00:00:00 2001 From: meliurwen Date: Sat, 30 Jul 2022 16:27:55 +0200 Subject: [PATCH 1/2] Added `rustfmt` in GH Workflow, added `rustfmt.toml` and updated `README.md` --- .github/workflows/build.yml | 7 ++++++- README.md | 8 ++++++++ rustfmt.toml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 rustfmt.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25ecf35..b94d480 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,12 +21,17 @@ jobs: with: profile: minimal toolchain: stable - components: clippy + components: clippy, fmt - name: Linting (clippy) uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} args: --all-targets -- -D warnings -A clippy::all -W clippy::correctness + - name: Formatting (rustfmt) + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check --verbose - name: Tests (test) uses: actions-rs/cargo@v1 with: diff --git a/README.md b/README.md index b114188..f928955 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,11 @@ Or with `clippy`: ```sh cargo clippy --all-targets -- -A clippy::all -W clippy::correctness ``` + +To check the **formatting**: + +> **NOTE:** remove `--check` to apply the changes to the file(s). + +```sh +cargo fmt --all -- --check +``` diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..3e7fb50 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,36 @@ +# This file defines the Rust style for automatic reformatting. +# See also https://rust-lang.github.io/rustfmt + +# NOTE: the unstable options will be uncommented when stabilized. + +# Version of the formatting rules to use. +#version = "One" + +# Number of spaces per tab. +tab_spaces = 4 + +max_width = 100 +#comment_width = 80 + +# Prevent carriage returns, admitted only \n. +newline_style = "Unix" + +# The "Default" setting has a heuristic which can split lines too aggresively. +#use_small_heuristics = "Max" + +# How imports should be grouped into `use` statements. +#imports_granularity = "Module" + +# How consecutive imports are grouped together. +#group_imports = "StdExternalCrate" + +# Error if unable to get all lines within max_width, except for comments and +# string literals. +#error_on_line_overflow = true + +# Error if unable to get comments or string literals within max_width, or they +# are left with trailing whitespaces. +#error_on_unformatted = true + +# Files to ignore like third party code which is formatted upstream. +#ignore = [] -- 2.36.3 From d5058e9ed255934279a90066cde8572c9d1bbec5 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Sat, 30 Jul 2022 16:36:27 +0200 Subject: [PATCH 2/2] Fixed malformed `rustfmt` component name in GH Workflows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b94d480..bc5c583 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: with: profile: minimal toolchain: stable - components: clippy, fmt + components: clippy, rustfmt - name: Linting (clippy) uses: actions-rs/clippy-check@v1 with: -- 2.36.3