ci: use workspace inheritance to enforce lints in all crates

Starting with nightly-2023-09-10, the `[lints]` section in `Cargo.toml` files is stable. Together with workspace inheritance, this can be used to declare all lints we want to enforce in a single place.

Resolves: #4484.

Pull-Request: #4575.
This commit is contained in:
Binston Sukhael Cardoza
2023-10-09 07:50:46 +05:30
committed by GitHub
parent 35b8308817
commit 0e9d339bd2
67 changed files with 246 additions and 48 deletions

View File

@ -1,3 +0,0 @@
[alias]
# Temporary solution to have clippy config in a single place until https://github.com/rust-lang/rust-clippy/blob/master/doc/roadmap-2021.md#lintstoml-configuration is shipped.
custom-clippy = "clippy --workspace --all-features --all-targets -- -A clippy::type_complexity -A clippy::pedantic -W clippy::used_underscore_binding -W unreachable_pub"

View File

@ -200,8 +200,9 @@ jobs:
fail-fast: false
matrix:
rust-version: [
1.72.0, # current stable
beta
# 1.72.0, # current stable
# beta,
nightly-2023-09-10
]
steps:
- uses: actions/checkout@v4
@ -218,7 +219,7 @@ jobs:
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Run cargo clippy
run: cargo custom-clippy # cargo alias to allow reuse of config locally
run: cargo clippy
ipfs-integration-test:
name: IPFS Integration tests

View File

@ -128,3 +128,9 @@ multihash = "0.19.1"
# we import via `rust-multiaddr`.
# This is expected to stay here until we move `libp2p-identity` to a separate repository which makes the dependency relationship more obvious.
libp2p-identity = { path = "identity" }
[workspace.lints]
rust.unreachable_pub = "warn"
clippy.used_underscore_binding = "warn"
clippy.pedantic = "allow"
clippy.type_complexity = "allow"

View File

@ -50,3 +50,6 @@ serde = ["multihash/serde-codec", "dep:serde", "libp2p-identity/serde"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -11,3 +11,6 @@ clap = { version = "4.3.23", features = ["derive"] }
env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] }
[lints]
workspace = true

View File

@ -38,3 +38,6 @@ wasm-bindgen = "0.2.84"
wasm-bindgen-futures = "0.4.37"
wasm-logger = { version = "0.2.0" }
web-sys = { version = "0.3", features = ['Document', 'Element', 'HtmlElement', 'Node', 'Response', 'Window'] }
[lints]
workspace = true

View File

@ -11,3 +11,6 @@ async-trait = "0.1"
env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] }
[lints]
workspace = true

View File

@ -12,3 +12,6 @@ futures = "0.3.28"
futures-timer = "3.0"
libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] }
log = "0.4"
[lints]
workspace = true

View File

@ -11,3 +11,6 @@ async-trait = "0.1"
env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "websocket", "yamux"] }
[lints]
workspace = true

View File

@ -14,3 +14,6 @@ env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "async-std", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] }
void = "1.0.2"
[lints]
workspace = true

View File

@ -11,3 +11,6 @@ async-trait = "0.1"
env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] }
[lints]
workspace = true

View File

@ -11,3 +11,6 @@ async-trait = "0.1"
env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "websocket", "yamux", "rsa"] }
[lints]
workspace = true

View File

@ -12,3 +12,6 @@ either = "1.9"
env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] }
[lints]
workspace = true

View File

@ -13,3 +13,6 @@ libp2p = { path = "../../libp2p", features = ["async-std", "metrics", "ping", "n
log = "0.4.20"
tokio = { version = "1", features = ["rt-multi-thread"] }
prometheus-client = "0.21.2"
[lints]
workspace = true

View File

@ -10,3 +10,6 @@ env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] }
tokio = { version = "1.32.0", features = ["full"] }
[lints]
workspace = true

View File

@ -12,3 +12,6 @@ async-trait = "0.1"
env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] }
[lints]
workspace = true

View File

@ -13,3 +13,6 @@ futures = "0.3.28"
libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] }
log = "0.4"
tokio = { version = "1.32", features = ["rt-multi-thread", "macros", "time"] }
[lints]
workspace = true

View File

@ -9,3 +9,6 @@ license = "MIT"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "websocket", "yamux", "upnp"] }
[lints]
workspace = true

View File

@ -57,3 +57,6 @@ harness = false
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -23,7 +23,9 @@ libp2p = { path = "../libp2p", features = ["ping", "noise", "tls", "rsa", "macro
libp2p-webrtc = { workspace = true, features = ["tokio"] }
libp2p-mplex = { path = "../muxers/mplex" }
mime_guess = "2.0"
redis = { version = "0.23.3", default-features = false, features = ["tokio-comp"] }
redis = { version = "0.23.3", default-features = false, features = [
"tokio-comp",
] }
rust-embed = "8.0"
serde_json = "1"
thirtyfour = "=0.32.0-rc.8" # https://github.com/stevepryde/thirtyfour/issues/169
@ -42,3 +44,6 @@ instant = "0.1.12"
reqwest = { version = "0.11", features = ["json"] }
console_error_panic_hook = { version = "0.1.7" }
futures-timer = "3.0.2"
[lints]
workspace = true

View File

@ -50,10 +50,10 @@ full = [
"websocket",
"webtransport-websys",
"yamux",
"upnp"
"upnp",
]
async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std", "libp2p-quic?/async-std"]
async-std = [ "libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std", "libp2p-quic?/async-std",]
autonat = ["dep:libp2p-autonat"]
cbor = ["libp2p-request-response?/cbor"]
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
@ -85,7 +85,7 @@ tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = [ "libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
wasm-bindgen = [ "futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen",]
wasm-ext = ["dep:libp2p-wasm-ext"]
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
websocket = ["dep:libp2p-websocket"]
@ -155,3 +155,6 @@ libp2p-tcp = { workspace = true, features = ["tokio"] }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -19,3 +19,6 @@ void = "1"
async-std = { version = "1.12.0", features = ["attributes"] }
libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }
[lints]
workspace = true

View File

@ -23,3 +23,6 @@ libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }
quickcheck = { workspace = true }
rand = "0.8.5"
[lints]
workspace = true

View File

@ -18,3 +18,6 @@ futures-timer = "3.0.2"
[dev-dependencies]
tokio = { version = "1.29.1", features = ["macros", "rt"] }
[lints]
workspace = true

View File

@ -17,3 +17,6 @@ serde_json = "1.0.107"
libp2p-core = { workspace = true }
base64 = "0.21.4"
libp2p-identity = { workspace = true }
[lints]
workspace = true

View File

@ -24,3 +24,6 @@ libp2p-identify = { workspace = true }
libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }
rand = "0.8.5"
[lints]
workspace = true

View File

@ -38,3 +38,6 @@ prometheus-client = { version = "0.21.2"}
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -32,3 +32,6 @@ rw-stream-sink = { workspace = true }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -23,3 +23,6 @@ quick-protobuf = "0.8"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -8,3 +8,6 @@ license = "Unlicense/MIT"
[dependencies]
quickcheck = "1"
num-traits = "0.2"
[lints]
workspace = true

View File

@ -24,3 +24,6 @@ async-std = "1.0"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -25,3 +25,6 @@ serde_derive = "1.0.125"
serde_json = "1.0"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
zeroize = "1"
[lints]
workspace = true

View File

@ -30,3 +30,6 @@ asynchronous-codec = "0.6"
[dev-dependencies]
hex-literal = "0.4"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
[lints]
workspace = true

View File

@ -43,3 +43,6 @@ harness = false
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -13,3 +13,6 @@ futures = "0.3.28"
log = "0.4"
futures-timer = "3.0.2"
futures_ringbuf = "0.4.0"
[lints]
workspace = true

View File

@ -27,3 +27,6 @@ libp2p-muxer-test-harness = { path = "../test-harness" }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -34,3 +34,6 @@ libp2p-swarm-test = { path = "../../swarm-test" }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -47,3 +47,6 @@ rand = "0.8"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -31,3 +31,6 @@ thiserror = "1.0.49"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -58,3 +58,6 @@ quickcheck = { workspace = true }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -39,3 +39,6 @@ libp2p-swarm = { workspace = true, features = ["macros"] }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -54,3 +54,6 @@ serde = ["dep:serde", "bytes/serde"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -55,3 +55,6 @@ required-features = ["tokio"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -43,3 +43,6 @@ libp2p-swarm-test = { path = "../../swarm-test" }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -35,3 +35,6 @@ quickcheck = { workspace = true }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -43,3 +43,6 @@ quickcheck = { workspace = true }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -46,3 +46,6 @@ libp2p-swarm-test = { path = "../../swarm-test" }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -46,3 +46,6 @@ serde = { version = "1.0", features = ["derive"]}
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -22,3 +22,6 @@ tokio = { version = "1.29", default-features = false, features = ["rt"], optiona
[features]
tokio = ["igd-next/aio_tokio", "dep:tokio"]
[lints]
workspace = true

View File

@ -26,3 +26,6 @@ proc-macro2 = "1.0"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -23,3 +23,6 @@ futures = "0.3.28"
log = "0.4.20"
rand = "0.8.5"
futures-timer = "3.0.2"
[lints]
workspace = true

View File

@ -67,3 +67,6 @@ required-features = ["macros"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -28,3 +28,6 @@ futures_ringbuf = "0.4.0"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -41,3 +41,6 @@ tokio-dns-over-https-rustls = ["tokio", "trust-dns-resolver/dns-over-https-rustl
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -43,3 +43,6 @@ quickcheck = { workspace = true }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -33,3 +33,6 @@ futures_ringbuf = "0.4.0"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -35,3 +35,6 @@ tokio = { version = "1.32.0", features = ["full"] }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -51,3 +51,6 @@ tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread", "time"] }
[[test]]
name = "stream_compliance"
required-features = ["async-std"]
[lints]
workspace = true

View File

@ -38,3 +38,6 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -41,3 +41,6 @@ tokio = { version = "1.32.0", features = ["full"] }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -26,3 +26,6 @@ tempfile = "3.8"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -27,3 +27,6 @@ websocket = []
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -34,3 +34,6 @@ web-sys = { version = "0.3.64", features = ["Document", "Location", "MessageEven
hex-literal = "0.4"
libp2p-ping = { workspace = true }
libp2p-swarm = { workspace = true, features = ["wasm-bindgen"] }
[lints]
workspace = true

View File

@ -45,3 +45,6 @@ quickcheck = "1.0.3"
[[test]]
name = "smoke"
required-features = ["tokio"]
[lints]
workspace = true

View File

@ -36,3 +36,6 @@ rcgen = "0.10.0"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -46,3 +46,6 @@ multibase = "0.9.1"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]
[lints]
workspace = true

View File

@ -18,3 +18,6 @@ wasm-bindgen = "0.2.87"
wasm-bindgen-futures = "0.4.37"
wasm-bindgen-test = "0.3.37"
web-sys = { version = "0.3.64", features = ["Response", "Window"] }
[lints]
workspace = true