Skip to content

Commit c63e0fe

Browse files
ci: Wait 5 seconds for the test server to start (#5551)
GH actions couldn't send a curl request to the test server. As we launch the server in the background, GH actions could require some time until the test server launches. Therefore, we now check for 5 seconds in a loop if it runs. Fixes GH-5550
1 parent 079bcc8 commit c63e0fe

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,8 @@ jobs:
171171
- name: Print hardware info
172172
run: system_profiler SPHardwareDataType
173173

174-
- name: Allow test-server to run
175-
run: chmod +x ./test-server-exec
176-
- run: ./test-server-exec &
177-
178-
- name: Check test-server runs
179-
run: curl http://localhost:8080/echo-baggage-header
174+
- name: Start Test Server
175+
run: ./scripts/start-test-server.sh
180176

181177
- run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}}
182178

scripts/start-test-server.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
log() {
6+
echo "[$(date '+%H:%M:%S')] $1"
7+
}
8+
9+
is_server_running() {
10+
curl -s http://localhost:8080/echo-baggage-header > /dev/null 2>&1
11+
}
12+
13+
log "🚀 Starting test server..."
14+
15+
log "Make the test server executable"
16+
chmod +x ./test-server-exec
17+
18+
log "Start the test server in the background"
19+
./test-server-exec &
20+
21+
log "⏳ Waiting for 5 seconds that the test server to responds"
22+
23+
start_time=$(date +%s)
24+
server_started=false
25+
26+
while true; do
27+
if is_server_running; then
28+
log "✅ Test server is running and responding."
29+
server_started=true
30+
break
31+
else
32+
log "⏳ Test server is not yet responding, waiting..."
33+
fi
34+
35+
current_time=$(date +%s)
36+
elapsed=$((current_time - start_time))
37+
38+
if [ $elapsed -ge 5 ]; then
39+
break
40+
fi
41+
42+
sleep 0.1
43+
done
44+
45+
if [ "$server_started" = true ]; then
46+
log "✅ Test server successfully started and is responding at http://localhost:8080"
47+
else
48+
log "❌ Test server failed to start or is not responding after 5 seconds"
49+
exit 1
50+
fi

0 commit comments

Comments
 (0)