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: no_std and workflow #727

Merged
merged 6 commits into from
Sep 6, 2024
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ jobs:
- name: cargo hack
run: cargo hack check --feature-powerset --depth 2

check-no-std:
name: check no_std ${{ matrix.features }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32imac-unknown-none-elf
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: ./scripts/check_no_std.sh

clippy:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ quote = "1.0"
syn = "2.0"

cfg-if = "1.0.0"
derive_more = { version = "1.0", features = ["full"] }
derive_more = { version = "1.0", default-features = false }
hex-literal = "0.4"
paste = "1.0"
num_enum = "0.7"
Expand Down
8 changes: 7 additions & 1 deletion crates/dyn-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ itoa.workspace = true
winnow.workspace = true

# eip712
derive_more = { workspace = true, optional = true }
derive_more = { workspace = true, optional = true, features = [
"deref",
"deref_mut",
"from",
"into",
"into_iterator",
] }
serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }

Expand Down
16 changes: 15 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@ tiny-keccak = { workspace = true, features = ["keccak"] }
keccak-asm = { workspace = true, optional = true }

# macros
derive_more.workspace = true
derive_more = { workspace = true, features = [
"as_ref",
"add",
"add_assign",
"not",
"deref",
"deref_mut",
"from",
"from_str",
"index",
"index_mut",
"into",
"into_iterator",
"display",
] }
cfg-if.workspace = true

# rlp
Expand Down
7 changes: 5 additions & 2 deletions crates/primitives/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

use super::{FixedBytes, Sign, Signed};
use bytes::{BufMut, BytesMut};
use derive_more::{Display, Error};
use derive_more::Display;
use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type, WrongType};
use std::{
error::Error,
iter,
str::{from_utf8, FromStr},
};
Expand Down Expand Up @@ -55,13 +56,15 @@ fn trim_end_vec<T: PartialEq>(vec: &mut Vec<T>, value: &T) {
}

/// Error when converting to Postgres types.
#[derive(Clone, Debug, PartialEq, Eq, Display, Error)]
#[derive(Clone, Debug, PartialEq, Eq, Display)]
pub enum ToSqlError {
/// The value is too large for the type.
#[display("Signed<{_0}> value too large to fit target type {_1}")]
Overflow(usize, Type),
}

impl std::error::Error for ToSqlError {}

/// Convert to Postgres types.
///
/// Compatible [Postgres data types][dt] are:
Expand Down
26 changes: 26 additions & 0 deletions scripts/check_no_std.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -eo pipefail

target=riscv32imac-unknown-none-elf
crates=(
alloy-core
alloy-core-sol-test
alloy-dyn-abi
alloy-json-abi
alloy-json-abi
alloy-primitives
# alloy-sol-macro
# alloy-sol-macro-expander
# alloy-sol-macro-input
alloy-sol-type-parser
alloy-sol-types
# syn-solidity
)

cmd=(cargo +stable hack check --no-default-features --target "$target")
DaniPopes marked this conversation as resolved.
Show resolved Hide resolved
for crate in "${crates[@]}"; do
cmd+=(-p "$crate")
done

echo "Running: ${cmd[*]}"
"${cmd[@]}"