From 5983b91a4fbfaa0c062677434874be97f24b33ad Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 18 Sep 2024 00:24:42 -0400 Subject: [PATCH] ci: add a rustfmt and clippy job Signed-off-by: Henry Schreiner --- .github/workflows/check.yml | 10 ++++++++++ rust/src/helpers/array.rs | 4 +--- rust/src/project.rs | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index efa982c..43f6e79 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -82,3 +82,13 @@ jobs: run: tox run --skip-pkg-install -e ${{ matrix.env }} env: PYTEST_ADDOPTS: "-vv --durations=20" + + rust-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 + - name: Lint + run: cargo clippy --all-targets -- -D warnings diff --git a/rust/src/helpers/array.rs b/rust/src/helpers/array.rs index 6dd880e..c6696f3 100644 --- a/rust/src/helpers/array.rs +++ b/rust/src/helpers/array.rs @@ -37,9 +37,7 @@ where .filter(|x| *x == COMMA || *x == VALUE) .last() == Some(COMMA); - let multiline = array_node - .children_with_tokens() - .any(|e| e.kind() == NEWLINE); + let multiline = array_node.children_with_tokens().any(|e| e.kind() == NEWLINE); let mut value_set = Vec::>::new(); let entry_set = RefCell::new(Vec::::new()); let mut key_to_pos = HashMap::::new(); diff --git a/rust/src/project.rs b/rust/src/project.rs index 44c4ac0..b5015dc 100644 --- a/rust/src/project.rs +++ b/rust/src/project.rs @@ -55,7 +55,9 @@ pub fn fix( } "dependencies" | "optional-dependencies" => { transform(entry, &|s| format_requirement(s, keep_full_version)); - sort(entry, |e| get_canonic_requirement_name(e).to_lowercase() + " " + &format_requirement(e, keep_full_version)); + sort(entry, |e| { + get_canonic_requirement_name(e).to_lowercase() + " " + &format_requirement(e, keep_full_version) + }); } "dynamic" | "keywords" => { transform(entry, &|s| String::from(s));