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

fix ci for use with RUSTFLAGS #69

Closed
wants to merge 11 commits into from
Closed
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
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
build:
strategy:
matrix:
features:
- "async-std-executor,channel-async-std,logging-utils"
- "async-std-executor,channel-flume,logging-utils"
- "tokio-executor,channel-tokio,logging-utils"
- "tokio-executor,channel-flume,logging-utils"
flags:
- --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\"
- --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"flume\"
- --cfg async_executor_impl=\"tokio\" --cfg async_channel_impl=\"tokio\"
- --cfg async_executor_impl=\"tokio\" --cfg async_channel_impl=\"flume\"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand All @@ -37,12 +37,12 @@ jobs:

- name: Build
run: |
cargo build --all-targets --workspace --features "${{ matrix.features }}" --release
RUSTFLAGS="${{ matrix.flags }}" cargo build --all-targets --workspace --release --features="logging-utils"

- name: Test
run: |
cargo test --release --all-targets --workspace --features "${{ matrix.features }}"
RUSTFLAGS="${{ matrix.flags }}" cargo test --all-targets --workspace --release --features="logging-utils"

- name: Lint
run: |
cargo clippy --workspace --all-targets --features "${{ matrix.features }}" --bins --tests --examples -- -D warnings
RUSTFLAGS="${{ matrix.flags }}" cargo clippy --workspace --all-targets --bins --tests --examples --features="logging-utils" -- -D warnings
17 changes: 9 additions & 8 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
build:
strategy:
matrix:
features:
- "async-std-executor,channel-async-std,logging-utils"
- "async-std-executor,channel-flume,logging-utils"
- "tokio-executor,channel-tokio,logging-utils"
- "tokio-executor,channel-flume,logging-utils"
flags:
- --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\"
- --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"flume\"
- --cfg async_executor_impl=\"tokio\" --cfg async_channel_impl=\"tokio\"
- --cfg async_executor_impl=\"tokio\" --cfg async_channel_impl=\"flume\"
runs-on: ubuntu-latest
timeout-minutes: 60
if: ${{ github.actor != 'dependabot[bot]' }}
Expand All @@ -36,12 +36,13 @@ jobs:

- name: Build
run: |
nix develop -c cargo build --all-targets --workspace --features "${{ matrix.features }}" --release
nix develop -c RUSTFLAGS="${{ matrix.flags }}" cargo build --all-targets --workspace --release --features="logging-utils"

- name: Test
run: |
nix develop -c cargo test --release --all-targets --workspace --features "${{ matrix.features }}"
nix develop -c RUSTFLAGS="${{ matrix.flags }}" cargo test --all-targets --workspace --release --features="logging-utils"

- name: Lint
run: |
nix develop -c cargo clippy --workspace --all-targets --features "${{ matrix.features }}" --bins --tests --examples -- -D warnings
nix develop -c RUSTFLAGS="${{ matrix.flags }}" cargo clippy --all-targets --workspace --release --bins --tests --examples --features="logging-utils" -- -D warnings

61 changes: 30 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ opentelemetry-jaeger = { version = "0.17.0", features = [
opentelemetry-aws = { version = "0.8.0", features = ["trace"], optional = true }

[target.'cfg(all(async_executor_impl = "tokio"))'.dependencies]
console-subscriber = { version = "0.1.10" }
tokio = { version = "1", features = [
"fs",
"io-util",
Expand All @@ -64,7 +65,6 @@ async-std = { version = "1.12", features = [
]}

[target.'cfg(all(async_channel_impl = "tokio"))'.dependencies]
console-subscriber = { version = "0.1.10" }
tokio = { version = "1", features = [
"fs",
"io-util",
Expand Down
4 changes: 2 additions & 2 deletions src/async_primitives/subscribable_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use futures::{stream::FuturesOrdered, Future, FutureExt};
use std::{fmt, time::Duration};
use tracing::warn;

#[cfg(all(async_executor_impl = "async-std"))]
#[cfg(async_executor_impl = "async-std")]
use async_std::prelude::StreamExt;
#[cfg(all(async_executor_impl = "tokio"))]
#[cfg(async_executor_impl = "tokio")]
use tokio_stream::StreamExt;
#[cfg(not(any(async_executor_impl = "async-std", async_executor_impl = "tokio")))]
std::compile_error! {"The cfg flag async_executor_impl must be set in rustflags to either \"async-std\" or \"tokio\" for this crate. Try adding `--cfg async_executor_impl=\"tokio\""}
Expand Down
26 changes: 13 additions & 13 deletions src/channel/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::pin::Pin;
use futures::Stream;

/// inner module, used to group feature-specific imports
#[cfg(all(async_channel_impl = "tokio"))]
#[cfg(async_channel_impl = "tokio")]
mod inner {
pub use tokio::sync::mpsc::error::{SendError, TryRecvError};

Expand Down Expand Up @@ -45,7 +45,7 @@ mod inner {
}

/// inner module, used to group feature-specific imports
#[cfg(all(async_channel_impl = "flume"))]
#[cfg(async_channel_impl = "flume")]
mod inner {
pub use flume::{RecvError, SendError, TryRecvError};

Expand Down Expand Up @@ -75,7 +75,7 @@ mod inner {
}

/// inner module, used to group feature-specific imports
#[cfg(all(async_channel_impl = "async-std"))]
#[cfg(async_channel_impl = "async-std")]
mod inner {
pub use async_channel::{RecvError, SendError, TryRecvError};

Expand Down Expand Up @@ -114,7 +114,7 @@ impl<T> Sender<T> {
///
/// Will return an error if the receiver is dropped
pub async fn send(&self, msg: T) -> Result<(), SendError<T>> {
#[cfg(all(async_channel_impl = "flume"))]
#[cfg(async_channel_impl = "flume")]
let result = self.0.send_async(msg).await;
#[cfg(not(all(async_channel_impl = "flume")))]
let result = self.0.send(msg).await;
Expand All @@ -130,11 +130,11 @@ impl<T> Receiver<T> {
///
/// Will return an error if the sender is dropped
pub async fn recv(&mut self) -> Result<T, RecvError> {
#[cfg(all(async_channel_impl = "flume"))]
#[cfg(async_channel_impl = "flume")]
let result = self.0.recv_async().await;
#[cfg(all(async_channel_impl = "tokio"))]
#[cfg(async_channel_impl = "tokio")]
let result = self.0.recv().await.ok_or(RecvError);
#[cfg(all(async_channel_impl = "async-std"))]
#[cfg(async_channel_impl = "async-std")]
let result = self.0.recv().await;

result
Expand All @@ -144,11 +144,11 @@ impl<T> Receiver<T> {
where
T: 'static,
{
#[cfg(all(async_channel_impl = "async-std"))]
#[cfg(async_channel_impl = "async-std")]
let result = self.0;
#[cfg(all(async_channel_impl = "tokio"))]
#[cfg(async_channel_impl = "tokio")]
let result = tokio_stream::wrappers::ReceiverStream::new(self.0);
#[cfg(all(async_channel_impl = "flume"))]
#[cfg(async_channel_impl = "flume")]
let result = self.0.into_stream();

BoundedStream(result)
Expand Down Expand Up @@ -219,14 +219,14 @@ impl<T> Stream for BoundedStream<T> {
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
#[cfg(all(async_channel_impl = "flume"))]
#[cfg(async_channel_impl = "flume")]
return <flume::r#async::RecvStream<T>>::poll_next(Pin::new(&mut self.0), cx);
#[cfg(all(async_channel_impl = "tokio"))]
#[cfg(async_channel_impl = "tokio")]
return <tokio_stream::wrappers::ReceiverStream<T> as Stream>::poll_next(
Pin::new(&mut self.0),
cx,
);
#[cfg(all(async_channel_impl = "async-std"))]
#[cfg(async_channel_impl = "async-std")]
return <async_channel::Receiver<T> as Stream>::poll_next(Pin::new(&mut self.0), cx);
}
}
Expand Down
Loading