Skip to content

Commit ab500a9

Browse files
authored
install postgres-16 in CI (#10687)
1 parent 1d3d315 commit ab500a9

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ runs:
55
steps:
66
- shell: bash
77
run: |
8-
sudo systemctl start postgresql.service
8+
sudo apt-get --purge remove postgresql postgresql-*
9+
sudo apt update -y
10+
sudo apt install gnupg2 wget vim -y
11+
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
12+
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
13+
sudo apt update -y
14+
sudo apt install postgresql-16
15+
sudo apt-get -y install postgresql postgresql-contrib
16+
sudo systemctl start postgresql
17+
sudo systemctl enable postgresql
918
pg_isready
1019
sudo -u postgres bash ${{ github.action_path }}/setup_db.sh

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ runs:
55
steps:
66
- shell: bash
77
run: |
8-
brew services start postgresql
8+
brew install postgresql@16
9+
brew services start postgresql@16
910
echo "Check PostgreSQL service is running"
1011
i=10
1112
COMMAND='pg_isready'

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

+16-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ runs:
55
steps:
66
- shell: pwsh
77
run: |
8-
$pgService = Get-Service -Name postgresql*
8+
Write-Host -Object "Installing PostgreSQL 16 as windows service..."
9+
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
10+
$filePath = Invoke-DownloadWithRetry -Url "https://get.enterprisedb.com/postgresql/postgresql-16.1-1-windows-x64.exe" -Path "$env:PGROOT/postgresql-16.1-1-windows-x64.exe"
11+
Start-Process -FilePath $filePath -ArgumentList $installerArgs -Wait -PassThru
12+
13+
Write-Host -Object "Validating PostgreSQL 16 Install..."
14+
Get-Service -Name postgresql*
15+
$pgReady = Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
16+
$exitCode = $pgReady.ExitCode
17+
if ($exitCode -ne 0) {
18+
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
19+
exit $exitCode
20+
}
21+
22+
Write-Host -Object "Starting PostgreSQL 16 Service..."
23+
$pgService = Get-Service -Name postgresql-x64-16
924
Set-Service -InputObject $pgService -Status running -StartupType automatic
10-
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
1125
$env:Path += ";$env:PGBIN"
1226
bash ${{ github.action_path }}/setup_db.sh

test/setup_db.sh

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ for i in {1..10}; do
3939
done;
4040

4141
createdb dbt
42+
psql -c "SELECT version();"
4243
psql -c "CREATE ROLE root WITH PASSWORD 'password';"
4344
psql -c "ALTER ROLE root WITH LOGIN;"
4445
psql -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"

0 commit comments

Comments
 (0)