Skip to content

Add Tls examples

Add Tls examples #1

Workflow file for this run

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: |
echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc
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 "SET GLOBAL max_allowed_packet = 36700160;" -uroot -proot
mysql -e "SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;" -uroot -proot
mysql -e "SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;" -uroot -proot
mysql -e "SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;" -uroot -proot
mysql -e "SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;" -uroot -proot
mysql -e "SET @@GLOBAL.GTID_MODE = ON;" -uroot -proot
mysql -e "PURGE BINARY LOGS BEFORE now();" -uroot -proot
# - name: Install and run TiDB
# run: |
# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
# source ~/.profile
# tiup playground $(DB_VERSION) --db 1 --pd 1 --kv 1 &
# while ! nc -W 1 localhost 4000 | grep -q -P '.+'; do sleep 1; done
- name: Install and run Redis
run: |
sudo apt-get update
sudo apt install redis-server
sudo systemctl status redis-server
- name: Install and run PostgreSQL
run: |
sudo apt-get update
sudo apt install postgresql postgresql-contrib
# sudo pg_ctlcluster 12 main start
sudo systemctl start postgresql.service
sleep 10
sudo -u postgres createuser -w wasmedge
sudo -u postgres createdb -O wasmedge testdb
sudo -u postgres psql -c "ALTER USER wasmedge PASSWORD 'mysecret';"
sudo -u postgres psql -c 'SELECT datname FROM pg_catalog.pg_database'
# - name: Install Anna KVS and run router
# run: |
# git clone https://github.com/essa-project/anna-rs.git
# cd anna-rs
# cp example-config.yml config.yml
# ANNA_PUBLIC_IP=127.0.0.1 ANNA_TCP_PORT_BASE=12340 nohup cargo run --bin routing -- config.yml &
# - name: Run Anna KVS
# run: |
# cd anna-rs
# ANNA_PUBLIC_IP=127.0.0.1 nohup cargo run --bin kvs -- config.yml &
- name: Install Rust target for wasm
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 -- --version=$VERSION -p /usr/local --plugins=wasmedge_image
wget https://github.com/WasmEdge/WasmEdge/releases/download/$VERSION/WasmEdge-plugin-wasmedge_rustls-$VERSION-ubuntu20.04_x86_64.tar.gz
tar -zxf WasmEdge-plugin-wasmedge_rustls-*-ubuntu20.04_x86_64.tar.gz
sudo mv libwasmedge_rustls.so /usr/local/lib/wasmedge/
- name: MySQL async examples
run: |
cd mysql_async
cargo build --target wasm32-wasi --release
wasmedge compile target/wasm32-wasi/release/crud.wasm crud.wasm
resp=$(wasmedge --env "DATABASE_URL=mysql://root:root@localhost:3306/mysql" crud.wasm 2>&1)
echo "$resp"
if [[ $resp == *"Bobcat"* ]]; then
echo -e "Execution Success!"
else
echo -e "Execution Fail!"
exit 1
fi
- name: MySQL tls async examples
env:
DB_URL: ${{ secrets.DB_URL }}
run: |
cd mysql_async
resp=$(wasmedge --env "DATABASE_SSL=1" --env "DATABASE_URL=${DB_URL}" crud.wasm 2>&1)
echo "$resp"
if [[ $resp == *"Bobcat"* ]]; then
echo -e "Execution Success!"
else
echo -e "Execution Fail!"
exit 1
fi
# - name: TiDB async examples
# run: |
# cd mysql_async
# cargo build --target wasm32-wasi --release
# wasmedgec target/wasm32-wasi/release/crud.wasm crud.wasm
# resp=$(wasmedge --env "DATABASE_URL=mysql://root@127.0.0.1:4000/mysql" crud.wasm 2>&1)
# echo "$resp"
# if [[ $resp == *"Bobcat"* ]]; then
# echo -e "Execution Success!"
# else
# echo -e "Execution Fail!"
# exit 1
# fi
- name: MySQL simple examples
run: |
cd mysql
cargo build --target wasm32-wasi --release
wasmedge compile target/wasm32-wasi/release/query.wasm query.wasm
wasmedge compile target/wasm32-wasi/release/insert.wasm insert.wasm
resp=$(wasmedge --env "DATABASE_URL=mysql://root:root@127.0.0.1:3306/mysql" query.wasm 2>&1)
echo "$resp"
if [[ $resp == *"localhost"* ]]; then
echo -e "Execution Success!"
else
echo -e "Execution Fail!"
exit 1
fi
resp=$(wasmedge --env "DATABASE_URL=mysql://root:root@localhost:3306/mysql" insert.wasm 2>&1)
echo "$resp"
if [[ $resp == *"foo"* ]]; then
echo -e "Execution Success!"
else
echo -e "Execution Fail!"
exit 1
fi
- name: Redis examples
run: |
cd redis
cargo build --target wasm32-wasi --release
wasmedge compile target/wasm32-wasi/release/wasmedge-redis-client-examples.wasm wasmedge-redis-client-examples.wasm
resp=$(wasmedge --env "REDIS_URL=redis://localhost/" wasmedge-redis-client-examples.wasm 2>&1)
echo "$resp"
if [[ $resp == *"UTC"* ]]; then
echo -e "Execution Success!"
else
echo -e "Execution Fail!"
exit 1
fi
- name: PostgresSQL examples
run: |
cd postgres
cargo build --target wasm32-wasi --release
wasmedge compile target/wasm32-wasi/release/crud.wasm crud.wasm
resp=$(wasmedge --env "DATABASE_URL=postgres://wasmedge:mysecret@localhost/testdb" crud.wasm 2>&1)
echo "$resp"
# - name: Anna KVS examples
# run: |
# cd anna
# cargo build --target wasm32-wasi --release
# wasmedgec target/wasm32-wasi/release/putget.wasm putget.wasm
# resp=$(wasmedge putget.wasm 2>&1)
# echo "$resp"
# if [[ $resp == *"UTC"* ]]; then
# echo -e "Execution Success!"
# else
# echo -e "Execution Fail!"
# exit 1
# fi