fix(ci): ensure all examples compile with the specified feature-set

Due to cargo's feature unification, a full build of our workspace doesn't actually check whether the examples compile as standalone projects.

We add a new CI check that iterates through all crates in the `examples/` directory and runs a plain `cargo check` on them. Any failure is bubbled up via `set -e`, thus failing CI in case one of the `cargo check` commands fails.

To fix the current failures, we construct a simple TCP transport everywhere where we were previously using `development_transport`. That is because `development_transport` requires `mplex` which is now deprecated.

Related #3657.
Related #3809.

Pull-Request: #3811.
This commit is contained in:
Thomas Eizinger
2023-04-21 11:58:08 +02:00
committed by GitHub
parent 0fe9791829
commit 28da3d4180
16 changed files with 60 additions and 21 deletions

View File

@ -14,11 +14,13 @@ use libp2p::{
record::store::MemoryStore, GetProvidersOk, Kademlia, KademliaEvent, QueryId, QueryResult,
},
multiaddr::Protocol,
noise,
request_response::{self, ProtocolSupport, RequestId, ResponseChannel},
swarm::{ConnectionHandlerUpgrErr, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent},
PeerId,
tcp, yamux, PeerId, Transport,
};
use libp2p::core::upgrade::Version;
use std::collections::{hash_map, HashMap, HashSet};
use std::error::Error;
use std::iter;
@ -45,10 +47,16 @@ pub async fn new(
};
let peer_id = id_keys.public().to_peer_id();
let transport = tcp::async_io::Transport::default()
.upgrade(Version::V1Lazy)
.authenticate(noise::NoiseAuthenticated::xx(&id_keys)?)
.multiplex(yamux::YamuxConfig::default())
.boxed();
// Build the Swarm, connecting the lower layer transport logic with the
// higher layer network behaviour logic.
let swarm = SwarmBuilder::with_async_std_executor(
libp2p::development_transport(id_keys).await?,
transport,
ComposedBehaviour {
kademlia: Kademlia::new(peer_id, MemoryStore::new(peer_id)),
request_response: request_response::Behaviour::new(