Skip to content

feat: add wescale wesql cluster workflow #29

feat: add wescale wesql cluster workflow

feat: add wescale wesql cluster workflow #29

name: "Ubuntu Docker Cluster"
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
setup:
name: "Ubuntu Docker Cluster"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Start MySQL Server
run: |
chmod -R 777 .
chown -R $(whoami) .
cd ./examples/wesql-server && ./start_mysql_server.sh
- name: Install MySQL client
run: |
sudo apt-get update && sudo apt-get install -y mysql-client
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.1
- name: Compile source
timeout-minutes: 30
run: |
pwd
ls -alF examples/wesql-server/vtdataroot
whoami
make failpoint-enable
make build
make failpoint-disable
- name: Start WeScale
run: |
cd ./examples/wesql-server
# 在一个终端会话中运行初始化脚本并通过 tee 输出日志
./init_single_node_cluster.sh 2>&1 | tee init_script_logs.txt &
INIT_PID=$!
# 实时显示日志文件内容
tail -f init_script_logs.txt &
TAIL_PID=$!
echo "Waiting for WeScale to be ready..."
if timeout 10 bash -c 'until nc -z localhost 15306; do sleep 2; echo "Waiting for port 15306..."; done'; then
echo "Port 15306 is now available"
# 停止 tail
kill $TAIL_PID
wait $INIT_PID
echo "Initialization completed successfully"
else
echo "Timeout waiting for port 15306"
# 停止 tail 和初始化脚本
kill $TAIL_PID
kill $INIT_PID
echo "=== Final logs ==="
cat init_script_logs.txt
exit 1
fi
- name: Check Vitess Tablets
if: always()
run: |
# Attempt to connect and execute command, display logs if failed
if ! mysql -h127.0.0.1 -P15306 -uroot -ppasswd -e "show vitess_tablets"; then
echo "Failed to execute MySQL command"
echo "=== Initialization Script Logs ==="
cat ./examples/wesql-server/init_script_logs.txt
exit 1
fi
- name: Install Tmate
if: always()
run: sudo apt-get install tmate
- name: Start Tmate session
if: always()
run: |
tmate -S /tmp/tmate.sock new-session -d
tmate -S /tmp/tmate.sock wait tmate-ready
echo "SSH access: $(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}')"
echo "Web access: $(tmate -S /tmp/tmate.sock display -p '#{tmate_web}')"
TIMEOUT=1800 # 30 minutes
INTERVAL=1 # 1 second
START_TIME=$(date +%s)
while true; do
sleep "$INTERVAL"
CURRENT_TIME=$(date +%s)
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
# Check if timeout is reached
if [ "$ELAPSED_TIME" -ge "$TIMEOUT" ]; then
echo "Timeout reached while waiting for the container."
break
fi
done
continue-on-error: true