File tree Expand file tree Collapse file tree 1 file changed +25
-14
lines changed
Expand file tree Collapse file tree 1 file changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -30,24 +30,33 @@ jobs:
3030 matrix :
3131 rust : [1.90.0]
3232
33- # 使用服务容器提供测试依赖
34- services :
35- # httpbin 服务
36- httpbin :
37- image : kennethreitz/httpbin:latest
38- ports :
39- - 8888:80
40- options : >-
41- --health-cmd "python -c 'import requests; requests.get(\"http://localhost/get\")'"
42- --health-interval 10s
43- --health-timeout 10s
44- --health-retries 10
45- --health-start-period 20s
46-
4733 steps :
4834 - name : Checkout code
4935 uses : actions/checkout@v5
5036
37+ - name : Start httpbin
38+ run : |
39+ # 使用 httpbin 官方镜像
40+ docker run -d \
41+ --name httpbin \
42+ -p 8888:80 \
43+ kennethreitz/httpbin:latest
44+
45+ # 等待服务就绪
46+ echo "Waiting for httpbin to be ready..."
47+ for i in {1..30}; do
48+ if curl -f http://localhost:8888/get > /dev/null 2>&1; then
49+ echo "✅ httpbin is ready!"
50+ break
51+ fi
52+ if [ $i -eq 30 ]; then
53+ echo "❌ httpbin failed to start"
54+ docker logs httpbin
55+ exit 1
56+ fi
57+ sleep 2
58+ done
59+
5160 - name : Start json-server
5261 run : |
5362 # 使用 Node.js 官方镜像运行 json-server
@@ -154,6 +163,8 @@ jobs:
154163 - name : Cleanup test services
155164 if : always()
156165 run : |
166+ docker stop httpbin || true
167+ docker rm httpbin || true
157168 docker stop json-api || true
158169 docker rm json-api || true
159170 docker stop ws-echo || true
You can’t perform that action at this time.
0 commit comments