Skip to content

Commit 4e35e9d

Browse files
Add cargo deny on CI (sigp#8580)
Closes: - sigp#8408 Add `cargo deny` on CI with deprecated crates (`ethers` and `ethereum-types`) banned and duplicates banned for `reqwest`. Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
1 parent 4c268bc commit 4e35e9d

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.github/workflows/test-suite.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ jobs:
324324
channel: stable
325325
cache-target: release
326326
components: rustfmt,clippy
327-
bins: cargo-audit
327+
bins: cargo-audit,cargo-deny
328328
- name: Check formatting with cargo fmt
329329
run: make cargo-fmt
330330
- name: Lint code for quality and style with Clippy
@@ -337,6 +337,8 @@ jobs:
337337
run: make arbitrary-fuzz
338338
- name: Run cargo audit
339339
run: make audit-CI
340+
- name: Run cargo deny
341+
run: make deny-CI
340342
- name: Run cargo vendor to make sure dependencies can be vendored for packaging, reproducibility and archival purpose
341343
run: CARGO_HOME=$(readlink -f $HOME) make vendor
342344
- name: Markdown-linter

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,15 @@ install-audit:
326326
audit-CI:
327327
cargo audit
328328

329+
# Runs cargo deny (check for banned crates, duplicate versions, and source restrictions)
330+
deny: install-deny deny-CI
331+
332+
install-deny:
333+
cargo install --force cargo-deny --version 0.18.2
334+
335+
deny-CI:
336+
cargo deny check bans sources --hide-inclusion-graph
337+
329338
# Runs `cargo vendor` to make sure dependencies can be vendored for packaging, reproducibility and archival purpose.
330339
vendor:
331340
cargo vendor

deny.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# cargo-deny configuration for Lighthouse
2+
# See https://embarkstudios.github.io/cargo-deny/
3+
4+
[bans]
5+
# Warn when multiple versions of the same crate are detected
6+
multiple-versions = "warn"
7+
deny = [
8+
# Legacy Ethereum crates that have been replaced with alloy
9+
{ crate = "ethers", reason = "use alloy instead" },
10+
{ crate = "ethereum-types", reason = "use alloy-primitives instead" },
11+
# Replaced by quick-protobuf
12+
{ crate = "protobuf", reason = "use quick-protobuf instead" },
13+
# Prevent duplicate versions of reqwest - heavy crate with build scripts
14+
{ crate = "reqwest", deny-multiple-versions = true, reason = "prevent duplicate versions" },
15+
]
16+
17+
[sources]
18+
unknown-registry = "deny"
19+
unknown-git = "warn"
20+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
21+
22+
[sources.allow-org]
23+
github = ["sigp"]

0 commit comments

Comments
 (0)