Skip to content

Commit 37e409e

Browse files
mmizutaniarkhipov
authored andcommitted
Fix Windows CI issues with PostgreSQL 17: uninstall preinstalled version, clean up services, and stabilize test execution
1 parent c562eb6 commit 37e409e

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

.github/workflows/build-win.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ jobs:
5757
$psql_opt = "--bindir"
5858
}
5959
60-
if ("$pg_version" -eq "14") {
61-
& "C:\Program Files\PostgreSQL\14\uninstall-postgresql.exe" --mode unattended 2>&1 | Out-Default
62-
Remove-Item -Recurse -Force "C:\Program Files\PostgreSQL\14"
60+
# Uninstall existing PostgreSQL installation in windows-latest (windows-2025) runner
61+
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md#postgresql
62+
if ("$pg_version" -eq "17") {
63+
& "C:\Program Files\PostgreSQL\17\uninstall-postgresql.exe" --mode unattended 2>&1 | Out-Default
64+
Remove-Item -Recurse -Force "C:\Program Files\PostgreSQL\17"
6365
}
6466
6567
"PG_VERSION=$pg_version" >> $env:GITHUB_ENV
@@ -96,25 +98,39 @@ jobs:
9698
run: |
9799
$ErrorActionPreference = "Stop"
98100
99-
Stop-Service -Name "postgresql$env:X64-$env:PG_VERSION"
101+
$serviceName = "postgresql$env:X64-$env:PG_VERSION"
102+
$pgData = "C:\pgdata"
103+
$pgPort = "55432"
104+
105+
$env:PGPORT = $pgPort
106+
$env:PGHOST = "localhost"
107+
$env:Path = "$env:PG_ROOT\bin;$env:Path"
108+
109+
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
110+
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
111+
& "$env:PG_ROOT\bin\pg_ctl.exe" unregister -N "$serviceName" 2>&1 | Out-Default
112+
Start-Sleep -Seconds 2
113+
}
114+
Remove-Item -Recurse -Force "$pgData" -ErrorAction SilentlyContinue
100115
101116
Copy ".\$env:RELEASE_DIR\temporal_tables.dll" "$env:PG_ROOT\lib"
102117
Copy ".\*.sql" "$env:PG_ROOT\share\extension"
103118
Copy ".\*.control" "$env:PG_ROOT\share\extension"
104119
105120
Set-Content -path pg.pass -value $env:PGPASSWORD -encoding ascii
106-
& "$env:PG_ROOT\bin\initdb.exe" -A md5 -U postgres --pwfile=pg.pass C:\pgdata 2>&1 | Out-Default
107-
& "$env:PG_ROOT\bin\pg_ctl.exe" register -S demand -N "postgresql$env:X64-$env:PG_VERSION" -D c:\pgdata 2>&1 | Out-Default
121+
& "$env:PG_ROOT\bin\initdb.exe" -A md5 -U postgres --pwfile=pg.pass "$pgData" 2>&1 | Out-Default
122+
& "$env:PG_ROOT\bin\pg_ctl.exe" register -S demand -N "$serviceName" -D "$pgData" -o "-p $pgPort" 2>&1 | Out-Default
108123
109-
Start-Service -Name "postgresql$env:X64-$env:PG_VERSION"
124+
Start-Service -Name "$serviceName"
110125
111126
Get-ChildItem "$env:PG_REGRESS"
112-
& "C:\Program Files\PostgreSQL\17\lib\pgxs\src\test\regress\pg_regress.exe" --help 2>&1 | Out-Default
113127
114128
& "$env:PG_REGRESS" "$env:PSQL_OPT=$env:PG_ROOT\bin" --dbname=pl_regression install no_system_period invalid_system_period no_history_table no_history_system_period invalid_types invalid_system_period_values versioning versioning_custom_system_time structure uninstall 2>&1 | Out-Default
115129
116130
if ($LASTEXITCODE -ne 0) {
117-
Get-Content -Path ".\regression.diffs" | Out-Printer
131+
if (Test-Path -Path ".\regression.diffs") {
132+
Get-Content -Path ".\regression.diffs" | Out-Host
133+
}
118134
Write-Error "Tests failed"
119135
}
120136
env:

0 commit comments

Comments
 (0)