Skip to content

Commit

Permalink
Re-try to start WebDriver on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Dec 11, 2024
1 parent 514fc38 commit 963a237
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,45 @@ jobs:
- name: Start and set WebDriver
if: matrix.driver.browser == true
run: |
${{ matrix.driver.binary }} --port=9000 &
echo "${{ matrix.driver.env }}_REMOTE=http://127.0.0.1:9000" >> $GITHUB_ENV
iteration=5
while true; do
if (( iteration == 0 )); then
echo "CI: Failed to start driver."
exit 1
fi
(( iteration-- ))
${{ matrix.driver.binary }} --port=9000 2>stderr &
process_pid=$!
tail -f stderr >&2 &
while true; do
sleep 1
if [[ $(wc -l < stderr) -gt 0 ]]; then
echo "CI: WebDriver failed"
kill -SIGKILL $process_pid || true
echo
echo "CI: stderr:"
sed 's/^/CI: /' stderr
echo
echo "CI: Re-trying to start the WebDriver."
break
else
port=$(lsof -p $process_pid -a -i4| tail -n +2 | awk '{print $9}' | cut -d: -f2)
if [[ $port ]]; then
echo "Successfully started WebDriver on port $port."
echo "${{ matrix.driver.env }}_REMOTE=http://127.0.0.1:9000" >> $GITHUB_ENV
break 2
fi
fi
done
done
- name: Set environment
if: matrix.environment.name != ''
run: echo "${{ matrix.environment.name }}=1" >> $GITHUB_ENV
Expand Down

0 comments on commit 963a237

Please sign in to comment.