From 80c7969fb3c81ebfe316d4934f6e3822c9a9467d Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 12 Jul 2024 15:26:51 +0300 Subject: [PATCH] ci: Use cargo-machete to check for unused dependencies (#1974) * ci: Use cargo-machete to check for unused dependencies And remove the ones it found. * --with-metadata has false positives * Remove --no-fallback --------- Signed-off-by: Lars Eggert --- .github/actions/rust/action.yml | 5 +++-- .github/workflows/check.yml | 5 +++++ neqo-bin/Cargo.toml | 2 -- neqo-common/Cargo.toml | 1 - neqo-http3/Cargo.toml | 1 - neqo-qpack/Cargo.toml | 4 +++- neqo-udp/Cargo.toml | 3 +++ test-fixture/Cargo.toml | 4 +++- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/actions/rust/action.yml b/.github/actions/rust/action.yml index 23cdbaa6f6..7de55dbae4 100644 --- a/.github/actions/rust/action.yml +++ b/.github/actions/rust/action.yml @@ -25,8 +25,9 @@ runs: - name: Install Rust tools shell: bash run: | - cargo +${{ inputs.version }} quickinstall --no-binstall --no-fallback \ - cargo-llvm-cov cargo-nextest flamegraph cargo-hack cargo-mutants hyperfine cargo-fuzz + cargo +${{ inputs.version }} quickinstall --no-binstall \ + cargo-llvm-cov cargo-nextest flamegraph cargo-hack cargo-mutants hyperfine \ + cargo-machete cargo-fuzz # sccache slows CI down, so we leave it disabled. # Leaving the steps below commented out, so we can re-evaluate enabling it later. diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e12493427b..bf0e67b755 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -136,6 +136,11 @@ jobs: cargo +${{ matrix.rust-toolchain }} fmt --all -- --check $CONFIG_PATH if: success() || failure() + - name: Check for unused dependencies + run: | + # --with-metadata has false positives, see https://github.com/bnjbvr/cargo-machete/issues/127 + cargo +${{ matrix.rust-toolchain }} machete + - name: Clippy run: | # Use cargo-hack to run clippy on each crate individually with its diff --git a/neqo-bin/Cargo.toml b/neqo-bin/Cargo.toml index 9e336f4fed..b8351d8b94 100644 --- a/neqo-bin/Cargo.toml +++ b/neqo-bin/Cargo.toml @@ -35,11 +35,9 @@ log = { workspace = true } neqo-common = { path = "./../neqo-common" } neqo-crypto = { path = "./../neqo-crypto" } neqo-http3 = { path = "./../neqo-http3" } -neqo-qpack = { path = "./../neqo-qpack" } neqo-transport = { path = "./../neqo-transport" } neqo-udp = { path = "./../neqo-udp", default-features = false, features = ["tokio"] } qlog = { workspace = true } -quinn-udp = { version = "0.5.0", default-features = false } regex = { version = "1.9", default-features = false, features = ["unicode-perl"] } tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] } url = { version = "2.5", default-features = false } diff --git a/neqo-common/Cargo.toml b/neqo-common/Cargo.toml index dec3f41bdc..2832bd2521 100644 --- a/neqo-common/Cargo.toml +++ b/neqo-common/Cargo.toml @@ -25,7 +25,6 @@ qlog = { workspace = true } time = { version = "0.3", default-features = false, features = ["formatting"] } [dev-dependencies] -criterion = { version = "0.5", default-features = false, features = ["html_reports"] } test-fixture = { path = "../test-fixture" } [features] diff --git a/neqo-http3/Cargo.toml b/neqo-http3/Cargo.toml index bc9e3225ee..0055cbf326 100644 --- a/neqo-http3/Cargo.toml +++ b/neqo-http3/Cargo.toml @@ -25,7 +25,6 @@ neqo-qpack = { path = "./../neqo-qpack" } neqo-transport = { path = "./../neqo-transport" } qlog = { workspace = true } sfv = { version = "0.9", default-features = false } -smallvec = { version = "1.11", default-features = false } url = { version = "2.5", default-features = false } [dev-dependencies] diff --git a/neqo-qpack/Cargo.toml b/neqo-qpack/Cargo.toml index 74fe823e4b..b2de1ed6c4 100644 --- a/neqo-qpack/Cargo.toml +++ b/neqo-qpack/Cargo.toml @@ -19,7 +19,6 @@ workspace = true # Sync with https://searchfox.org/mozilla-central/source/Cargo.lock 2024-02-08 log = { workspace = true } neqo-common = { path = "./../neqo-common" } -neqo-crypto = { path = "./../neqo-crypto" } neqo-transport = { path = "./../neqo-transport" } qlog = { workspace = true } static_assertions = { version = "1.1", default-features = false } @@ -27,6 +26,9 @@ static_assertions = { version = "1.1", default-features = false } [dev-dependencies] test-fixture = { path = "../test-fixture" } +[package.metadata.cargo-machete] +ignored = ["log"] + [lib] # See https://github.com/bheisler/criterion.rs/blob/master/book/src/faq.md#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options bench = false diff --git a/neqo-udp/Cargo.toml b/neqo-udp/Cargo.toml index b604912cb9..230822e103 100644 --- a/neqo-udp/Cargo.toml +++ b/neqo-udp/Cargo.toml @@ -24,6 +24,9 @@ tokio = { version = "1", default-features = false, features = ["net"], optional [dev-dependencies] tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] } +[package.metadata.cargo-machete] +ignored = ["log"] + [lib] # See https://github.com/bheisler/criterion.rs/blob/master/book/src/faq.md#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options bench = false diff --git a/test-fixture/Cargo.toml b/test-fixture/Cargo.toml index 498f8b8dfb..862a9d3130 100644 --- a/test-fixture/Cargo.toml +++ b/test-fixture/Cargo.toml @@ -21,7 +21,6 @@ log = { workspace = true } neqo-common = { path = "../neqo-common" } neqo-crypto = { path = "../neqo-crypto" } neqo-http3 = { path = "../neqo-http3" } -neqo-qpack = { path = "../neqo-qpack" } neqo-transport = { path = "../neqo-transport" } qlog = { workspace = true } @@ -29,6 +28,9 @@ qlog = { workspace = true } bench = [] disable-random = [] +[package.metadata.cargo-machete] +ignored = ["log"] + [lib] # See https://github.com/bheisler/criterion.rs/blob/master/book/src/faq.md#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options bench = false