Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

ci: test on windows targets #682

Merged
merged 6 commits into from
Dec 13, 2021
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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,52 @@ jobs:
run: |
export PATH=$HOME/bin:$PATH
./scripts/examples.sh

windows-build:
Copy link
Owner

Choose a reason for hiding this comment

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

Might be worth putting this in a different workflow file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

windows.yml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but I'm a little hesitant to move this out, perhaps we can leverage all the geth, ganach stuff and unify everything in a matrix build with all vars etc, like I've attempted here foundry-rs/foundry#218

runs-on: windows-latest
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
env:
CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
strategy:
fail-fast: false
matrix:
target: [
i686-pc-windows-gnu,
i686-pc-windows-msvc,
x86_64-pc-windows-gnu,
x86_64-pc-windows-msvc,
]
cfg_release_channel: [nightly]

steps:
- name: checkout
uses: actions/checkout@v2

# Run build
- name: Install Rustup using win.rustup.rs
run: |
# disable download progress bar
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
del rustup-init.exe
rustup target add ${{ matrix.target }}
shell: powershell

- name: Add mingw32 to path for i686-gnu
run: |
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
if: matrix.target == 'i686-pc-windows-gnu' && matrix.channel == 'nightly'
shell: bash

- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
shell: bash

- name: build
run: |
rustc -Vv
cargo -V
cargo check --all-features
shell: cmd
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ ethers-etherscan = { version = "^0.2.0", default-features = false, path = "./eth

[dev-dependencies]
ethers-contract = { version = "^0.6.0", default-features = false, path = "./ethers-contract", features = ["abigen", "eip712"] }
ethers-providers = { version = "^0.6.0", default-features = false, path = "./ethers-providers", features = ["ws"] }

[target.'cfg(target_family = "unix")'.dev-dependencies]
ethers-providers = { version = "^0.6.0", default-features = false, path = "./ethers-providers", features = ["ws", "ipc"] }


anyhow = "1.0.39"
rand = "0.8.4"
serde = { version = "1.0.124", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion ethers-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tokio = { version = "1.5", default-features = false, features = ["rt", "macros"]
tempfile = "3.2.0"

[features]
default = ["ws", "ipc", "rustls"]
default = ["ws", "rustls"]
celo = ["ethers-core/celo"]
ws = ["tokio", "tokio-tungstenite"]
ipc = ["tokio", "tokio/io-util", "tokio-util", "bytes"]
Expand Down
3 changes: 1 addition & 2 deletions ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,7 @@ impl Provider<crate::Ws> {
}
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "ipc")]
#[cfg(all(target_family = "unix", feature = "ipc"))]
impl Provider<crate::Ipc> {
/// Direct connection to an IPC socket.
pub async fn connect_ipc(path: impl AsRef<std::path::Path>) -> Result<Self, ProviderError> {
Expand Down
67 changes: 20 additions & 47 deletions ethers-providers/src/transports/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ use futures_channel::mpsc;
use futures_util::stream::{Fuse, StreamExt};
use oneshot::error::RecvError;
use serde::{de::DeserializeOwned, Serialize};
use std::sync::atomic::Ordering;
use std::{
collections::HashMap,
path::Path,
sync::{atomic::AtomicU64, Arc},
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};
use thiserror::Error;
use tokio::{
Expand All @@ -37,18 +39,9 @@ type Subscription = mpsc::UnboundedSender<serde_json::Value>;

#[derive(Debug)]
enum TransportMessage {
Request {
id: u64,
request: String,
sender: Pending,
},
Subscribe {
id: U256,
sink: Subscription,
},
Unsubscribe {
id: U256,
},
Request { id: u64, request: String, sender: Pending },
Subscribe { id: U256, sink: Subscription },
Unsubscribe { id: U256 },
}

impl Ipc {
Expand Down Expand Up @@ -112,10 +105,7 @@ impl PubsubClient for Ipc {

fn subscribe<T: Into<U256>>(&self, id: T) -> Result<Self::NotificationStream, IpcError> {
let (sink, stream) = mpsc::unbounded();
self.send(TransportMessage::Subscribe {
id: id.into(),
sink,
})?;
self.send(TransportMessage::Subscribe { id: id.into(), sink })?;
Ok(stream)
}

Expand Down Expand Up @@ -157,12 +147,9 @@ where
let f = async move {
let mut read_buffer = Vec::new();
loop {
let closed = self
.process(&mut read_buffer)
.await
.expect("WS Server panic");
let closed = self.process(&mut read_buffer).await.expect("WS Server panic");
if closed && self.pending.is_empty() {
break;
break
}
}
};
Expand Down Expand Up @@ -197,11 +184,7 @@ where

async fn handle_request(&mut self, msg: TransportMessage) -> Result<(), IpcError> {
match msg {
TransportMessage::Request {
id,
request,
sender,
} => {
TransportMessage::Request { id, request, sender } => {
if self.pending.insert(id, sender).is_some() {
warn!("Replacing a pending request with id {:?}", id);
}
Expand All @@ -218,10 +201,7 @@ where
}
TransportMessage::Unsubscribe { id } => {
if self.subscriptions.remove(&id).is_none() {
warn!(
"Unsubscribing from non-existent subscription with id {:?}",
id
);
warn!("Unsubscribing from non-existent subscription with id {:?}", id);
}
}
};
Expand Down Expand Up @@ -287,7 +267,8 @@ where
}

/// Sends JSON response through the channel based on the ID in that response.
/// This handles RPC calls with only one response, and the channel entry is dropped after sending.
/// This handles RPC calls with only one response, and the channel entry is dropped after
/// sending.
fn respond(&mut self, output: Response<serde_json::Value>) -> Result<(), IpcError> {
let id = output.id;

Expand Down Expand Up @@ -338,7 +319,10 @@ impl From<IpcError> for ProviderError {
#[cfg(not(feature = "celo"))]
mod test {
use super::*;
use ethers_core::{utils::Geth, types::{Block, TxHash, U256}};
use ethers_core::{
types::{Block, TxHash, U256},
utils::Geth,
};
use tempfile::NamedTempFile;

#[tokio::test]
Expand Down Expand Up @@ -366,25 +350,14 @@ mod test {

// Subscribing requires sending the sub request and then subscribing to
// the returned sub_id
let block_num: u64 = ipc
.request::<_, U256>("eth_blockNumber", ())
.await
.unwrap()
.as_u64();
let block_num: u64 = ipc.request::<_, U256>("eth_blockNumber", ()).await.unwrap().as_u64();
let mut blocks = Vec::new();
for _ in 0..3 {
let item = stream.next().await.unwrap();
let block = serde_json::from_value::<Block<TxHash>>(item).unwrap();
blocks.push(block.number.unwrap_or_default().as_u64());
}
let offset = blocks[0] - block_num;
assert_eq!(
blocks,
&[
block_num + offset,
block_num + offset + 1,
block_num + offset + 2
]
)
assert_eq!(blocks, &[block_num + offset, block_num + offset + 1, block_num + offset + 2])
}
}
10 changes: 4 additions & 6 deletions ethers-providers/src/transports/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ macro_rules! if_not_wasm {
)*}
}

if_not_wasm! {
#[cfg(feature = "ipc")]
mod ipc;
#[cfg(feature = "ipc")]
pub use ipc::Ipc;
}
#[cfg(all(target_family = "unix", feature = "ipc"))]
mod ipc;
#[cfg(all(target_family = "unix", feature = "ipc"))]
pub use ipc::Ipc;

mod http;
pub use http::{ClientError as HttpClientError, Provider as Http};
Expand Down