Skip to content

Commit

Permalink
fix(deps): Remove unused dependencies, and check for them in CI (#6216)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
teor2345 authored Feb 26, 2023
1 parent 9d2b912 commit 98c634b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 27 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/continous-integration-os.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
37 changes: 37 additions & 0 deletions .github/workflows/continous-integration-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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 changes: 1 addition & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"] }

Expand Down
1 change: 0 additions & 1 deletion zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions zebra-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"] }
Expand All @@ -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" }
Expand All @@ -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"] }
Expand Down
1 change: 0 additions & 1 deletion zebra-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 98c634b

Please sign in to comment.