Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
[Script] Use install script from WasmEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
dm4 authored and hydai committed Sep 29, 2021
1 parent e89e9fb commit f912b4c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 41 deletions.
53 changes: 25 additions & 28 deletions .github/workflows/external-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@ jobs:
node-version: [10.x, 12.x, 14.x]
include:
- node-version: '14.x'
ssvm-options: '--enable-aot'
rustwasmc-options: '--enable-aot'

steps:
# MAGIC: Checkout wasm-learning at $GITHUB_WORKSPACE so that node
# module search will find 'ssvm' from inside the testdirs.
- uses: actions/checkout@v2

- name: Checkout wasm-learning
uses: actions/checkout@v2
with:
repository: second-state/wasm-learning
path: wasm-learning

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Checkout wasmedge-core
uses: actions/checkout@v2
with:
path: wasmedge-core

- name: Set Rust to required version
uses: actions-rs/toolchain@v1
with:
Expand All @@ -49,44 +45,45 @@ jobs:

- name: Install dependencies
run: |
apt update && apt install -y sudo
npm install --unsafe-perm -g rustwasmc
ln -s $(which node) /usr/local/bin/node
ln -s $(which npm) /usr/local/bin/npm
- name: Build and install wasmedge-core
uses: './wasmedge-core/.github/actions/build-from-source'
with:
path: './wasmedge-core'
uses: './.github/actions/build-from-source'

- name: Test functions ${{ matrix.ssvm-options }}
- name: Test functions ${{ matrix.rustwasmc-options }}
run: |
rustwasmc build ${{ matrix.ssvm-options }}
sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js
rustwasmc build ${{ matrix.rustwasmc-options }}
cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd ..
node node/app.js
rustwasmc clean
working-directory: nodejs/functions
working-directory: wasm-learning/nodejs/functions

- name: Test JSON IO ${{ matrix.ssvm-options }}
- name: Test JSON IO ${{ matrix.rustwasmc-options }}
run: |
rustwasmc build ${{ matrix.ssvm-options }}
sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js
rustwasmc build ${{ matrix.rustwasmc-options }}
cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd ..
node node/app.js
rustwasmc clean
working-directory: nodejs/json_io
working-directory: wasm-learning/nodejs/json_io

- name: Test WASI ${{ matrix.ssvm-options }}
- name: Test WASI ${{ matrix.rustwasmc-options }}
run: |
rustwasmc build ${{ matrix.ssvm-options }}
sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js
rustwasmc build ${{ matrix.rustwasmc-options }}
cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd ..
node node/app.js
rustwasmc clean
working-directory: nodejs/wasi
working-directory: wasm-learning/nodejs/wasi

- name: Test KMeans ${{ matrix.ssvm-options }}
if: ${{ contains(matrix.ssvm-options, 'aot') }}
- name: Test KMeans ${{ matrix.rustwasmc-options }}
if: ${{ contains(matrix.rustwasmc-options, 'aot') }}
run: |
rustwasmc build ${{ matrix.ssvm-options }}
sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js
rustwasmc build ${{ matrix.rustwasmc-options }}
cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd ..
cd node
node app.js
cd -
rustwasmc clean
working-directory: nodejs/kmeans
working-directory: wasm-learning/nodejs/kmeans
11 changes: 9 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ jobs:
toolchain: 1.50.0
override: true

- name: Build SSVM-napi with ${{ matrix.cc }}
- name: Install dependencies
run: |
apt update && apt install -y sudo
npm install --unsafe-perm -g rustwasmc
ln -s $(which node) /usr/local/bin/node
ln -s $(which npm) /usr/local/bin/npm
- name: Build wasmedge-core with ${{ matrix.cc }}
uses: './.github/actions/build-from-source'
with:
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}

- name: Test SSVM-napi built with ${{ matrix.cc }}
- name: Test wasmedge-core built with ${{ matrix.cc }}
run: |
JOBS=max npm test
4 changes: 2 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"cflags_cc!": [ "-fno-exceptions", "-fno-rtti" ],
"link_settings": {
"libraries": [
"/usr/local/lib/libwasmedge_c.so",
"$(HOME)/.wasmedge/lib/libwasmedge_c.so",
],
},
"sources": [
Expand All @@ -20,7 +20,7 @@
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"src",
"/usr/local/include",
"$(HOME)/.wasmedge/include",
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
},
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wasmedge-core",
"version": "0.8.1",
"version": "0.8.2-rc.1",
"description": "Second State WebAssembly VM for Node.js Addon",
"keywords": [
"wasm",
Expand Down Expand Up @@ -28,8 +28,7 @@
},
"devDependencies": {
"mocha": "^8.1.3",
"node-gyp-cache": "^0.2.1",
"rustwasmc": "^0.1.29"
"node-gyp-cache": "^0.2.1"
},
"scripts": {
"test": "cd test && ./test.sh",
Expand Down
10 changes: 7 additions & 3 deletions scripts/preinstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

INSTALL_SCRIPT=/tmp/install_wasmedge.sh
wget -O "$INSTALL_SCRIPT" https://github.com/second-state/WasmEdge-go/releases/download/v0.8.1/install_wasmedge.sh
sh "$INSTALL_SCRIPT" /usr/local
rm -f "$INSTALL_SCRIPT"
INSTALL_PATH="$HOME/.wasmedge"
INSTALL_VERSION=0.8.1
SUDO=

wget -O "$INSTALL_SCRIPT" "https://raw.githubusercontent.com/WasmEdge/WasmEdge/766654ee0b655a06156278854d22be8042a2c6bd/utils/install.sh"
[ "$GITHUB_ACTIONS" == true ] && SUDO=sudo
$SUDO bash "$INSTALL_SCRIPT" -p "$INSTALL_PATH" --version "$INSTALL_VERSION"
2 changes: 1 addition & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
ARCH=$1
ARCH=$(node -e 'console.log(process.arch)')
npm run release
rm -rf wasmedge
mkdir wasmedge
Expand Down
8 changes: 6 additions & 2 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env bash

set -xe

SUDO=
[ "$GITHUB_ACTIONS" == true ] && SUDO=sudo

rustwasmc build
cd pkg
npm install ../..
sed -i "s/require('ssvm')/require('wasmedge-core')/" integers_lib.js
$SUDO npm install ../..
cd -
mocha js
rustwasmc clean

0 comments on commit f912b4c

Please sign in to comment.