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

Commit

Permalink
ci: add more feature tests and checks (#2436)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored May 27, 2023
1 parent a8d5f5f commit d75e324
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 104 deletions.
65 changes: 26 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,32 @@ env:

jobs:
test:
name: test ${{ matrix.os }} (${{ matrix.flags.name }})
name: test ${{ matrix.flags.name }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
flags:
- name: no default features
flags: --workspace --no-default-features
flags: --no-default-features
- name: default features
flags: --workspace
flags: ""
- name: all features
flags: --workspace --all-features
flags: --all-features
include:
# not workspace because compiling examples fails for no reason in CI
- os: windows-latest
- os: ubuntu-latest
flags:
name: no default features
flags: --no-default-features
- os: windows-latest
name: celo feature
flags:
-p ethers-core -p ethers-providers -p ethers-contract --features celo
- os: ubuntu-latest
flags:
name: default features
flags: ""
- os: windows-latest
flags:
name: all features
flags: --all-features
name: optimism feature
flags: -p ethers-core --features optimism
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain:
${{ matrix.os == 'windows-latest' && 'stable-x86_64-pc-windows-gnu' ||
'stable' }}
- name: Install Anvil
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -68,7 +60,7 @@ jobs:
cargo nextest run \
${{ matrix.flags.flags }} \
-E "!(deps(ethers-etherscan) & kind(test))" \
--retries 3
--retries 2
etherscan-tests:
name: etherscan tests
Expand All @@ -82,7 +74,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Don't use cargo-nextest since all the tests have to be ran sequentially
# Don't use cargo-nextest since all the tests have to be run sequentially
- name: live tests
run: cargo test -p ethers-etherscan --test it

Expand All @@ -98,30 +90,26 @@ jobs:
# - name: live tests
# run: cargo test -p ethers-tests --all-features

# TODO: [#2191](https://github.com/gakonst/ethers-rs/issues/2191)
# feature-checks:
# name: feature checks
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@nightly
# - uses: taiki-e/install-action@cargo-hack
# - uses: Swatinem/rust-cache@v2
# - name: cargo hack
# run:
# cargo hack check --all --feature-powerset --depth 2 -Z avoid-dev-deps --keep-going
feature-checks:
name: feature checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- name: cargo hack
run: cargo hack check --feature-powerset --depth 1 --no-dev-deps

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
run: cargo clippy --workspace --tests --all-features
run: cargo clippy --workspace --all-features --all-targets
env:
RUSTFLAGS: "-D warnings"

Expand All @@ -137,7 +125,6 @@ jobs:
- name: doc
run: cargo doc --workspace --all-features --no-deps --document-private-items
env:
RUSTFLAGS: "--cfg docsrs"
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

fmt:
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ exclude = [
# https://docs.rs/about/metadata
[workspace.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

# https://github.com/integer32llc/rust-playground/blob/c6165a36923db5d99313e6056b5b610a2ede5bb0/top-crates/src/lib.rs#L175-L184
Expand All @@ -34,6 +33,8 @@ members = [
"ethers",
"ethers-addressbook",
"ethers-contract",
"ethers-contract/ethers-contract-abigen",
"ethers-contract/ethers-contract-derive",
"ethers-core",
"ethers-etherscan",
"ethers-middleware",
Expand All @@ -50,6 +51,8 @@ default-members = [
"ethers",
"ethers-addressbook",
"ethers-contract",
"ethers-contract/ethers-contract-abigen",
"ethers-contract/ethers-contract-derive",
"ethers-core",
"ethers-etherscan",
"ethers-middleware",
Expand Down
1 change: 0 additions & 1 deletion ethers-addressbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
1 change: 0 additions & 1 deletion ethers-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
1 change: 0 additions & 1 deletion ethers-contract/ethers-contract-abigen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ keywords.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
1 change: 0 additions & 1 deletion ethers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
23 changes: 13 additions & 10 deletions ethers-core/src/types/trace/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ pub mod spoof {

/// Returns an empty state override set.
///
/// # Example
/// # Examples
///
/// ```no_run
/// ```ignore
/// # use ethers_core::{
/// # types::{Address, TransactionRequest, H256, spoof},
/// # utils::{parse_ether, Geth},
Expand Down Expand Up @@ -346,8 +346,9 @@ pub mod spoof {

/// Returns a state override set with a single element setting the balance of the address.
///
/// # Example
/// ```no_run
/// # Examples
///
/// ```ignore
/// # use ethers_core::{
/// # types::{Address, TransactionRequest, H256},
/// # utils::{parse_ether, Geth},
Expand Down Expand Up @@ -378,8 +379,9 @@ pub mod spoof {

/// Returns a state override set with a single element setting the nonce of the address.
///
/// # Example
/// ```no_run
/// # Examples
///
/// ```ignore
/// # use ethers_core::{
/// # types::{Address, TransactionRequest, H256},
/// # utils::{parse_ether, Geth},
Expand Down Expand Up @@ -408,8 +410,9 @@ pub mod spoof {

/// Returns a state override set with a single element setting the code at the address.
///
/// # Example
/// ```no_run
/// # Examples
///
/// ```ignore
/// # use ethers_core::{
/// # types::{Address, TransactionRequest, H256},
/// # utils::{parse_ether, Geth},
Expand Down Expand Up @@ -439,9 +442,9 @@ pub mod spoof {
/// Returns a state override set with a single element setting the storage at the given address
/// and key.
///
/// # Example
/// # Examples
///
/// ```no_run
/// ```ignore
/// # use ethers_core::{
/// # types::{Address, TransactionRequest, H256},
/// # utils::{parse_ether, Geth},
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/types/transaction/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub struct Transaction {
pub chain_id: Option<U256>,

/// Captures unknown fields such as additional fields used by L2s
#[cfg(not(feature = "celo"))]
#[cfg(not(any(feature = "celo", feature = "optimism")))]
#[serde(flatten)]
pub other: crate::types::OtherFields,
}
Expand Down
1 change: 0 additions & 1 deletion ethers-etherscan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
1 change: 0 additions & 1 deletion ethers-middleware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
2 changes: 1 addition & 1 deletion ethers-middleware/tests/it/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async fn can_stack_middlewares() {
for _ in 0..10 {
let pending = provider.send_transaction(tx.clone(), None).await.unwrap();
let hash = *pending;
let gas_price = provider.get_transaction(hash).await.unwrap().unwrap().gas_price;
let _ = provider.get_transaction(hash).await.unwrap().unwrap();
pending_txs.push(pending);
}

Expand Down
1 change: 0 additions & 1 deletion ethers-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
6 changes: 4 additions & 2 deletions ethers-providers/src/ext/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ pub enum EthPeerInfo {
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct EthInfo {
/// The negotiated eth version.
#[serde(default)]
pub version: u64,

/// The total difficulty of the peer's blockchain.
#[serde(deserialize_with = "deserialize_stringified_numeric")]
#[serde(default, deserialize_with = "deserialize_stringified_numeric")]
pub difficulty: U256,

/// The hash of the peer's best known block.
#[serde(default)]
pub head: H256,
}

Expand Down Expand Up @@ -168,7 +170,7 @@ pub struct SnapInfo {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PeerInfo {
/// The peer's ENR.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub enr: Option<Enr<SigningKey>>,

/// The peer's enode URL.
Expand Down
1 change: 0 additions & 1 deletion ethers-signers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
12 changes: 2 additions & 10 deletions ethers-solc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down Expand Up @@ -67,7 +66,7 @@ svm-builds = { package = "svm-rs-builds", version = "0.1", optional = true }
tokio = { workspace = true, features = ["rt-multi-thread"] }

[dev-dependencies]
criterion.workspace = true
criterion = { workspace = true, features = ["async_tokio"] }
env_logger = "0.10.0"
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] }
rand.workspace = true
Expand Down Expand Up @@ -99,14 +98,7 @@ default = ["rustls"]

full = ["async", "svm-solc"]

async = [
"tokio/process",
"tokio/io-util",
"tokio/fs",
"tokio/time",
"futures-util",
"criterion/async_tokio",
]
async = ["tokio/process", "tokio/io-util", "tokio/fs", "tokio/time", "futures-util"]
svm-solc = ["svm", "svm-builds", "sha2"]

# Utilities for creating and testing project workspaces
Expand Down
1 change: 0 additions & 1 deletion ethers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
2 changes: 1 addition & 1 deletion ethers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub use ethers_core::{abi, types, utils};

/// Easy imports of frequently used type definitions and traits.
#[doc(hidden)]
#[allow(ambiguous_glob_reexports)]
#[allow(unknown_lints, ambiguous_glob_reexports)]
pub mod prelude {
pub use super::addressbook::contract;

Expand Down
4 changes: 0 additions & 4 deletions examples/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ license.workspace = true
rust-version.workspace = true
edition.workspace = true

[features]
default = ["legacy"]
legacy = ["ethers/legacy"]

[dev-dependencies]
ethers = { workspace = true, features = ["abigen", "rustls", "ws", "ethers-solc"] }

Expand Down
6 changes: 0 additions & 6 deletions examples/contracts/examples/deploy_moonbeam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ abigen!(
/// ```bash
/// docker run --rm --name moonbeam_development -p 9944:9944 -p 9933:9933 purestake/moonbeam:v0.14.2 --dev --ws-external --rpc-external
/// ```
///
/// Also requires the `legacy` feature to send Legacy transaction instead of an EIP-1559
#[tokio::main]
#[cfg(feature = "legacy")]
async fn main() -> eyre::Result<()> {
use ethers::prelude::*;
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};
Expand Down Expand Up @@ -71,6 +68,3 @@ async fn main() -> eyre::Result<()> {

Ok(())
}

#[cfg(not(feature = "legacy"))]
fn main() {}
Loading

0 comments on commit d75e324

Please sign in to comment.