Skip to content
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

Bump postgres ci windows #10691

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 27 additions & 25 deletions .github/actions/setup-postgres-windows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,39 @@ description: "Set up postgres service on windows vm for dbt integration tests"
runs:
using: "composite"
steps:
- shell: bash
- shell: pwsh
run: |
# The Windows runner has some PostgreSQL environment variables set
# that may confuse users since they may be irrelevant to the
# PostgreSQL server we're using. Since GitHub actions does not
# support unsetting environment variables, the best we can do is to
# clear their values in order to indicate they must not be used.
# for name in "PGROOT" "PGDATA" "PGBIN" "PGUSER" "PGPASSWORD"; do
# echo "$name=" >> $GITHUB_ENV
# done
# Download postgres16
$url = "https://get.enterprisedb.com/postgresql/postgresql-16.1-1-windows-x64.exe"
$checkAccess = [System.Net.WebRequest]::Create($url)
$response = $checkAccess.GetResponse()
$installerUrl = $response.ResponseUri.OriginalString

choco install postgresql16 \
--params "/Password:password" \
--ia "--enable-components server,commandlinetools --extract-only 1" \
--no-progress
# Invoke Install-Binary function
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
Install-Binary `
-Url $url `
-InstallArgs $installerArgs `
-ExpectedSignature (Get-ToolsetContent).postgresql.signature

PG_BINDIR="C:\Program Files\PostgreSQL\16\bin"
PG_LIBDIR="C:\Program Files\PostgreSQL\16\lib"
# Get Path to pg_ctl.exe
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName

echo "$PG_BINDIR" >> $GITHUB_PATH
echo "PQ_LIB_DIR=$PG_LIBDIR" >> $GITHUB_ENV
# Parse output of command above to obtain pure path
$pgBin = Split-Path -Path $pgPath.split('"')[1]
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
$pgData = Join-Path $pgRoot "data"

PGBIN="C:\Program Files\PostgreSQL\16\bin"
PGROOT="C:\Program Files\PostgreSQL\16"
PGDATA="C:\Program Files\PostgreSQL\16\data"
# Validate PostgreSQL installation
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
$exitCode = $pgReady.ExitCode

if ($exitCode -ne 0) {
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
exit $exitCode
}

echo "PGBIN=$PGBIN" >> $GITHUB_ENV
echo "PGROOT=$PGROOT" >> $GITHUB_ENV
echo "PGDATA=$PGDATA" >> $GITHUB_ENV
- shell: pwsh
run: |
$pgService = Get-Service -Name postgresql*
Set-Service -InputObject $pgService -Status running -StartupType automatic
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
Expand Down
Loading