Skip to content

Commit

Permalink
add Execute trait, add CI workflow for wasm helper crate
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Jan 26, 2022
1 parent f5c5528 commit a143433
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 490 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/iroha2-dev-pr-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- "**.toml"
- "**.yml"

# Not part of the workspace
- "!wasm/**"

jobs:
check:
runs-on: [self-hosted, Linux]
Expand All @@ -17,20 +20,21 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1

- name: Format check
run: cargo +nightly-2021-12-02 fmt --all -- --check
- name: Static analysis without features
run: cargo lints clippy --workspace --benches --tests --examples --quiet --no-default-features
if: always()
- name: Static analysis with all features enabled
run: cargo lints clippy --workspace --benches --tests --examples --all-features --quiet
run: cargo lints clippy --workspace --benches --tests --examples --quiet --all-features
if: always()
- name: Verify iroha_data_model supports no_std
- name: Verify iroha_data_model still supports no_std
run: cargo nono check --package iroha_data_model --no-default-features
if: always()

- name: Documentation check
run: |
cargo doc --no-deps --quiet
./scripts/check_docs.sh
if: always()

3 changes: 3 additions & 0 deletions .github/workflows/iroha2-dev-pr-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- "**.toml"
- "**.yml"

# Not part of the workspace
- "!wasm/**"

env:
CARGO_TERM_COLOR: always

Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/iroha2-dev-pr-wasm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: I2::Dev::Wasm

defaults:
run:
working-directory: wasm

on:
pull_request:
branches: [iroha2-dev]
paths:
- "wasm/**.rs"
- "wasm/**.json"
- "wasm/**.toml"
- "wasm/**.yml"

env:
RUSTC_BOOTSTRAP: 1

jobs:
wasm32:
runs-on: [self-hosted, Linux]
container:
image: 7272721/i2-ci:latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1

# Static analysis
- name: Format check
run: cargo +nightly-2021-12-02 fmt --all -- --check
- name: Static analysis without features
run: cargo lints clippy --benches --tests --examples --quiet --no-default-features
if: always()
- name: Static analysis with all features enabled
run: cargo lints clippy --benches --tests --examples --quiet --all-features
if: always()

- name: Verify iroha_wasm still supports no_std
run: cargo nono check --package iroha_wasm
if: always()

# Tests
- name: Run tests
run: mold -run cargo test --tests --quiet --no-fail-fast
13 changes: 5 additions & 8 deletions .github/workflows/iroha2-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ on:
- "**.toml"
- "**.yml"

# Not part of the workspace
- "!wasm/**"

env:
CARGO_TERM_COLOR: always
RUSTC_BOOTSTRAP: 1

jobs:
test:
Expand All @@ -23,19 +27,13 @@ jobs:
- uses: Swatinem/rust-cache@v1
- name: Run tests
run: mold -run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2
env:
RUSTC_BOOTSTRAP: 1
- name: Run iroha tests with network mock
run: mold -run cargo test --quiet --features mock -- --ignored --skip unstable_network --test-threads 2
env:
RUSTC_BOOTSTRAP: 1
working-directory: core/test_network
- name: Run iroha_actor deadlock detection tests
working-directory: actor
run: mold -run cargo test --quiet --features deadlock_detection -- --skip unstable_network --test-threads 2
if: always()
env:
RUSTC_BOOTSTRAP: 1
working-directory: actor

# Coverage is both in PR and in push pipelines so that:
# 1. PR can get coverage report from bot.
Expand All @@ -51,7 +49,6 @@ jobs:
run: mold -run cargo test --quiet --workspace --no-fail-fast -- --skip unstable_network --test-threads 2 || true
env:
RUSTFLAGS: "-Zinstrument-coverage"
RUSTC_BOOTSTRAP: 1
LLVM_PROFILE_FILE: "iroha-%p-%m.profraw"
- name: Generate a grcov coverage report
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/iroha2-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:

# Coverage is both in PR and in push pipelines so that:
# 1. PR can get coverage report from bot.
# 2 Coverage bot can have results from `iroha2-dev` to report coverage changes.
# 2. Coverage bot can have results from `iroha2-dev` to report coverage changes.
coverage:
runs-on: ubuntu-latest
container:
Expand All @@ -180,7 +180,7 @@ jobs:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Run tests
run: mold -run cargo test --workspace --no-fail-fast -- --skip unstable_network || true
run: mold -run cargo test --workspace --no-fail-fast -- --skip unstable_network || true
env:
RUSTFLAGS: "-Zinstrument-coverage"
RUSTC_BOOTSTRAP: 1
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/iroha2-pr-heavy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
- "**.toml"
- "**.yml"

# Not part of the workspace
- "!wasm/**"

env:
CARGO_TERM_COLOR: always

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/blocks/
**/*.rs.bk
**/rusty-tags.vi
/**/Cargo.lock

config/__pycaсhe__
**/__pycache__/*
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ members = [
"version",
"version/derive",
]

exclude = ["wasm"]
4 changes: 2 additions & 2 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ RUN git clone https://github.com/rui314/mold.git; \
rm -rf "./mold"

RUN rustup component add llvm-tools-preview clippy; \
rustup target add wasm32-unknown-unknown; \
rustup install --profile default nightly-2021-12-02; \
cargo install cargo-lints cargo-nono grcov
cargo install cargo-lints cargo-nono webassembly-test-runner grcov

RUN curl -fsSL https://get.docker.com -o get-docker.sh; \
chmod +x get-docker.sh; \
Expand All @@ -62,4 +63,3 @@ RUN curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-c
chmod +x /usr/local/bin/docker-compose

# Refer to docker-compose.yml to see which ports should be exposed.

2 changes: 1 addition & 1 deletion crypto/src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(not(feature = "std"))]
use alloc::{format, string::String, vec::Vec};
use alloc::{format, string::String, vec, vec::Vec};
use core::{
fmt::{self, Debug, Display, Formatter},
hash,
Expand Down
1 change: 1 addition & 0 deletions crypto/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloc::{
collections::{btree_map, btree_set},
format,
string::String,
vec,
vec::Vec,
};
use core::{fmt, marker::PhantomData};
Expand Down
2 changes: 1 addition & 1 deletion data_model/src/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Merkle tree implementation
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, vec, vec::Vec};
use alloc::{boxed::Box, format, string::String, vec, vec::Vec};
#[cfg(feature = "std")]
use std::collections::VecDeque;

Expand Down
5 changes: 5 additions & 0 deletions wasm/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build]
target = "wasm32-unknown-unknown"

[target.wasm32-unknown-unknown]
runner = "webassembly-test-runner"
8 changes: 8 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ panic = "abort"
[profile.release]
panic = "abort"

[workspace]
members = [
"derive",
]

[dependencies]
iroha_data_model = { version = "=2.0.0-pre.1", path = "../data_model", default-features = false }
iroha_wasm_derive = { path = "derive" }

parity-scale-codec = { version = "2.3.1", default-features = false }
wee_alloc = "0.4.5"

[dev-dependencies]
webassembly-test = "0.1.0"
Loading

0 comments on commit a143433

Please sign in to comment.