diff --git a/.github/actions/setup-postgres-windows/action.yml b/.github/actions/setup-postgres-windows/action.yml index 117a6b017a6..8eae6407fb9 100644 --- a/.github/actions/setup-postgres-windows/action.yml +++ b/.github/actions/setup-postgres-windows/action.yml @@ -5,15 +5,6 @@ runs: steps: - shell: bash 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 - choco upgrade postgresql16 \ --params "/Password:password" \ --ia "--enable-components server,commandlinetools --extract-only 1" \ @@ -28,24 +19,39 @@ runs: echo "$PG_BINDIR" >> $GITHUB_PATH echo "PQ_LIB_DIR=$PG_LIBDIR" >> $GITHUB_ENV - PGBIN=PG_BINDIR - PGROOT="%ProgramFiles%\PostgreSQL\16" - PGDATA="%ProgramFiles%\PostgreSQL\16\data" + PGBIN=$PG_BINDIR + PGROOT=$(dirname $PG_BINDIR) + PGDATA="$PGROOT/data" echo "PGBIN=$PGBIN" >> $GITHUB_ENV echo "PGROOT=$PGROOT" >> $GITHUB_ENV echo "PGDATA=$PGDATA" >> $GITHUB_ENV - echo "listing contents of PGROOT: $PGROOT" + echo "PGROOT:$PGROOT" ls $PGROOT - echo "registering service using $PGBIN\pg_ctl.exe" - "$PGBIN\pg_ctl.exe" register -N "postgresql16" -D "%ProgramData%\data" -S auto - "$PGBIN\initdb.exe -D "%ProgramFiles%\PostgreSQL\16\data" + echo "PGBIN:$PGBIN" + ls $PGBIN + + echo "PGDATA:$PGDATA" + mkdir $PGDATA + ls $PGDATA + + echo "registering service using $PGBIN/pg_ctl.exe" + "$PGBIN/pg_ctl.exe" register -N "postgresql16" -D "$PGDATA" -S auto - shell: pwsh run: | - # $pgService = Get-Service -Name postgresql16 - # Set-Service -InputObject $pgService -Status running -StartupType automatic + 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 + } + + $pgService = Get-Service -Name postgresql16 + 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