From ab500a9709e596e6d762855470932eed31267f36 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Wed, 11 Sep 2024 12:43:33 -0400 Subject: [PATCH] install postgres-16 in CI (#10687) --- .../actions/setup-postgres-linux/action.yml | 11 ++++++++++- .../actions/setup-postgres-macos/action.yml | 3 ++- .../actions/setup-postgres-windows/action.yml | 18 ++++++++++++++++-- test/setup_db.sh | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-postgres-linux/action.yml b/.github/actions/setup-postgres-linux/action.yml index 1c8fc772a8a..30050b1a38d 100644 --- a/.github/actions/setup-postgres-linux/action.yml +++ b/.github/actions/setup-postgres-linux/action.yml @@ -5,6 +5,15 @@ runs: steps: - shell: bash run: | - sudo systemctl start postgresql.service + sudo apt-get --purge remove postgresql postgresql-* + sudo apt update -y + sudo apt install gnupg2 wget vim -y + sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg + sudo apt update -y + sudo apt install postgresql-16 + sudo apt-get -y install postgresql postgresql-contrib + sudo systemctl start postgresql + sudo systemctl enable postgresql pg_isready sudo -u postgres bash ${{ github.action_path }}/setup_db.sh diff --git a/.github/actions/setup-postgres-macos/action.yml b/.github/actions/setup-postgres-macos/action.yml index af9a9fe1657..3ce1cd7144e 100644 --- a/.github/actions/setup-postgres-macos/action.yml +++ b/.github/actions/setup-postgres-macos/action.yml @@ -5,7 +5,8 @@ runs: steps: - shell: bash run: | - brew services start postgresql + brew install postgresql@16 + brew services start postgresql@16 echo "Check PostgreSQL service is running" i=10 COMMAND='pg_isready' diff --git a/.github/actions/setup-postgres-windows/action.yml b/.github/actions/setup-postgres-windows/action.yml index 419b5e267cb..2b6217d360f 100644 --- a/.github/actions/setup-postgres-windows/action.yml +++ b/.github/actions/setup-postgres-windows/action.yml @@ -5,8 +5,22 @@ runs: steps: - shell: pwsh run: | - $pgService = Get-Service -Name postgresql* + Write-Host -Object "Installing PostgreSQL 16 as windows service..." + $installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended") + $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" + Start-Process -FilePath $filePath -ArgumentList $installerArgs -Wait -PassThru + + Write-Host -Object "Validating PostgreSQL 16 Install..." + Get-Service -Name postgresql* + $pgReady = Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru + $exitCode = $pgReady.ExitCode + if ($exitCode -ne 0) { + Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" + exit $exitCode + } + + Write-Host -Object "Starting PostgreSQL 16 Service..." + $pgService = Get-Service -Name postgresql-x64-16 Set-Service -InputObject $pgService -Status running -StartupType automatic - Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru $env:Path += ";$env:PGBIN" bash ${{ github.action_path }}/setup_db.sh diff --git a/test/setup_db.sh b/test/setup_db.sh index de59bf0fac6..2d877a9e8df 100755 --- a/test/setup_db.sh +++ b/test/setup_db.sh @@ -39,6 +39,7 @@ for i in {1..10}; do done; createdb dbt +psql -c "SELECT version();" psql -c "CREATE ROLE root WITH PASSWORD 'password';" psql -c "ALTER ROLE root WITH LOGIN;" psql -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"