mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Windows] Pin PostgreSQL version installed in the toolset (#4492)
This commit is contained in:
@@ -1,23 +1,27 @@
|
|||||||
#Define user and password for PostgreSQL database
|
# Define user and password for PostgreSQL database
|
||||||
$pgUser = "postgres"
|
$pgUser = "postgres"
|
||||||
$pgPwd = "root"
|
$pgPwd = "root"
|
||||||
|
|
||||||
#Prepare environment variable for validation
|
# Prepare environment variable for validation
|
||||||
Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
|
Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
|
||||||
Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
|
Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
|
||||||
|
|
||||||
#Install latest PostgreSQL
|
# Define latest available version to install based on version specified in the toolset
|
||||||
Choco-Install -PackageName postgresql -ArgumentList "--params", "'/Password:$pgPwd /NoPath'", "--params-global"
|
$toolsetVersion = (Get-ToolsetContent).postgresql.version
|
||||||
|
$latestChocoPackage = Get-LatestChocoPackageVersion -TargetVersion $toolsetVersion -PackageName "postgresql"
|
||||||
|
|
||||||
#Get Path to pg_ctl.exe
|
# Install latest PostgreSQL
|
||||||
|
Choco-Install -PackageName postgresql -ArgumentList "--params", "'/Password:$pgPwd /NoPath'", "--params-global", "--version=$latestChocoPackage"
|
||||||
|
|
||||||
|
# Get Path to pg_ctl.exe
|
||||||
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
||||||
|
|
||||||
#Parse output of command above to obtain pure path
|
# Parse output of command above to obtain pure path
|
||||||
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
||||||
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
||||||
$pgData = Join-Path $pgRoot "data"
|
$pgData = Join-Path $pgRoot "data"
|
||||||
|
|
||||||
#Validate PostgreSQL installation
|
# Validate PostgreSQL installation
|
||||||
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
|
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
|
||||||
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
|
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
|
||||||
$exitCode = $pgReady.ExitCode
|
$exitCode = $pgReady.ExitCode
|
||||||
@@ -28,12 +32,12 @@ if ($exitCode -ne 0)
|
|||||||
exit $exitCode
|
exit $exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
#Added PostgreSQL environment variable
|
# Added PostgreSQL environment variable
|
||||||
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
|
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
|
||||||
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
|
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
|
||||||
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
|
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
|
||||||
|
|
||||||
#Stop and disable PostgreSQL service
|
# Stop and disable PostgreSQL service
|
||||||
$pgService = Get-Service -Name postgresql*
|
$pgService = Get-Service -Name postgresql*
|
||||||
Stop-Service -InputObject $pgService
|
Stop-Service -InputObject $pgService
|
||||||
Set-Service -InputObject $pgService -StartupType Disabled
|
Set-Service -InputObject $pgService -StartupType Disabled
|
||||||
|
|||||||
@@ -51,6 +51,16 @@ Describe "PostgreSQL" {
|
|||||||
$StartType | Should -Be "Disabled"
|
$StartType | Should -Be "Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context "PostgreSQL version" {
|
||||||
|
It "PostgreSQL version should correspond to the version in the toolset" {
|
||||||
|
$toolsetVersion = (Get-ToolsetContent).postgresql.version
|
||||||
|
# Client version
|
||||||
|
(&$Env:PGBIN\psql --version).split()[-1] | Should -BeLike "$toolsetVersion*"
|
||||||
|
# Server version
|
||||||
|
(&$Env:PGBIN\pg_config --version).split()[-1] | Should -BeLike "$toolsetVersion*"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "MySQL" {
|
Describe "MySQL" {
|
||||||
|
|||||||
@@ -432,5 +432,8 @@
|
|||||||
},
|
},
|
||||||
"llvm": {
|
"llvm": {
|
||||||
"version": "13"
|
"version": "13"
|
||||||
|
},
|
||||||
|
"postgresql": {
|
||||||
|
"version": "14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,5 +464,8 @@
|
|||||||
},
|
},
|
||||||
"llvm": {
|
"llvm": {
|
||||||
"version": "13"
|
"version": "13"
|
||||||
|
},
|
||||||
|
"postgresql": {
|
||||||
|
"version": "14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,5 +313,8 @@
|
|||||||
},
|
},
|
||||||
"php": {
|
"php": {
|
||||||
"version": "8.0"
|
"version": "8.0"
|
||||||
|
},
|
||||||
|
"postgresql": {
|
||||||
|
"version": "14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user