Skip to content

Commit 44e2d27

Browse files
committed
ci: harden unix installer smoke server startup
Detect python command, randomize test port, and wait for readiness before invoking one-liner installer to avoid flaky connection failures.
1 parent 86f2cd4 commit 44e2d27

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/installer-smoke.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,37 @@ jobs:
9393
shell: bash
9494
run: |
9595
set -euo pipefail
96-
port=18080
96+
port=$((RANDOM % 1000 + 18080))
9797
serve_root="$RUNNER_TEMP/serve"
9898
99-
python3 -m http.server "$port" --directory "$serve_root" >"$RUNNER_TEMP/http.log" 2>&1 &
99+
if command -v python3 >/dev/null 2>&1; then
100+
python_cmd="python3"
101+
elif command -v python >/dev/null 2>&1; then
102+
python_cmd="python"
103+
else
104+
echo "Python is required for installer smoke tests." >&2
105+
exit 1
106+
fi
107+
108+
"$python_cmd" -m http.server "$port" --directory "$serve_root" >"$RUNNER_TEMP/http.log" 2>&1 &
100109
server_pid=$!
101110
trap 'kill "$server_pid"' EXIT INT TERM
102-
sleep 2
111+
112+
ready=0
113+
for _ in $(seq 1 30); do
114+
if curl -fsS "http://127.0.0.1:${port}/tool/install.sh" >/dev/null 2>&1; then
115+
ready=1
116+
break
117+
fi
118+
sleep 1
119+
done
120+
if [ "$ready" -ne 1 ]; then
121+
echo "Local HTTP server did not become ready on port ${port}." >&2
122+
if [ -f "$RUNNER_TEMP/http.log" ]; then
123+
cat "$RUNNER_TEMP/http.log"
124+
fi
125+
exit 1
126+
fi
103127
104128
curl -fsSL "http://127.0.0.1:${port}/tool/install.sh" | \
105129
DRX_REPO=example/drx \

0 commit comments

Comments
 (0)