-
Notifications
You must be signed in to change notification settings - Fork 61
197 lines (168 loc) · 6.83 KB
/
examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: examples
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'info'
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install apt-get packages
run: |
sudo ACCEPT_EULA=Y apt-get update
sudo ACCEPT_EULA=Y apt-get upgrade
sudo apt-get install wget git curl software-properties-common build-essential
- name: Install Rust target
run: |
rustup target add wasm32-wasi
- name: Install WasmEdge
run: |
VERSION=0.13.5
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -e all --version=$VERSION --plugins wasi_nn-tensorflowlite wasi_crypto -p /usr/local
wget https://github.com/WasmEdge/WasmEdge/releases/download/$VERSION/WasmEdge-plugin-wasmedge_rustls-$VERSION-ubuntu20.04_x86_64.tar.gz
sudo chmod +x /usr/local/lib/wasmedge
tar -zxf WasmEdge-plugin-wasmedge_rustls-*-ubuntu20.04_x86_64.tar.gz
sudo mv libwasmedge_rustls.so /usr/local/lib/wasmedge/
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Regular examples
run: |
cargo build --target wasm32-wasi --release
wasmedge --env 'a=1' --env 'b=1' --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/hello.js WasmEdge Runtime
- name: Image examples
run: |
cargo build --target wasm32-wasi --release --features=img
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/image.js
- name: Modules examples
run: |
cargo build --target wasm32-wasi --release
cp example_js/module_demo/modules/* modules/
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/module_demo/demo.js
- name: Network example
run: |
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/wasi_net_echo.js
- name: Http fetch example
run: |
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/wasi_http_fetch.js
- name: Http server example
run: |
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/wasi_http_echo.js &
- name: Https fetch example
run: |
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/wasi_https_fetch.js
- name: ES6 module
run: |
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/es6_module_demo/demo.js
- name: CommonJs with rollup.js
run: |
cargo build --target wasm32-wasi --release
cd example_js/simple_common_js_demo
npm install
npm run build
echo '> wasmedge aot'
cd ../..
wasmedgec target/wasm32-wasi/release/wasmedge_quickjs.wasm wasmedge_quickjs.wasm
echo '> start wasmedge'
time wasmedge --dir .:. wasmedge_quickjs.wasm example_js/simple_common_js_demo/dist/npm_main.mjs
- name: React SSR
run: |
cargo build --target wasm32-wasi --release
cd example_js/react_ssr
npm install
npm run build
cp -r ../../modules .
echo '> start wasmedge'
wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.js
- name: React Stream SSR
run: |
cargo build --target wasm32-wasi --release
cd example_js/react_ssr_stream
npm install
npm run build
cp -r ../../modules .
echo '> start wasmedge'
nohup wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.mjs &
sleep 15
resp=$(curl http://localhost:8001)
echo "Server response is $resp"
- name: React18 Stream SSR example
run: |
cargo build --target wasm32-wasi --release
cd example_js/react18_ssr
npm install
npm run build
cp -r ../../modules .
echo '> start wasmedge'
nohup wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.mjs &
sleep 15
resp=$(curl http://localhost:8002)
echo "$resp"
- name: Create-react-app SSR example
run: |
cargo build --target wasm32-wasi --release
cd example_js/create-react-app-ssr
npm install
npm run build
cp -r ../../modules .
# Use webpack
npm run webpack:build-server
echo '> start wasmedge server transpiled by Webpack'
nohup wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm server-build/index.js &
echo $! > wasmedge.pid
sleep 15
resp=$(curl http://localhost:8003)
echo "$resp"
kill -9 `cat wasmedge.pid`
rm wasmedge.pid
# Use rollup.js
npm run rollup:build-server
echo '> start wasmedge server transpiled by rollup'
nohup wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm server-build/index.js &
sleep 15
resp=$(curl http://localhost:8003)
echo "$resp"
- name: WASI-NN example (TensorflowLite)
run: |
cargo build --target wasm32-wasi --release --features=wasi_nn
wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm example_js/tensorflow_lite_demo/wasi_nn_main.js
- name: Embed JS in Rust
run: |
cd examples/embed_js
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/embed_js.wasm
- name: Embed JS module in Rust
run: |
cd examples/embed_js_module
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/embed_js_module.wasm
- name: Use Rust to implement JS APIs
run: |
cd examples/embed_rust_module
cargo build --target wasm32-wasi --release
wasmedge --dir .:. target/wasm32-wasi/release/embed_rust_module.wasm
- name: Use Rust to extends JS Class
run: |
cargo build --target wasm32-wasi --release --example=js_extend
wasmedge --dir .:. target/wasm32-wasi/release/examples/js_extend.wasm
- name: Node fs module test
timeout-minutes: 60
run: |
cargo test test_fs --target=wasm32-wasi --release
- name: Node crypto module test
#timeout-minutes: 10
run: |
cargo test test_crypto --target=wasm32-wasi --release --features=nodejs_crypto