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

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

Merged
merged 3 commits into from
Jan 7, 2025
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: 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;
Comment on lines -24 to -25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some unused warnings were detected.


/// 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
Loading