Skip to content

Commit

Permalink
.github/workflows: Refactor CI jobs (libp2p#3090)
Browse files Browse the repository at this point in the history
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 libp2p#2951.
  • Loading branch information
thomaseizinger authored Nov 18, 2022
1 parent 4b5f4e2 commit b55364f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "Elena Frank <[email protected]>"]
Expand Down
4 changes: 2 additions & 2 deletions src/behaviour/as_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/behaviour/as_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit b55364f

Please sign in to comment.