Skip to content

Commit

Permalink
fix: no_std and workflow (#727)
Browse files Browse the repository at this point in the history
* feat: no_std workflow

* chore: move to ci

* fix

* ci: install cargo-hack

* ci: install cargo-hack

* fix: manual derive_more features

---------

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
  • Loading branch information
refcell and DaniPopes authored Sep 6, 2024
1 parent dfa480e commit 96d4d86
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
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")
for crate in "${crates[@]}"; do
cmd+=(-p "$crate")
done

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

0 comments on commit 96d4d86

Please sign in to comment.