From b55364f3a219b7f63f3de5cfed4ca04a94ef0e92 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 18 Nov 2022 22:04:16 +1100 Subject: [PATCH] .github/workflows: Refactor CI jobs (#3090) We refactor our continuous integration workflow with the following goals in mind: - Run as few jobs as possible - Have the jobs finish as fast as possible - Have the jobs redo as little work as possible There are only so many jobs that GitHub Actions will run in parallel. Thus, it makes sense to not create massive matrices but instead group things together meaningfully. The new `test` job will: - Run once for each crate - Ensure that the crate compiles on its specified MSRV - Ensure that the tests pass - Ensure that there are no semver violations This is an improvement to before because we are running all of these in parallel which speeds up execution and highlights more errors at once. Previously, tests run later in the pipeline would not get run at all until you make sure the "first" one passes. We also previously did not verify the MSRV of each crate, making the setting in the `Cargo.toml` rather pointless. The new `cross` job supersedes the existing `wasm` job. This is an improvement because we now also compile the crate for windows and MacOS. Something that wasn't checked before. We assume that checking MSRV and the tests under Linux is good enough. Hence, this job only checks for compile-errors. The new `feature_matrix` ensures we compile correctly with certain feature combinations. `libp2p` exposes a fair few feature-flags. Some of the combinations are worth checking independently. For the moment, this concerns only the executor related transports together with the executor flags but this list can easily be extended. The new `clippy` job runs for `stable` and `beta` rust. Clippy gets continuously extended with new lints. Up until now, we would only learn about those as soon as a new version of Rust is released and CI would run the new lints. This leads to unrelated failures in CI. Running clippy on with `beta` Rust gives us a heads-up of 6 weeks before these lints land on stable. Fixes #2951. --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- src/behaviour/as_client.rs | 4 ++-- src/behaviour/as_server.rs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac7af065ba8..d98a65cb9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,10 @@ - Replace `Behaviour`'s `NetworkBehaviour` implemention `inject_*` methods with the new `on_*` methods. See [PR 3011]. +- Update `rust-version` to reflect the actual MSRV: 1.62.0. See [PR 3090]. + [PR 3011]: https://github.com/libp2p/rust-libp2p/pull/3011 +[PR 3090]: https://github.com/libp2p/rust-libp2p/pull/3090 # 0.8.0 diff --git a/Cargo.toml b/Cargo.toml index 10fd0e71ff5..80bbb54fcbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-autonat" edition = "2021" -rust-version = "1.56.1" +rust-version = "1.62.0" description = "NAT and firewall detection for libp2p" version = "0.9.0" authors = ["David Craven ", "Elena Frank "] diff --git a/src/behaviour/as_client.rs b/src/behaviour/as_client.rs index 5a5e18b6531..cbb63f6aa95 100644 --- a/src/behaviour/as_client.rs +++ b/src/behaviour/as_client.rs @@ -150,7 +150,7 @@ impl<'a> HandleInnerEvent for AsClient<'a> { // Update observed address score if it is finite. let score = params .external_addresses() - .find_map(|r| (r.addr == address).then(|| r.score)) + .find_map(|r| (r.addr == address).then_some(r.score)) .unwrap_or(AddressScore::Finite(0)); if let AddressScore::Finite(finite_score) = score { action = Some(NetworkBehaviourAction::ReportObservedAddr { @@ -266,7 +266,7 @@ impl<'a> AsClient<'a> { // Filter servers for which no qualified address is known. // This is the case if the connection is relayed or the address is // not global (in case of Config::only_global_ips). - addrs.values().any(|a| a.is_some()).then(|| id) + addrs.values().any(|a| a.is_some()).then_some(id) })); } diff --git a/src/behaviour/as_server.rs b/src/behaviour/as_server.rs index 681076b92cb..f858c48ceb7 100644 --- a/src/behaviour/as_server.rs +++ b/src/behaviour/as_server.rs @@ -346,7 +346,7 @@ impl<'a> AsServer<'a> { addr.push(Protocol::P2p(peer.into())) } // Only collect distinct addresses. - distinct.insert(addr.clone()).then(|| addr) + distinct.insert(addr.clone()).then_some(addr) }) .collect() }