Add curl_template to CI (#7)

This commit is contained in:
folex 2021-06-13 23:54:37 +03:00 committed by GitHub
parent 7f33ee4b4f
commit 256aae9c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 154 additions and 46 deletions

View File

@ -48,7 +48,7 @@ jobs:
- run: npm install -g @fluencelabs/fldist
- name: "Check call parameters deployment"
- name: "Check call_parameters deployment"
run: |
set -x
export NODE="/ip4/127.0.0.1/tcp/4310/ws/p2p/12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
@ -60,3 +60,16 @@ jobs:
)
')
working-directory: call_parameters
- name: "Check curl_template deployment"
run: |
set -x
export NODE="/ip4/127.0.0.1/tcp/4310/ws/p2p/12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
SERVICE_ID=`./deploy.sh`
fldist --node-addr $NODE run_air -d '{"service_id": "'$SERVICE_ID'"}' -p <(echo '
(seq
(call relay (service_id "request") ["https://fluence.network/join.html"] result)
(call %init_peer_id% (returnService "run") [result])
)
')
working-directory: curl_template

View File

@ -1,11 +1,32 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]]
name = "curl_template"
version = "0.1.0"
@ -15,48 +36,27 @@ dependencies = [
[[package]]
name = "fluence"
version = "0.3.3"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c621ecf5ba628a3a66c4571cb63b9e57de5b8e1ffbb4636873349d04ed9c4c"
checksum = "88b09e1cd11a51ba4d169db347d009fe41ece2714eef4d5df720343733a1d5a6"
dependencies = [
"fluence-sdk-macro",
"fluence-sdk-main",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3ed152de2a9f59c5494a5ead9d85b40cc1588696d10bb69129addebf0239efb"
dependencies = [
"fluence-sdk-wit",
"marine-macro",
"marine-timestamp-macro",
"serde",
]
[[package]]
name = "fluence-sdk-main"
version = "0.3.3"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ed74c32aded592c2a4c2d11a4586369e2d9f793e6c7b500a2a22f4a61769784"
checksum = "68d93cde99e1494e11755a39b93863333397245c9959c774fe3bebd9e4143879"
dependencies = [
"fluence-sdk-macro",
"log",
"marine-macro",
"serde",
]
[[package]]
name = "fluence-sdk-wit"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65bb11a2ebb063b8809e43c1837d32e44c12ba3c281e55f2fcf5c5819a6a9ad"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_json",
"syn",
"uuid",
]
[[package]]
name = "getrandom"
version = "0.2.2"
@ -89,6 +89,58 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "marine-macro"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f63d927851847cc3dd9e3bd0f10bdeb313859d4822d5b5f650d9d34d461ed419"
dependencies = [
"marine-macro-impl",
]
[[package]]
name = "marine-macro-impl"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb504be4a90e229ab453c7369cc8a9063acec819f3397802eea719cd0a232be1"
dependencies = [
"proc-macro2",
"quote",
"serde",
"serde_json",
"syn",
"uuid",
]
[[package]]
name = "marine-timestamp-macro"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5994c7db5567d21609f2a2e5a40d9d4564f86c17ca35b2d77007152619b9d7fc"
dependencies = [
"chrono",
"quote",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]]
name = "proc-macro2"
version = "1.0.24"
@ -146,15 +198,26 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.60"
version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"winapi",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
@ -172,6 +235,28 @@ dependencies = [
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
fluence = { version = "=0.3.3" }
fluence = { version = "=0.6.9" }

View File

@ -1,19 +1,22 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::MountedBinaryStringResult as StringResult;
use fluence::MountedBinaryResult as Result;
use fluence::marine;
use fluence::module_manifest;
use fluence::MountedBinaryResult;
use fluence::MountedBinaryStringResult;
module_manifest!();
fn main() {}
#[fce]
pub fn request(url: String) -> StringResult {
unsafe { curl(vec!["-sS".into(), url]) }.stringify().unwrap()
#[marine]
pub fn request(url: String) -> MountedBinaryStringResult {
curl(vec!["-sS".into(), url]).stringify().unwrap()
}
// mounted_binaries are available to import like this:
#[fce]
#[marine]
#[link(wasm_import_module = "host")]
extern "C" {
pub fn curl(cmd: Vec<String>) -> Result;
pub fn curl(cmd: Vec<String>) -> MountedBinaryResult;
}

View File

@ -1,7 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
set -o errexit -o nounset -o pipefail
# check `fcli` and `fldist` tools are installed or install them
if [[ -z "${NODE:-}" ]]; then
NODE_ADDR=""
else
NODE_ADDR="--node-addr $NODE"
fi
# check `marine` and `fldist` tools are installed or install them
(command -v marine || cargo install marine) >/dev/null
(command -v fldist || npm install -g @fluencelabs/fldist) >/dev/null
@ -17,4 +23,5 @@ test -f "$WASM" || echo >&2 "Couldn't find $WASM"
# create a service from that .wasm
CONFIG="$(pwd)/backend/BackendConfig.json"
fldist new_service --modules "$WASM:$CONFIG" --name curl_template
SERVICE_ID=$(fldist new_service $NODE_ADDR --modules "$WASM:$CONFIG" --name call_parameters | head -n1 | sed -e 's/service id: //')
echo $SERVICE_ID