fix(deps): Remove unused dependencies, and check for them in CI (#6216)

* Remove unused dependencies

* Check for newly unused dependencies in CI

* Use the correct grep command

* Always show cargo machete output

* Ignore cargo machete exit status, use grep instead

* Use if instead of && and subshells

* Invert if logic
This commit is contained in:
teor 2023-02-27 09:42:36 +10:00 committed by GitHub
parent 9d2b912840
commit 98c634bbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 27 deletions

View File

@ -60,3 +60,10 @@ jobs:
steps:
- run: 'echo "No build required"'
unused-deps:
name: Check for unused dependencies
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'

View File

@ -279,3 +279,40 @@ jobs:
with:
command: check ${{ matrix.checks }}
arguments: --workspace ${{ matrix.features }}
unused-deps:
name: Check for unused dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v3.3.0
with:
persist-credentials: false
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install cargo-machete
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-machete
- name: Check unused dependencies
# Exclude macro and transitive dependencies by filtering them out of the output,
# then if there are any more unused dependencies, fail the job.
run: |
echo "-- full cargo machete output, including ignored dependencies --"
cargo machete --skip-target-dir || true
echo "-- unused dependencies are below this line, full output is above --"
if (cargo machete --skip-target-dir 2>/dev/null || true) | \
grep -v -e gumdrop -e humantime-serde -e tinyvec -e "found the following" -e Cargo.toml -e Done; then
echo "New unused dependencies were found, please remove them!"
exit 1
else
echo "No unused dependencies found."
fi

17
Cargo.lock generated
View File

@ -297,12 +297,6 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b"
[[package]]
name = "bech32"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445"
[[package]]
name = "bellman"
version = "0.13.1"
@ -5278,7 +5272,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804268e702b664fc09d3e2ce82786d0addf4ae57ba6976469be63e09066bf9f7"
dependencies = [
"bech32 0.8.1",
"bech32",
"bs58",
"f4jumble",
"zcash_encoding",
@ -5436,13 +5430,10 @@ dependencies = [
name = "zebra-chain"
version = "1.0.0-beta.21"
dependencies = [
"aes",
"bech32 0.9.1",
"bitflags",
"bitvec",
"blake2b_simd",
"blake2s_simd",
"bls12_381",
"bs58",
"byteorder",
"chrono",
@ -5478,7 +5469,6 @@ dependencies = [
"sha2",
"spandoc",
"static_assertions",
"subtle",
"thiserror",
"tinyvec",
"tokio",
@ -5506,7 +5496,6 @@ dependencies = [
"bls12_381",
"chrono",
"color-eyre",
"dirs",
"displaydoc",
"futures",
"futures-util",
@ -5599,7 +5588,6 @@ dependencies = [
"jsonrpc-http-server",
"num_cpus",
"proptest",
"proptest-derive",
"rand 0.8.5",
"serde",
"serde_json",
@ -5607,7 +5595,6 @@ dependencies = [
"tokio",
"tower",
"tracing",
"tracing-futures",
"zcash_address",
"zebra-chain",
"zebra-consensus",
@ -5639,7 +5626,6 @@ dependencies = [
"chrono",
"color-eyre",
"dirs",
"displaydoc",
"futures",
"halo2_proofs",
"hex",
@ -5726,7 +5712,6 @@ dependencies = [
"futures",
"gumdrop",
"hex",
"humantime",
"humantime-serde",
"hyper",
"indexmap",

View File

@ -33,13 +33,10 @@ bench = ["zebra-test"]
[dependencies]
# Cryptography
aes = "0.7.5"
bech32 = "0.9.1"
bitvec = "1.0.1"
bitflags = "1.3.2"
blake2b_simd = "1.0.1"
blake2s_simd = "1.0.1"
bls12_381 = "0.7.0"
bs58 = { version = "0.4.0", features = ["check"] }
byteorder = "1.4.3"
equihash = "0.2.0"
@ -53,7 +50,6 @@ ripemd = "0.1.3"
# Matches version used by hdwallet
secp256k1 = { version = "0.21.3", features = ["serde"] }
sha2 = { version = "0.9.9", features = ["compress"] }
subtle = "2.4.1"
uint = "0.9.5"
x25519-dalek = { version = "2.0.0-pre.1", features = ["serde"] }

View File

@ -30,7 +30,6 @@ rand = { version = "0.8.5", package = "rand" }
rayon = "1.6.1"
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
dirs = "4.0.0"
displaydoc = "0.2.3"
lazy_static = "1.4.0"
once_cell = "1.17.1"

View File

@ -25,7 +25,6 @@ getblocktemplate-rpcs = [
# Test-only features
proptest-impl = [
"proptest",
"proptest-derive",
"zebra-consensus/proptest-impl",
"zebra-state/proptest-impl",
"zebra-network/proptest-impl",
@ -52,7 +51,6 @@ tokio = { version = "1.25.0", features = ["time", "rt-multi-thread", "macros", "
tower = "0.4.13"
tracing = "0.1.37"
tracing-futures = "0.2.5"
hex = { version = "0.4.3", features = ["serde"] }
serde = { version = "1.0.152", features = ["serde_derive"] }
@ -64,7 +62,6 @@ zcash_address = { version = "0.2.0", optional = true }
# Test-only feature proptest-impl
proptest = { version = "0.10.1", optional = true }
proptest-derive = { version = "0.3.0", optional = true }
zebra-chain = { path = "../zebra-chain" }
zebra-consensus = { path = "../zebra-consensus" }
@ -77,7 +74,6 @@ zebra-state = { path = "../zebra-state" }
insta = { version = "1.28.0", features = ["redactions", "json", "ron"] }
proptest = "0.10.1"
proptest-derive = "0.3.0"
thiserror = "1.0.38"
tokio = { version = "1.25.0", features = ["full", "tracing", "test-util"] }

View File

@ -26,7 +26,6 @@ proptest-impl = [
bincode = "1.3.3"
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
dirs = "4.0.0"
displaydoc = "0.2.3"
futures = "0.3.26"
hex = "0.4.3"
indexmap = "1.9.2"

View File

@ -101,7 +101,6 @@ zebra-state = { path = "../zebra-state" }
abscissa_core = "0.5"
gumdrop = { version = "0.7", features = ["default_expr"]}
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
humantime = "2.1.0"
humantime-serde = "1.1.1"
indexmap = "1.9.2"
lazy_static = "1.4.0"