examples #460
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: examples | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'info' | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
schedule: | |
- cron: "0 0 */1 * *" | |
jobs: | |
run-all-examples: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- 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 and run MySQL | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install mysql-server libmysqlclient-dev curl | |
sudo service mysql start | |
mysql -e "PURGE BINARY LOGS BEFORE now();" -uroot -proot | |
- name: Install WasmEdge | |
run: | | |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --version=0.11.2 | |
sudo -E sh -c 'echo "$HOME/.wasmedge/lib" > /etc/ld.so.conf.d/libwasmedge.conf' | |
sudo ldconfig | |
- name: Build and install conatiner wasmedge shim | |
run: | | |
rustup default nightly | |
rustup target add wasm32-wasi | |
make build FEATURES=wasmedge | |
sudo make install RUNTIME=wasmedge | |
- name: Build all test and demo OCI images | |
run: | | |
make load | |
make load_demo | |
- name: Run basic test case | |
run: | | |
sudo ctr run --rm --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasi-demo-app:latest testwasm /wasi-demo-app.wasm echo 'hello' | |
- name: Run hype demo conatiner | |
run: | | |
sudo ctr run --rm --net-host --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasmedge_hyper_client:latest testclient | |
nohup sudo ctr run --rm --net-host --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasmedge_hyper_server:latest testserver & | |
- name: Test hyper server | |
run: | | |
curl http://localhost:8080/echo -X POST -d "WasmEdge" | |
sudo ctr task kill -s SIGKILL testserver | |
- name: Run reqwest demo conatiner | |
run: | | |
sudo ctr run --rm --net-host --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasmedge_reqwest_demo:latest testreqwest | |
- name: Run db demo conatiner | |
run: | | |
sudo ctr run --rm --net-host --env DATABASE_URL=mysql://root:[email protected]:3306/mysql --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasmedge-mysql-driver-demo:latest testdb /insert.wasm | |
sudo ctr run --rm --net-host --env DATABASE_URL=mysql://root:[email protected]:3306/mysql --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/wasmedge-mysql-driver-demo:latest testdb /query.wasm | |
sudo ctr run --rm --net-host --env DATABASE_URL=mysql://root:[email protected]:3306/mysql --runtime=io.containerd.wasmedge.v1 ghcr.io/containerd/runwasi/crud:latest testdb | |
- name: Run rootfs mounts demo conatiner | |
run: | | |
sudo ctr run --rm --runtime=io.containerd.wasmedge.v1 \ | |
--mount type=bind,src=$PWD/demo/wasmedge-rootfs-mounts-demo,dst=/mnt,options=rbind:ro \ | |
ghcr.io/containerd/runwasi/wasmedge-rootfs-mounts-demo:latest preopens | |
- name: Run microservice with database demo conatiner | |
run: | | |
nohup sudo ctr run --rm --net-host \ | |
--env DATABASE_URL=mysql://root:[email protected]:3306/mysql \ | |
--runtime=io.containerd.wasmedge.v1 \ | |
ghcr.io/containerd/runwasi/order_demo_service:latest testmicroservice & | |
- name: Test microservice | |
run: | | |
curl http://localhost:8080/init | |
curl http://localhost:8080/create_orders -X POST -d @demo/microservice_db/orders.json | |
curl http://localhost:8080/orders | |
curl http://localhost:8080/update_order -X POST -d @demo/microservice_db/update_order.json | |
curl http://localhost:8080/delete_order?id=2 | |
sudo ctr task kill -s SIGKILL testmicroservice | |
- name: Download PyTorch library, Wasmedge Library and WASINN PyTorch plugin | |
run: | | |
./demo/utils/setup_wasinn_plugin.sh | |
echo "WASMEDGE_INCLUDE_DIR=$PWD/WasmEdge-0.11.1-Linux/include" >> $GITHUB_ENV | |
echo "WASMEDGE_LIB_DIR=$PWD/WasmEdge-0.11.1-Linux/lib" >> $GITHUB_ENV | |
echo "WASMEDGE_PLUGIN_PATH=$PWD/WasmEdge-0.11.1-Linux/lib/wasmedge" >> $GITHUB_ENV | |
- name: Build and install conatiner wasmedge shim with support wasi-nn plugin | |
run: | | |
make build FEATURES=wasmedge,wasi_nn | |
sudo make install RUNTIME=wasmedge | |
- name: Add WASMEDGE_PLUGIN_PATH into service containerd | |
shell: 'script -q -e -c "bash {0}"' | |
run: | | |
sudo SYSTEMD_EDITOR=tee systemctl edit containerd <<EOF | |
[Service] | |
Environment="WASMEDGE_PLUGIN_PATH=$WASMEDGE_PLUGIN_PATH" | |
EOF | |
sudo systemctl restart containerd | |
- name: Run WASI-NN PyTorch demo conatiner | |
run: | | |
wget --no-clobber https://github.com/bytecodealliance/wasi-nn/raw/main/rust/examples/images/1.jpg -O demo/wasinn/pytorch-mobilenet-image/input.jpg | |
sudo ctr run --rm \ | |
--mount type=bind,src=$PWD/demo/wasinn/pytorch-mobilenet-image,dst=/resource,options=rbind:ro \ | |
--runtime=io.containerd.wasmedge.v1 \ | |
ghcr.io/containerd/runwasi/wasmedge-wasinn-example-mobilenet-image:latest \ | |
testwasinn \ | |
/app.wasm /resource/mobilenet.pt /resource/input.jpg |