Skip to content

[Backport 1.9.latest] Add retry to macos postgres setup (#11432) #11438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .github/actions/setup-postgres-macos/action.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/actions/setup-postgres-macos/setup_db.sh

This file was deleted.

7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -284,7 +284,12 @@ jobs:

- name: Set up postgres (macos)
if: runner.os == 'macOS'
uses: ./.github/actions/setup-postgres-macos

uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: ./test/setup_db.sh

- name: Set up postgres (windows)
if: runner.os == 'Windows'
10 changes: 7 additions & 3 deletions .github/workflows/test-repeater.yml
Original file line number Diff line number Diff line change
@@ -99,9 +99,13 @@ jobs:
run: make setup-db

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

- name: "Set up postgres (windows)"
if: inputs.os == 'windows-latest'
28 changes: 28 additions & 0 deletions test/setup_db.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#!/bin/bash
set -x

brew install postgresql@16
brew link postgresql@16 --force

# Add the services tap and ensure PATH is updated
brew tap homebrew/services
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"

# Start PostgreSQL using the full command instead of brew services
pg_ctl -D /opt/homebrew/var/postgresql@16 start

echo "Check PostgreSQL service is running"
i=10
COMMAND='pg_isready'
while [ $i -gt -1 ]; do
if [ $i == 0 ]; then
echo "PostgreSQL service not ready, all attempts exhausted"
exit 1
fi
echo "Check PostgreSQL service status"
eval $COMMAND && break
echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i"
sleep 10
((i--))
done

createuser -s postgres

env | grep '^PG'

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