Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add checks for zenoh crate alone #1131

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,27 @@ jobs:
- name: Code format check
run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate"

- name: Clippy
- name: Clippy zenoh no-default-features
run: cargo +stable clippy -p zenoh --all-targets --no-default-features -- --deny warnings

- name: Clippy zenoh
run: cargo +stable clippy -p zenoh --all-targets -- --deny warnings

- name: Clippy zenoh unstable
run: cargo +stable clippy -p zenoh --all-targets --features unstable -- --deny warnings

- name: Clippy zenoh internal
run: cargo +stable clippy -p zenoh --all-targets --features unstable,internal -- --deny warnings

- name: Clippy zenoh shared-memory
run: cargo +stable clippy -p zenoh --all-targets --features unstable,shared-memory -- --deny warnings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add a check on --all-features.


- name: Clippy workspace
run: cargo +stable clippy --all-targets -- --deny warnings

- name: Clippy unstable targets
- name: Clippy workspace unstable
run: cargo +stable clippy --all-targets --features unstable -- --deny warnings

- name: Clippy shared memory without unstable
run: cargo +stable clippy --all-targets --features shared-memory -- --deny warnings

- name: Clippy all features
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest' }}
run: cargo +stable clippy --all-targets --all-features -- --deny warnings
Expand Down
4 changes: 2 additions & 2 deletions ci/valgrind-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ categories = ["network-programming"]
description = "Internal crate for zenoh."

[dependencies]
tokio = { version = "1.35.1", features = ["rt-multi-thread", "time", "io-std"] }
tokio = { version = "1.35.1", features = ["rt-multi-thread", "time", "io-std"] }
tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
futures = "0.3.25"
zenoh = { path = "../../zenoh/", features = ["unstable"] }
zenoh = { path = "../../zenoh/" }
zenoh-runtime = { path = "../../commons/zenoh-runtime/" }
zenoh-util = { path = "../../commons/zenoh-util/", features = ["test"] }

Expand Down
4 changes: 2 additions & 2 deletions ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn main() {
let queryable_key_expr = queryable_key_expr.clone();
zenoh_runtime::ZRuntime::Application.block_in_place(async move {
query
.reply(queryable_key_expr, query.value().unwrap().payload().clone())
.reply(queryable_key_expr, query.payload().unwrap().clone())
.await
.unwrap();
});
Expand All @@ -51,7 +51,7 @@ async fn main() {
println!("Sending Query '{get_selector}'...");
let replies = get_session
.get(&get_selector)
.value(idx)
.payload(idx)
.target(QueryTarget::All)
.await
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions zenoh/src/api/builders/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ impl<'a, 'b> PublisherBuilder<'a, 'b> {
priority: self.priority,
is_express: self.is_express,
destination: self.destination,
#[cfg(feature = "unstable")]
matching_listeners: Default::default(),
undeclare_on_drop: true,
})
Expand Down Expand Up @@ -346,6 +347,7 @@ impl<'a, 'b> Wait for PublisherBuilder<'a, 'b> {
priority: self.priority,
is_express: self.is_express,
destination: self.destination,
#[cfg(feature = "unstable")]
matching_listeners: Default::default(),
undeclare_on_drop: true,
})
Expand Down
22 changes: 15 additions & 7 deletions zenoh/src/api/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,32 @@
//

use std::{
collections::HashSet,
convert::TryFrom,
fmt,
future::{IntoFuture, Ready},
pin::Pin,
sync::{Arc, Mutex},
task::{Context, Poll},
};

use futures::Sink;
#[zenoh_macros::unstable]
use zenoh_config::wrappers::EntityGlobalId;
use zenoh_core::{zread, Resolvable, Resolve, Wait};
use zenoh_protocol::{
core::CongestionControl,
network::{push::ext, Push},
zenoh::{Del, PushBody, Put},
};
use zenoh_result::{Error, ZResult};
#[zenoh_macros::unstable]
#[cfg(feature = "unstable")]
use {
crate::api::handlers::{Callback, DefaultHandler, IntoHandler},
crate::api::sample::SourceInfo,
crate::api::{
handlers::{Callback, DefaultHandler, IntoHandler},
sample::SourceInfo,
},
std::{
collections::HashSet,
sync::{Arc, Mutex},
},
zenoh_config::wrappers::EntityGlobalId,
zenoh_protocol::core::EntityGlobalIdProto,
};

Expand Down Expand Up @@ -137,6 +140,7 @@ pub struct Publisher<'a> {
pub(crate) priority: Priority,
pub(crate) is_express: bool,
pub(crate) destination: Locality,
#[cfg(feature = "unstable")]
pub(crate) matching_listeners: Arc<Mutex<HashSet<Id>>>,
pub(crate) undeclare_on_drop: bool,
}
Expand Down Expand Up @@ -350,6 +354,7 @@ impl<'a> Publisher<'a> {
Undeclarable::undeclare_inner(self, ())
}

#[cfg(feature = "unstable")]
fn undeclare_matching_listeners(&self) -> ZResult<()> {
let ids: Vec<Id> = zlock!(self.matching_listeners).drain().collect();
for id in ids {
Expand Down Expand Up @@ -479,6 +484,7 @@ impl Wait for PublisherUndeclaration<'_> {
fn wait(mut self) -> <Self as Resolvable>::To {
// set the flag first to avoid double panic if this function panic
self.publisher.undeclare_on_drop = false;
#[cfg(feature = "unstable")]
self.publisher.undeclare_matching_listeners()?;
self.publisher
.session
Expand All @@ -498,6 +504,7 @@ impl IntoFuture for PublisherUndeclaration<'_> {
impl Drop for Publisher<'_> {
fn drop(&mut self) {
if self.undeclare_on_drop {
#[cfg(feature = "unstable")]
let _ = self.undeclare_matching_listeners();
let _ = self.session.undeclare_publisher_inner(self.id);
}
Expand Down Expand Up @@ -1102,6 +1109,7 @@ mod tests {

use crate::api::{sample::SampleKind, session::SessionDeclarations};

#[cfg(feature = "internal")]
#[test]
fn priority_from() {
use std::convert::TryInto;
Expand Down
1 change: 1 addition & 0 deletions zenoh/src/api/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ impl<'a> From<KeyExpr<'a>> for Selector<'a> {
}
}

#[cfg(feature = "unstable")]
#[test]
fn selector_accessors() {
use crate::api::query::_REPLY_KEY_EXPR_ANY_SEL_PARAM as ANYKE;
Expand Down
10 changes: 4 additions & 6 deletions zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,13 +1665,11 @@ impl Session {
tracing::trace!("get({}, {:?}, {:?})", selector, target, consolidation);
let mut state = zwrite!(self.state);
let consolidation = match consolidation.mode {
ConsolidationMode::Auto => {
if selector.parameters().contains_key(TIME_RANGE_KEY) {
ConsolidationMode::None
} else {
ConsolidationMode::Latest
}
#[cfg(feature = "unstable")]
ConsolidationMode::Auto if selector.parameters().contains_key(TIME_RANGE_KEY) => {
ConsolidationMode::None
}
ConsolidationMode::Auto => ConsolidationMode::Latest,
mode => mode,
};
let qid = state.qid_counter.fetch_add(1, Ordering::SeqCst);
Expand Down
1 change: 1 addition & 0 deletions zenoh/src/net/routing/hat/client/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ impl HatPubSubTrait for HatCode {
get_routes_entries()
}

#[zenoh_macros::unstable]
fn get_matching_subscriptions(
&self,
tables: &Tables,
Expand Down
24 changes: 12 additions & 12 deletions zenoh/src/net/routing/hat/linkstate_peer/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ use super::{
face_hat, face_hat_mut, get_peer, get_routes_entries, hat, hat_mut, network::Network, res_hat,
res_hat_mut, HatCode, HatContext, HatFace, HatTables,
};
use crate::{
key_expr::KeyExpr,
net::routing::{
dispatcher::{
face::FaceState,
pubsub::*,
resource::{NodeId, Resource, SessionContext},
tables::{Route, RoutingExpr, Tables},
},
hat::{CurrentFutureTrait, HatPubSubTrait, Sources},
router::RoutesIndexes,
RoutingContext, PREFIX_LIVELINESS,
#[cfg(feature = "unstable")]
use crate::key_expr::KeyExpr;
use crate::net::routing::{
dispatcher::{
face::FaceState,
pubsub::*,
resource::{NodeId, Resource, SessionContext},
tables::{Route, RoutingExpr, Tables},
},
hat::{CurrentFutureTrait, HatPubSubTrait, Sources},
router::RoutesIndexes,
RoutingContext, PREFIX_LIVELINESS,
};

#[inline]
Expand Down Expand Up @@ -913,6 +912,7 @@ impl HatPubSubTrait for HatCode {
get_routes_entries(tables)
}

#[zenoh_macros::unstable]
fn get_matching_subscriptions(
&self,
tables: &Tables,
Expand Down
7 changes: 5 additions & 2 deletions zenoh/src/net/routing/hat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! This module is intended for Zenoh's internal use.
//!
//! [Click here for Zenoh's documentation](../zenoh/index.html)
use std::{any::Any, collections::HashMap, sync::Arc};
use std::{any::Any, sync::Arc};

use zenoh_buffers::ZBuf;
use zenoh_config::{unwrap_or_default, Config, WhatAmI};
Expand All @@ -34,6 +34,8 @@ use zenoh_protocol::{
};
use zenoh_result::ZResult;
use zenoh_transport::unicast::TransportUnicast;
#[cfg(feature = "unstable")]
use {crate::key_expr::KeyExpr, std::collections::HashMap};

use super::{
dispatcher::{
Expand All @@ -42,7 +44,7 @@ use super::{
},
router::RoutesIndexes,
};
use crate::{key_expr::KeyExpr, net::runtime::Runtime};
use crate::net::runtime::Runtime;

mod client;
mod linkstate_peer;
Expand Down Expand Up @@ -180,6 +182,7 @@ pub(crate) trait HatPubSubTrait {

fn get_data_routes_entries(&self, tables: &Tables) -> RoutesIndexes;

#[zenoh_macros::unstable]
fn get_matching_subscriptions(
&self,
tables: &Tables,
Expand Down
1 change: 1 addition & 0 deletions zenoh/src/net/routing/hat/p2p_peer/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ impl HatPubSubTrait for HatCode {
get_routes_entries()
}

#[zenoh_macros::unstable]
fn get_matching_subscriptions(
&self,
tables: &Tables,
Expand Down
24 changes: 12 additions & 12 deletions zenoh/src/net/routing/hat/router/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ use super::{
face_hat, face_hat_mut, get_peer, get_router, get_routes_entries, hat, hat_mut,
network::Network, res_hat, res_hat_mut, HatCode, HatContext, HatFace, HatTables,
};
use crate::{
key_expr::KeyExpr,
net::routing::{
dispatcher::{
face::FaceState,
pubsub::*,
resource::{NodeId, Resource, SessionContext},
tables::{Route, RoutingExpr, Tables},
},
hat::{CurrentFutureTrait, HatPubSubTrait, Sources},
router::RoutesIndexes,
RoutingContext, PREFIX_LIVELINESS,
#[cfg(feature = "unstable")]
use crate::key_expr::KeyExpr;
use crate::net::routing::{
dispatcher::{
face::FaceState,
pubsub::*,
resource::{NodeId, Resource, SessionContext},
tables::{Route, RoutingExpr, Tables},
},
hat::{CurrentFutureTrait, HatPubSubTrait, Sources},
router::RoutesIndexes,
RoutingContext, PREFIX_LIVELINESS,
};

#[inline]
Expand Down Expand Up @@ -1252,6 +1251,7 @@ impl HatPubSubTrait for HatCode {
get_routes_entries(tables)
}

#[zenoh_macros::unstable]
fn get_matching_subscriptions(
&self,
tables: &Tables,
Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ mod test {
use zenoh::{
config,
config::{EndPoint, WhatAmI},
internal::{zlock, ztimeout},
prelude::*,
Config, Session,
};
use zenoh_core::{zlock, ztimeout};

const TIMEOUT: Duration = Duration::from_secs(60);
const SLEEP: Duration = Duration::from_secs(1);
Expand Down
4 changes: 3 additions & 1 deletion zenoh/tests/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
//
use std::time::Duration;

use zenoh::{config, internal::ztimeout, prelude::*, query::Reply, sample::SampleKind, Session};
use zenoh::{config, query::Reply, sample::SampleKind, Session};
use zenoh_core::ztimeout;

const TIMEOUT: Duration = Duration::from_secs(10);

Expand All @@ -39,6 +40,7 @@ async fn close_session(session: Session) {

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn zenoh_events() {
use zenoh::prelude::SessionDeclarations;
let session = open_session(&["tcp/127.0.0.1:18447"], &[]).await;
let zid = session.zid();
let sub1 =
Expand Down
1 change: 1 addition & 0 deletions zenoh/tests/formatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//
#![cfg(feature = "unstable")]
use zenoh::key_expr::format::{kedefine, keformat};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion zenoh/tests/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use std::time::Duration;

use zenoh::{
config,
internal::ztimeout,
prelude::*,
sample::{Sample, SampleKind},
};
use zenoh_core::ztimeout;

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn zenoh_liveliness() {
Expand Down
3 changes: 2 additions & 1 deletion zenoh/tests/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use std::{str::FromStr, time::Duration};

use flume::RecvTimeoutError;
use zenoh::{config, config::Locator, internal::ztimeout, prelude::*, sample::Locality, Session};
use zenoh::{config, config::Locator, prelude::*, sample::Locality, Session};
use zenoh_core::ztimeout;

const TIMEOUT: Duration = Duration::from_secs(60);
const RECV_TIMEOUT: Duration = Duration::from_secs(1);
Expand Down
1 change: 1 addition & 0 deletions zenoh/tests/open_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//
#![allow(unused)]
use std::{
future::IntoFuture,
time::{Duration, Instant},
Expand Down
3 changes: 2 additions & 1 deletion zenoh/tests/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
//
use std::time::Duration;

use zenoh::{core::Priority, internal::ztimeout, prelude::*, publisher::CongestionControl};
use zenoh::{core::Priority, prelude::*, publisher::CongestionControl};
use zenoh_core::ztimeout;

const TIMEOUT: Duration = Duration::from_secs(60);
const SLEEP: Duration = Duration::from_secs(1);
Expand Down
Loading