From 4fbf5a4eccb47a0db1f383e90223eb73f7a1602a Mon Sep 17 00:00:00 2001 From: hrmny <8845940+ForsakenHarmony@users.noreply.github.com> Date: Wed, 24 Apr 2024 23:55:50 +0200 Subject: [PATCH] chore: fix clippy error and add generic CI check --- .github/workflows/test.yml | 25 +++++++++++++++++++ .../src/aggregation/tests.rs | 9 +++---- .../turborepo-filewatch/src/hash_watcher.rs | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2274e9a53aa1d..e5f6bf05cfc5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -455,6 +455,31 @@ jobs: with: command: check licenses + rust_clippy: + needs: [determine_jobs] + if: needs.determine_jobs.outputs.rust == 'true' || + needs.determine_jobs.outputs.cargo_on_main == 'true' || + needs.determine_jobs.outputs.cargo_only == 'true' + name: Rust clippy + runs-on: + - "self-hosted" + - "linux" + - "x64" + - "metal" + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Turborepo Environment + uses: ./.github/actions/setup-turborepo-environment + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Run cargo clippy + run: | + cargo clippy --workspace --all-targets --features rustls-tls \ + -- --deny clippy::all --deny warnings --allow clippy::too_many_arguments + turborepo_rust_check: needs: [determine_jobs] # We test dependency changes only on main diff --git a/crates/turbo-tasks-memory/src/aggregation/tests.rs b/crates/turbo-tasks-memory/src/aggregation/tests.rs index bd6d5c2c821ad..c12e1e6864cf3 100644 --- a/crates/turbo-tasks-memory/src/aggregation/tests.rs +++ b/crates/turbo-tasks-memory/src/aggregation/tests.rs @@ -39,10 +39,7 @@ fn find_root(mut node: NodeRef) -> NodeRef { } } -fn check_invariants<'a>( - ctx: &NodeAggregationContext<'a>, - node_ids: impl IntoIterator, -) { +fn check_invariants(ctx: &NodeAggregationContext, node_ids: impl IntoIterator) { let mut queue = node_ids.into_iter().collect::>(); // print(ctx, &queue[0], true); let mut visited = HashSet::new(); @@ -100,7 +97,7 @@ fn check_invariants<'a>( } // All followers should also be connected to all uppers - let missing_uppers = uppers.iter().filter(|&upper_id| { + let mut missing_uppers = uppers.iter().filter(|&upper_id| { if follower_uppers .iter() .any(|follower_upper_id| follower_upper_id == upper_id) @@ -116,7 +113,7 @@ fn check_invariants<'a>( false } }); - for missing_upper in missing_uppers { + if let Some(missing_upper) = missing_uppers.next() { let upper_value = { let upper = ctx.node(missing_upper); upper.guard.value diff --git a/crates/turborepo-filewatch/src/hash_watcher.rs b/crates/turborepo-filewatch/src/hash_watcher.rs index 7578cdf0b28b6..6cbad0b2384bc 100644 --- a/crates/turborepo-filewatch/src/hash_watcher.rs +++ b/crates/turborepo-filewatch/src/hash_watcher.rs @@ -801,7 +801,7 @@ mod tests { .unwrap(); repo.branch("test-branch", ¤t_commit, false).unwrap(); repo.set_head("refs/heads/test-branch").unwrap(); - commit_all(&repo); + commit_all(repo); } #[tokio::test]