Skip to content

Commit

Permalink
add CI check to build wasm for all crates (with runtime-benchmarks fe…
Browse files Browse the repository at this point in the history
…ature if applicable) (#410)

* add CI check to build wasm for all crates (with runtime-benchmarks feature if applicable)

* fix: checkout code in wasm check

* fix unused warning
  • Loading branch information
clangenb authored Jan 7, 2025
1 parent 2362e1d commit 919520a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,17 @@ jobs:

- name: Fail-fast; cancel other jobs
if: failure()
uses: andymckay/[email protected]
uses: andymckay/[email protected]

check-wasm:
if: ${{ !startsWith(github.head_ref, 'release/') }}
name: Check wasm build
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install -y protobuf-compiler
- uses: Swatinem/rust-cache@v2
with:
key: check-debug-cache
- run: ./scripts/run_for_all_no_std_crates.sh check --no-default-features --target=wasm32-unknown-unknown
2 changes: 0 additions & 2 deletions balances-tx-payment/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
use core::fmt;
use frame_support::pallet_prelude::TypeInfo;
use parity_scale_codec::{Decode, Encode};
#[cfg(not(feature = "std"))]
use sp_std::vec::Vec;

/// Error type of this RPC api.
#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, TypeInfo)]
Expand Down
2 changes: 0 additions & 2 deletions democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ use sp_std::vec::Vec;
#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(not(feature = "std"))]
use alloc::string::String;
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
use frame_support::traits::Currency;
Expand Down
18 changes: 18 additions & 0 deletions scripts/run_for_all_no_std_crates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
find . -name "Cargo.toml" | while read -r CARGO_TOML; do
DIR=$(dirname "$CARGO_TOML")
echo "Checking in directory: $DIR"

# Skip the loop if the crate does not have a feature `std`
if ! grep -q "\[features\]" "$CARGO_TOML" || ! grep -q "std = \[" "$CARGO_TOML"; then
echo "Feature 'std' not found in $CARGO_TOML. Skipping."
continue
fi

if grep -q "\[features\]" "$CARGO_TOML" && grep -q "runtime-benchmarks = \[" "$CARGO_TOML"; then
echo "Feature 'runtime-benchmarks' found, adding this feature."
cargo $COMMAND $@ --features runtime-benchmarks --manifest-path "$CARGO_TOML"
else
echo "Feature 'runtime-benchmarks' not found, running command without this feature"
cargo $COMMAND $@ --manifest-path "$CARGO_TOML";
fi
done
3 changes: 0 additions & 3 deletions treasuries/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
use sp_std::vec::Vec;

use encointer_primitives::communities::CommunityIdentifier;
use parity_scale_codec::{Decode, Encode};

Expand Down

0 comments on commit 919520a

Please sign in to comment.