update
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
name: End-to-End Tests
|
||||
|
||||
on:
|
||||
# 默认触发条件,可以在复制到具体仓库后按需调整
|
||||
push:
|
||||
branches:
|
||||
- offline
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
# 多个 IP / 域名 组合时,互不影响
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# 在这里配置要检查的环境,只需要改 base_url 即可复用
|
||||
target:
|
||||
- name: offline-145 # 仅用于日志标识
|
||||
base_url: http://127.0.0.1
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: offline
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check API services (${{ matrix.target.name }})
|
||||
env:
|
||||
BASE_URL: ${{ matrix.target.base_url }}
|
||||
run: |
|
||||
echo "当前检查环境:${BASE_URL}"
|
||||
|
||||
echo "====== 开始检查各 API 服务 /health ======"
|
||||
|
||||
services="\
|
||||
service-name:5710 \
|
||||
service-name:5711 \
|
||||
"
|
||||
|
||||
failed_services=""
|
||||
api_failed=0
|
||||
|
||||
for item in $services; do
|
||||
name="${item%%:*}"
|
||||
port="${item##*:}"
|
||||
|
||||
echo ""
|
||||
echo "------ 检查服务 ${name} (端口 ${port}) /health ------"
|
||||
|
||||
success=0
|
||||
for i in {1..10}; do
|
||||
if curl -fsS "${BASE_URL}:${port}/health" > /dev/null; then
|
||||
success=1
|
||||
break
|
||||
fi
|
||||
echo "第 ${i} 次重试,等待 5 秒..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ "${success}" -ne 1 ]; then
|
||||
echo "✗ 服务 ${name} /health 检查失败"
|
||||
failed_services="${failed_services} ${name}:${port}"
|
||||
else
|
||||
echo "✓ 服务 ${name} /health 正常"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${failed_services}" ]; then
|
||||
echo ""
|
||||
echo "✗ 以下服务健康检查失败:"
|
||||
for s in ${failed_services}; do
|
||||
echo " - ${s}"
|
||||
done
|
||||
api_failed=1
|
||||
else
|
||||
echo ""
|
||||
echo "====== 所有 API 服务健康检查通过 ======"
|
||||
fi
|
||||
|
||||
if [ "${api_failed}" -ne 0 ]; then
|
||||
echo ""
|
||||
echo "✗ API /health 检查存在失败,详见上方日志"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ 所有 API /health 检查通过"
|
||||
Reference in New Issue
Block a user