Skip to content

Commit 215a984

Browse files
committed
Add retry to macos postgres setup (#11432)
* Retry macos postgres setup * Retry command instead of step * Use setup_db.sh * Simplify macos postgres setup
1 parent e8ea7a9 commit 215a984

File tree

5 files changed

+41
-39
lines changed

5 files changed

+41
-39
lines changed

.github/actions/setup-postgres-macos/action.yml

-34
This file was deleted.

.github/actions/setup-postgres-macos/setup_db.sh

-1
This file was deleted.

.github/workflows/main.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,12 @@ jobs:
284284

285285
- name: Set up postgres (macos)
286286
if: runner.os == 'macOS'
287-
uses: ./.github/actions/setup-postgres-macos
287+
288+
uses: nick-fields/retry@v3
289+
with:
290+
timeout_minutes: 10
291+
max_attempts: 3
292+
command: ./test/setup_db.sh
288293

289294
- name: Set up postgres (windows)
290295
if: runner.os == 'Windows'

.github/workflows/test-repeater.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ jobs:
9999
run: make setup-db
100100

101101
# mac and windows don't use make due to limitations with docker with those runners in GitHub
102-
- name: "Set up postgres (macos)"
103-
if: inputs.os == 'macos-14'
104-
uses: ./.github/actions/setup-postgres-macos
102+
- name: Set up postgres (macos)
103+
if: runner.os == 'macOS'
104+
uses: nick-fields/retry@v3
105+
with:
106+
timeout_minutes: 10
107+
max_attempts: 3
108+
command: ./test/setup_db.sh
105109

106110
- name: "Set up postgres (windows)"
107111
if: inputs.os == 'windows-latest'

test/setup_db.sh

+28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
#!/bin/bash
22
set -x
3+
4+
brew install postgresql@16
5+
brew link postgresql@16 --force
6+
7+
# Add the services tap and ensure PATH is updated
8+
brew tap homebrew/services
9+
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"
10+
11+
# Start PostgreSQL using the full command instead of brew services
12+
pg_ctl -D /opt/homebrew/var/postgresql@16 start
13+
14+
echo "Check PostgreSQL service is running"
15+
i=10
16+
COMMAND='pg_isready'
17+
while [ $i -gt -1 ]; do
18+
if [ $i == 0 ]; then
19+
echo "PostgreSQL service not ready, all attempts exhausted"
20+
exit 1
21+
fi
22+
echo "Check PostgreSQL service status"
23+
eval $COMMAND && break
24+
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
25+
sleep 10
26+
((i--))
27+
done
28+
29+
createuser -s postgres
30+
331
env | grep '^PG'
432

533
# If you want to run this script for your own postgresql (run with

0 commit comments

Comments
 (0)