Skip to content

Commit eff9e70

Browse files
committed
Add wasm32 build to CI
1 parent b17217d commit eff9e70

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

.github/workflows/rust.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,45 @@ jobs:
1313
RUST_BACKTRACE: 1
1414
strategy:
1515
matrix:
16-
build: [linux64, macos, win32, win64]
16+
build: [linux64, macos, win32, win64, wasm32]
1717
include:
1818
- build: linux64
1919
os: ubuntu-latest
2020
channel: stable
21+
toolchain: x86_64-unknown-linux-gnu
2122
target: x86_64-unknown-linux-gnu
2223
#- build: linux32
2324
# os: ubuntu-latest
2425
# channel: stable
26+
# toolchain: i686-unknown-linux-gnu
2527
# target: i686-unknown-linux-gnu
2628
- build: macos
2729
os: macos-latest
2830
channel: stable
31+
toolchain: x86_64-apple-darwin
2932
target: x86_64-apple-darwin
3033
- build: win32
3134
os: windows-latest
3235
channel: stable
36+
toolchain: i686-pc-windows-msvc
3337
target: i686-pc-windows-msvc
3438
- build: win64
3539
os: windows-latest
3640
channel: stable
41+
toolchain: x86_64-pc-windows-msvc
3742
target: x86_64-pc-windows-msvc
43+
- build: wasm32
44+
os: ubuntu-latest
45+
channel: stable
46+
toolchain: x86_64-unknown-linux-gnu
47+
target: wasm32-unknown-unknown
3848
steps:
3949
- uses: actions/checkout@v2
4050
- run: |
41-
TOOLCHAIN=${{ matrix.channel }}-${{ matrix.target }}
51+
TOOLCHAIN=${{ matrix.channel }}-${{ matrix.toolchain }}
4252
rustup toolchain install --no-self-update $TOOLCHAIN
4353
rustup default $TOOLCHAIN
54+
rustup target add ${{ matrix.target }}
4455
shell: bash
4556
- name: Rust version
4657
run: |
@@ -53,6 +64,7 @@ jobs:
5364
- run: cargo check --target ${{ matrix.target }}
5465
- run: cargo build --target ${{ matrix.target }}
5566
- run: cargo test --target ${{ matrix.target }}
67+
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
5668
# FIXME(#41): Some timeout/deadline tests make more sense to run in release mode.
5769
#- run: cargo test --release --target ${{ matrix.target }}
5870
- run: cargo build --all-targets --target ${{ matrix.target }}

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async-std = { version = "1.9.0", features = ["attributes", "unstable"] }
3939
futures = { version = "^0.3", features = ["std"] }
4040
waker-fn = "1.1.0"
4141
tokio = { version = "^1.16.1", features = ["rt", "macros"] }
42+
getrandom = { version = "0.2.15", features = ["js"] }
4243

4344
[[bench]]
4445
name = "basic"

examples/async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(feature = "async")]
1+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
22
#[async_std::main]
33
async fn main() {
44
let (tx, rx) = flume::bounded(1);
@@ -17,5 +17,5 @@ async fn main() {
1717
t.await;
1818
}
1919

20-
#[cfg(not(feature = "async"))]
20+
#[cfg(any(not(feature = "async"), target_os = "unknown"))]
2121
fn main() {}

tests/async.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(feature = "async")]
1+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
22
use {
33
flume::*,
44
futures::{stream::FuturesUnordered, StreamExt, TryFutureExt, Future},
@@ -7,7 +7,7 @@ use {
77
std::{time::Duration, sync::{atomic::{AtomicUsize, Ordering}, Arc}},
88
};
99

10-
#[cfg(feature = "async")]
10+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
1111
#[test]
1212
fn r#async_recv() {
1313
let (tx, rx) = unbounded();
@@ -24,7 +24,7 @@ fn r#async_recv() {
2424
t.join().unwrap();
2525
}
2626

27-
#[cfg(feature = "async")]
27+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
2828
#[test]
2929
fn r#async_send() {
3030
let (tx, rx) = bounded(1);
@@ -41,7 +41,7 @@ fn r#async_send() {
4141
t.join().unwrap();
4242
}
4343

44-
#[cfg(feature = "async")]
44+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
4545
#[test]
4646
fn r#async_recv_disconnect() {
4747
let (tx, rx) = bounded::<i32>(0);
@@ -58,7 +58,7 @@ fn r#async_recv_disconnect() {
5858
t.join().unwrap();
5959
}
6060

61-
#[cfg(feature = "async")]
61+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
6262
#[test]
6363
fn r#async_send_disconnect() {
6464
let (tx, rx) = bounded(0);
@@ -75,7 +75,7 @@ fn r#async_send_disconnect() {
7575
t.join().unwrap();
7676
}
7777

78-
#[cfg(feature = "async")]
78+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
7979
#[test]
8080
fn r#async_recv_drop_recv() {
8181
let (tx, rx) = bounded::<i32>(10);
@@ -103,7 +103,7 @@ fn r#async_recv_drop_recv() {
103103
assert_eq!(t.join().unwrap(), Ok(42))
104104
}
105105

106-
#[cfg(feature = "async")]
106+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
107107
#[async_std::test]
108108
async fn r#async_send_1_million_no_drop_or_reorder() {
109109
#[derive(Debug)]
@@ -137,7 +137,7 @@ async fn r#async_send_1_million_no_drop_or_reorder() {
137137
assert_eq!(count, 1_000_000)
138138
}
139139

140-
#[cfg(feature = "async")]
140+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
141141
#[async_std::test]
142142
async fn parallel_async_receivers() {
143143
let (tx, rx) = flume::unbounded();
@@ -175,7 +175,7 @@ async fn parallel_async_receivers() {
175175
println!("recv end");
176176
}
177177

178-
#[cfg(feature = "async")]
178+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
179179
#[test]
180180
fn change_waker() {
181181
let (tx, rx) = flume::bounded(1);
@@ -246,7 +246,7 @@ fn change_waker() {
246246
}
247247
}
248248

249-
#[cfg(feature = "async")]
249+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
250250
#[test]
251251
fn spsc_single_threaded_value_ordering() {
252252
async fn test() {

tests/stream.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(feature = "async")]
1+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
22
use {
33
flume::*,
44
futures::{stream::FuturesUnordered, StreamExt, TryFutureExt},
@@ -7,7 +7,7 @@ use {
77
};
88
use futures::{stream, Stream};
99

10-
#[cfg(feature = "async")]
10+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
1111
#[test]
1212
fn stream_recv() {
1313
let (tx, rx) = unbounded();
@@ -28,7 +28,7 @@ fn stream_recv() {
2828
t.join().unwrap();
2929
}
3030

31-
#[cfg(feature = "async")]
31+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
3232
#[test]
3333
fn stream_recv_disconnect() {
3434
let (tx, rx) = bounded::<i32>(0);
@@ -48,7 +48,7 @@ fn stream_recv_disconnect() {
4848
t.join().unwrap();
4949
}
5050

51-
#[cfg(feature = "async")]
51+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
5252
#[test]
5353
fn stream_recv_drop_recv() {
5454
let (tx, rx) = bounded::<i32>(10);
@@ -80,7 +80,7 @@ fn stream_recv_drop_recv() {
8080
assert_eq!(t.join().unwrap(), Some(42))
8181
}
8282

83-
#[cfg(feature = "async")]
83+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
8484
#[test]
8585
fn r#stream_drop_send_disconnect() {
8686
let (tx, rx) = bounded::<i32>(1);
@@ -98,7 +98,7 @@ fn r#stream_drop_send_disconnect() {
9898
t.join().unwrap();
9999
}
100100

101-
#[cfg(feature = "async")]
101+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
102102
#[async_std::test]
103103
async fn stream_send_1_million_no_drop_or_reorder() {
104104
#[derive(Debug)]
@@ -133,7 +133,7 @@ async fn stream_send_1_million_no_drop_or_reorder() {
133133
assert_eq!(count, 1_000_000)
134134
}
135135

136-
#[cfg(feature = "async")]
136+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
137137
#[async_std::test]
138138
async fn parallel_streams_and_async_recv() {
139139
let (tx, rx) = flume::unbounded();
@@ -174,7 +174,7 @@ async fn parallel_streams_and_async_recv() {
174174
.unwrap();
175175
}
176176

177-
#[cfg(feature = "async")]
177+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
178178
#[test]
179179
fn stream_no_double_wake() {
180180
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -220,7 +220,7 @@ fn stream_no_double_wake() {
220220
assert_eq!(count.load(Ordering::SeqCst), 1);
221221
}
222222

223-
#[cfg(feature = "async")]
223+
#[cfg(all(feature = "async", not(target_os = "unknown")))]
224224
#[async_std::test]
225225
async fn stream_forward_issue_55() { // https://github.com/zesterer/flume/issues/55
226226
fn dummy_stream() -> impl Stream<Item = usize> {

0 commit comments

Comments
 (0)