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: run miri in ci #327

Merged
merged 1 commit into from
Oct 3, 2023
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
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,26 @@ jobs:
if: ${{ matrix.rust != '1.65' }} # MSRV
run: cargo test --workspace ${{ matrix.flags }}

miri:
name: miri ${{ matrix.flags }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
flags: ["--no-default-features", "", "--all-features"]
env:
MIRIFLAGS: -Zmiri-strict-provenance
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@miri
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo miri setup ${{ matrix.flags }}
- run: cargo miri test ${{ matrix.flags }}

wasm:
name: check WASM
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -54,7 +72,6 @@ jobs:
run: cargo check --workspace --target wasm32-unknown-unknown

feature-checks:
name: feature checks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -68,7 +85,6 @@ jobs:
run: cargo hack check --feature-powerset --depth 2 --all-targets

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -82,7 +98,6 @@ jobs:
RUSTFLAGS: -Dwarnings

docs:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -96,7 +111,6 @@ jobs:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

fmt:
name: fmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down
2 changes: 1 addition & 1 deletion crates/dyn-abi/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ fn int_strategy<T: Arbitrary>() -> impl Strategy<Value = (ValueOfStrategy<T::Str
(any::<T>(), any::<usize>().prop_map(int_size))
}

#[cfg(test)]
#[cfg(all(test, not(miri)))] // doesn't run in isolation and would take too long
mod tests {
use super::*;
#[cfg(feature = "eip712")]
Expand Down
8 changes: 6 additions & 2 deletions crates/json-abi/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use alloy_json_abi::{AbiItem, EventParam, JsonAbi, Param};
use std::collections::HashMap;

macro_rules! abi_parse_tests {
($($name:ident($path:literal, $len:literal))*) => {$(
($( $(#[$attr:meta])* $name:ident($path:literal, $len:literal))*) => {$(
#[test]
$(#[$attr])*
fn $name() {
parse_test(include_str!($path), $len, $path);
}
Expand All @@ -12,19 +13,22 @@ macro_rules! abi_parse_tests {

abi_parse_tests! {
abiencoderv2("abi/Abiencoderv2Test.json", 1)
#[cfg_attr(miri, ignore = "takes too long")]
console("abi/console.json", 379)
event_with_struct("abi/EventWithStruct.json", 1)
large_array("abi/LargeArray.json", 1)
large_struct("abi/LargeStruct.json", 1)
#[cfg_attr(miri, ignore = "takes too long")]
large_structs("abi/LargeStructs.json", 4)
large_tuple("abi/LargeTuple.json", 1)
#[cfg_attr(miri, ignore = "takes too long")]
seaport("abi/Seaport.json", 69)
udvts("abi/Udvts.json", 1)
}

#[allow(unused_variables)]
fn load_test(path: &str, abi: &JsonAbi) {
#[cfg(all(feature = "std", feature = "serde_json"))]
#[cfg(all(feature = "std", feature = "serde_json", not(miri)))]
{
use std::{fs::File, io::BufReader};
let file_path: String = format!("tests/{path}");
Expand Down
2 changes: 2 additions & 0 deletions crates/json-abi/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn big_function() {
}

#[test]
#[cfg_attr(miri, ignore = "takes too long")]
fn test_constructor() {
// Parse the ABI JSON file
let abi_items_wo_constructor = include_str!("abi/Abiencoderv2Test.json");
Expand All @@ -65,6 +66,7 @@ fn test_constructor() {
}

#[test]
#[cfg_attr(miri, ignore = "no fs")]
fn no_from_reader() {
let path = "abi/Abiencoderv2Test.json";
let file_path: String = format!("tests/{path}");
Expand Down
1 change: 1 addition & 0 deletions crates/primitives/src/bits/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ mod tests {

#[test]
#[cfg(all(feature = "rlp", feature = "arbitrary"))]
#[cfg_attr(miri, ignore = "doesn't run in isolation and would take too long")]
fn create_correctness() {
fn create_slow(address: &Address, nonce: u64) -> Address {
use alloy_rlp::Encodable;
Expand Down
1 change: 1 addition & 0 deletions crates/sol-types/src/types/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ mod tests {
($($name:ident($st:ty : $t:ty);)+) => {
proptest::proptest! {$(
#[test]
#[cfg_attr(miri, ignore = "doesn't run in isolation and would take too long")]
fn $name(i: $t) {
proptest::prop_assert_eq!(<$st>::detokenize(<$st>::tokenize(&i)), i);
}
Expand Down
1 change: 1 addition & 0 deletions crates/syn-solidity/src/item/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ mod tests {
};

#[test]
#[cfg_attr(miri, ignore = "takes too long")]
fn getters() {
macro_rules! test_getters {
($($var:literal => $f:literal),* $(,)?) => {
Expand Down
1 change: 1 addition & 0 deletions crates/syn-solidity/tests/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use syn_solidity::{
};

#[test]
#[cfg_attr(miri, ignore = "no fs")]
fn contracts() {
static PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contracts");
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
Expand Down