File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,8 +133,40 @@ jobs:
133133 - name : Start and set WebDriver
134134 if : matrix.driver.browser == true
135135 run : |
136- ${{ matrix.driver.binary }} --port=9000 &
137- echo "${{ matrix.driver.env }}_REMOTE=http://127.0.0.1:9000" >> $GITHUB_ENV
136+ iteration=5
137+
138+ while true; do
139+ if (( iteration == 0 )); then
140+ echo "CI: Failed to start driver."
141+ exit 1
142+ fi
143+
144+ (( iteration-- ))
145+
146+ ${{ matrix.driver.binary }} --port=9000 2>stderr &
147+ process_pid=$!
148+
149+ sleep 1
150+
151+ if [[ $(wc -l < stderr) -gt 0 ]]; then
152+ echo "CI: WebDriver failed"
153+ kill -SIGKILL $process_pid || true
154+ echo
155+
156+ echo "CI: stderr:"
157+ sed 's/^/CI: /' stderr
158+ echo
159+
160+ echo "CI: Re-trying to start the WebDriver."
161+ else
162+ tail -f stderr >&2 &
163+ port=$(lsof -p $process_pid -a -i4| tail -n +2 | awk '{print $9}' | cut -d: -f2)
164+ echo "Successfully started WebDriver on port $port."
165+
166+ echo "${{ matrix.driver.env }}_REMOTE=http://127.0.0.1:9000" >> $GITHUB_ENV
167+ break
168+ fi
169+ done
138170 - name : Set environment
139171 if : matrix.environment.name != ''
140172 run : echo "${{ matrix.environment.name }}=1" >> $GITHUB_ENV
You can’t perform that action at this time.
0 commit comments