diff --git a/.github/download_marine.sh b/.github/download_marine.sh new file mode 100755 index 0000000..c7609aa --- /dev/null +++ b/.github/download_marine.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -o pipefail -o errexit -o nounset +set -x + +MARINE_RELEASE="https://api.github.com/repos/fluencelabs/marine/releases/latest" +OUT_DIR=/usr/local/bin + +# get metadata about release +curl -s -H "Accept: application/vnd.github.v3+json" $MARINE_RELEASE | + # extract url and name for asset with name "marine" + # also append $OUT_DIR to each name so file is saved to $OUT_DIR + jq -r ".assets | .[] | select(.name == \"marine\") | \"\(.browser_download_url) $OUT_DIR/\(.name)\"" | + # download assets + xargs -n2 bash -c 'curl -L $0 -o $1 && chmod +x $1' diff --git a/.github/workflows/check-deploy.yml b/.github/workflows/check-deploy.yml new file mode 100644 index 0000000..57ff7f0 --- /dev/null +++ b/.github/workflows/check-deploy.yml @@ -0,0 +1,62 @@ +name: "check-deploy" + +on: + push: + # branches: + # - "master" + +jobs: + check-deployment: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/.cargo/bin + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - run: docker run -d --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj --local + + - name: Download marine + run: sudo bash $GITHUB_WORKSPACE/.github/download_marine.sh + + - name: Install Rust + run: | + rustup toolchain install nightly-2021-04-24-x86_64-unknown-linux-gnu + rustup default nightly-2021-04-24-x86_64-unknown-linux-gnu + rustup target add wasm32-wasi --toolchain nightly-2021-04-24-x86_64-unknown-linux-gnu + + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-v1-node-14-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-v1-node-14 + + - name: Setup Node.js 14 + uses: actions/setup-node@v1 + with: + node-version: 14 + + - run: npm install -g @fluencelabs/fldist + + - name: "Check call parameters 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 "call_parameters") [] result) + (call %init_peer_id% (returnService "run") [result]) + ) + ') + working-directory: call_parameters diff --git a/call_parameters/config.json b/call_parameters/config.json new file mode 100644 index 0000000..8cbbcf9 --- /dev/null +++ b/call_parameters/config.json @@ -0,0 +1,3 @@ +{ + "name": "call_parameters" +} diff --git a/call_parameters/deploy.sh b/call_parameters/deploy.sh new file mode 100755 index 0000000..ce635ff --- /dev/null +++ b/call_parameters/deploy.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail + +if [[ -z "${NODE:-}" ]]; then + NODE_ADDR="" +else + NODE_ADDR="--node-addr $NODE" +fi + +./build.sh + +# check it .wasm was built +WASM="artifacts/call_parameters.wasm" +test -f "$WASM" || echo >&2 "Couldn't find $WASM" + +# create a service from that .wasm +CONFIG="config.json" +SERVICE_ID=$(fldist new_service $NODE_ADDR --modules "$WASM:$CONFIG" --name call_parameters | head -n1 | sed -e 's/service id: //') +echo $SERVICE_ID diff --git a/curl_template/deploy.sh b/curl_template/deploy.sh index d36f2d9..d8ca9ac 100755 --- a/curl_template/deploy.sh +++ b/curl_template/deploy.sh @@ -2,13 +2,13 @@ set -euo pipefail # check `fcli` and `fldist` tools are installed or install them -(command -v fce || cargo install fcli) >/dev/null +(command -v marine || cargo install marine) >/dev/null (command -v fldist || npm install -g @fluencelabs/fldist) >/dev/null # build .wasm ( cd backend - fce build --release + marine build --release ) # check it .wasm was built