diff --git a/.circleci/config.yml b/.circleci/config.yml index ec231aba..7c0949b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,59 +1,80 @@ -#version: 2.1 -#jobs: -# fce: -# docker: -# - image: circleci/rust:latest -# environment: -# RUST_BACKTRACE: 1 -# #RUST_TEST_THREADS: 1 -# steps: -# - checkout -# - restore_cache: -# keys: -# - fce01-{{ checksum "fce/Cargo.toml" }} -# - run: | -# rustup toolchain install stable -# rustup component add rustfmt -# rustup component add clippy -# cd fce -# cargo fmt --all -- --check --color always -# cargo build -v --all-features -# cargo test -v --all-features -# cargo clippy -v -# - save_cache: -# paths: -# - ~/.cargo -# - ~/.rustup -# key: fce01-{{ checksum "fce/Cargo.toml" }} -# wit_embedder: -# docker: -# - image: circleci/rust:latest -# environment: -# RUST_BACKTRACE: 1 -# #RUST_TEST_THREADS: 1 -# steps: -# - checkout -# - restore_cache: -# keys: -# - wit_embedder01-{{ checksum "wit_embedder/Cargo.toml" }} -# - run: | -# rustup toolchain install stable -# rustup component add rustfmt -# rustup component add clippy -# cd wit_embedder -# cargo fmt --all -- --check --color always -# cargo build -v --all-features -# cargo test -v --all-features -# cargo clippy -v -# - save_cache: -# paths: -# - ~/.cargo -# - ~/.rustup -# key: wit_embedder01-{{ checksum "wit_embedder/Cargo.toml" }} -# -#workflows: -# version: 2.1 -# fce: -# jobs: -# - fce -# - wit_embedder +version: 2.1 +jobs: + fce: + docker: + - image: circleci/rust:latest + environment: + RUST_BACKTRACE: 1 + #RUST_TEST_THREADS: 1 + steps: + - checkout + - restore_cache: + keys: + - fce01-{{ checksum "engine/Cargo.toml" }}-{{ checksum "fluence-faas/Cargo.toml" }} + - run: | + rustup toolchain install nightly + rustup component add rustfmt + rustup component add clippy --toolchain nightly + + cd engine + cargo fmt --all -- --check --color always + cargo +nightly build -v --all-features + cargo +nightly test -v --all-features + cargo +nightly clippy -v + + cd ../fluence-faas + cargo fmt --all -- --check --color always + cargo +nightly build -v --all-features + cargo +nightly test -v --all-features + cargo +nightly clippy -v + + - save_cache: + paths: + - ~/.cargo + - ~/.rustup + key: fce01-{{ checksum "engine/Cargo.toml" }}-{{ checksum "fluence-faas/Cargo.toml" }} + + examples: + docker: + - image: circleci/rust:latest + environment: + RUST_BACKTRACE: 1 + #RUST_TEST_THREADS: 1 + steps: + - checkout + - restore_cache: + keys: + - examples01-{{ checksum "examples/ipfs_node/wasm/ipfs_node/Cargo.toml" }}-{{ checksum "examples/ipfs_node/wasm/ipfs_rpc/Cargo.toml" }}-{{ checksum "examples/ipfs_node/Cargo.toml" }} + - run: | + rustup toolchain install nightly + rustup component add rustfmt + rustup component add clippy + cargo install cargo-wasi + + cd examples/ipfs_node/wasm/ipfs_node + cargo fmt --all -- --check --color always + cargo wasi build + cargo clippy -v + + cd ../ipfs_rpc + cargo fmt --all -- --check --color always + cargo wasi build + cargo clippy -v + + cd ../../../../tools/wit_embedder + cargo fmt --all -- --check --color always + cargo build -v --all-features + cargo clippy -v + + - save_cache: + paths: + - ~/.cargo + - ~/.rustup + key: examples01-{{ checksum "examples/ipfs_node/wasm/ipfs_node/Cargo.toml" }}-{{ checksum "examples/ipfs_node/wasm/ipfs_rpc/Cargo.toml" }}-{{ checksum "examples/ipfs_node/Cargo.toml" }} + +workflows: + version: 2.1 + fce: + jobs: + - fce + - examples diff --git a/.gitignore b/.gitignore index 18bc1ef6..b2e56494 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ target/ *.wasm *.wat -# Allowed Wasm files for the example +# Temporary file of ipfs node example +/examples/ipfs_node/wasm/artifacts/ipfs_rpc_file + +# Allowed Wasm files for examples !/examples/ipfs_node/wasm/artifacts/wasm_ipfs_rpc_wit.wasi.wasm !/examples/ipfs_node/wasm/artifacts/wasm_modules/* diff --git a/examples/ipfs_node/src/main.rs b/examples/ipfs_node/src/main.rs index 2186db61..865d78e3 100644 --- a/examples/ipfs_node/src/main.rs +++ b/examples/ipfs_node/src/main.rs @@ -41,7 +41,11 @@ fn main() { println!("ipfs node addresses are:\n{:?}", node_addresses); let result = ipfs_node - .call_code(&ipfs_rpc, "put", &[IValue::String("Hello, world".to_string())]) + .call_code( + &ipfs_rpc, + "put", + &[IValue::String("Hello, world".to_string())], + ) .unwrap(); println!("execution result {:?}", result); diff --git a/examples/ipfs_node/wasm/ipfs_node/src/main.rs b/examples/ipfs_node/wasm/ipfs_node/src/main.rs index 12909952..5d10124b 100644 --- a/examples/ipfs_node/wasm/ipfs_node/src/main.rs +++ b/examples/ipfs_node/wasm/ipfs_node/src/main.rs @@ -26,11 +26,10 @@ use crate::path::to_full_path; const RESULT_FILE_PATH: &str = "/tmp/ipfs_rpc_file"; pub fn main() { - let env_variable = std::env::var("tmp").unwrap(); - println!( - "ipfs_node.main: WASI initialization finished, env {}", - env_variable - ); + let msg = "ipfs_node.main: WASI initialization finished, env {}"; + unsafe { + log_utf8_string(msg.as_ptr() as _, msg.len() as _); + } } #[no_mangle] diff --git a/examples/ipfs_node/wasm/ipfs_rpc/src/main.rs b/examples/ipfs_node/wasm/ipfs_rpc/src/main.rs index 45727fb2..245fee8c 100644 --- a/examples/ipfs_node/wasm/ipfs_rpc/src/main.rs +++ b/examples/ipfs_node/wasm/ipfs_rpc/src/main.rs @@ -25,7 +25,10 @@ use std::path::PathBuf; const RPC_TMP_FILEPATH: &str = "/tmp/ipfs_rpc_file"; pub fn main() { - println!("ipfs_rpc.main: WASI initialization finished"); + let msg = "ipfs_rpc.main: WASI initialization finished, env {}"; + unsafe { + log_utf8_string(msg.as_ptr() as _, msg.len() as _); + } } #[no_mangle] diff --git a/fluence-faas/src/errors.rs b/fluence-faas/src/errors.rs index 42e5cb31..d65ac5bb 100644 --- a/fluence-faas/src/errors.rs +++ b/fluence-faas/src/errors.rs @@ -27,7 +27,7 @@ pub enum FaaSError { /// Various errors related to file i/o. IOError(String), - /// WIT doesn't contain such type. + /// FCE errors. EngineError(FCEError), } diff --git a/fluence-faas/src/misc/utils.rs b/fluence-faas/src/misc/utils.rs index 75de46ca..bf03c36f 100644 --- a/fluence-faas/src/misc/utils.rs +++ b/fluence-faas/src/misc/utils.rs @@ -103,9 +103,7 @@ where } /// Make FCE config based on parsed raw config. -pub(crate) fn make_fce_config( - config: Option, -) -> Result { +pub(crate) fn make_fce_config(config: Option) -> Result { use super::imports::create_host_import_func; use super::imports::log_utf8_string; use wasmer_core::import::Namespace;