mirror of
https://github.com/actions/runner-images.git
synced 2025-12-17 15:20:11 +00:00
* ,oving to the pester approach part #5 * moving to the pester approach part #5 * fixed PostgreSQL tests * return Validate-Svn.ps1 * fixed Selenium test * fixed rust test * fix rust test
This commit is contained in:
committed by
GitHub
parent
956b8a0093
commit
0c4dca229d
@@ -173,12 +173,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Docker.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-PowershellCore.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -275,12 +269,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-WDK.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -522,12 +510,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -708,18 +690,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Rust.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Sbt.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
|
||||
@@ -181,12 +181,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Docker.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-PowershellCore.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -268,12 +262,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-WDK.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -701,24 +689,12 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Rust.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Svn.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Sbt.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
@@ -767,12 +743,6 @@
|
||||
"{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
"{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts":[
|
||||
|
||||
@@ -19,7 +19,7 @@ function Get-WhichTool($tool) {
|
||||
|
||||
# Gets value of environment variable by the name
|
||||
function Get-EnvironmentVariable($variable) {
|
||||
return [System.Environment]::GetEnvironmentVariable($variable)
|
||||
return [System.Environment]::GetEnvironmentVariable($variable, "Machine")
|
||||
}
|
||||
|
||||
# Update environment variables without reboot
|
||||
|
||||
@@ -19,7 +19,25 @@ $pgBin = Split-Path -Path $pgPath.split('"')[1]
|
||||
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
||||
$pgData = Join-Path $pgRoot "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
|
||||
}
|
||||
|
||||
#Added PostgreSQL environment variable
|
||||
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
|
||||
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
|
||||
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
|
||||
|
||||
#Stop and disable PostgreSQL service
|
||||
$pgService = Get-Service -Name postgresql*
|
||||
Stop-Service -InputObject $pgService
|
||||
Set-Service -InputObject $pgService -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "PostgreSQL"
|
||||
@@ -4,3 +4,5 @@
|
||||
################################################################################
|
||||
|
||||
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI -Quiet"
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "PowerShell Core"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
Import-Module -Name ImageHelpers
|
||||
|
||||
# Rust Env
|
||||
$env:RUSTUP_HOME="C:\Rust\.rustup"
|
||||
$env:CARGO_HOME="C:\Rust\.cargo"
|
||||
$env:RUSTUP_HOME = "C:\Rust\.rustup"
|
||||
$env:CARGO_HOME = "C:\Rust\.cargo"
|
||||
|
||||
# Download the latest rustup-init.exe for Windows x64
|
||||
# See https://rustup.rs/#
|
||||
@@ -49,3 +49,10 @@ Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force
|
||||
|
||||
# Update Run key to run a script at logon
|
||||
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "RUSTSYM" -Value $cmdPath
|
||||
|
||||
# Create temporary symlinks to properly validate tools version
|
||||
Set-Location -Path $env:UserProfile
|
||||
$null = New-Item -Name ".rustup" -Value $env:RUSTUP_HOME -ItemType Junction
|
||||
$null = New-Item -Name ".cargo" -Value $env:CARGO_HOME -ItemType Junction
|
||||
|
||||
Invoke-PesterTests -TestFile "Rust"
|
||||
@@ -14,7 +14,5 @@ $env:SBT_HOME="${env:ProgramFiles(x86)}\sbt"
|
||||
|
||||
# Add sbt binaries to the path
|
||||
Add-MachinePathItem "$env:SBT_HOME\bin"
|
||||
$env:Path = Get-MachinePath
|
||||
|
||||
# Done
|
||||
exit 0
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Sbt"
|
||||
|
||||
@@ -32,3 +32,5 @@ Start-DownloadWithRetry -Url $seleniumReleaseUrl -Name $seleniumFileName -Downlo
|
||||
Write-Host "Add selenium jar to the environment variables..."
|
||||
$seleniumBinPath = Join-Path $seleniumDirectory $seleniumFileName
|
||||
setx "SELENIUM_JAR_PATH" "$($seleniumBinPath)" /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Selenium"
|
||||
@@ -11,3 +11,5 @@ New-Item -Path $temp_install_dir -ItemType Directory -Force
|
||||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
|
||||
|
||||
WebpiCmd.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEula /XML:https://webpifeed.blob.core.windows.net/webpifeed/5.1/WebProductList.xml
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "ServiceFabricSDK"
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
$pgReadyPath = Join-Path ${env:PGBIN} "pg_isready.exe"
|
||||
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
|
||||
$exitCode = $pgReady.ExitCode
|
||||
|
||||
if ($exitCode -eq 0)
|
||||
{
|
||||
Write-Host -Object "PostgreSQL has been successfully installed."
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
#Stop and disable PostgreSQL service
|
||||
$pgService = Get-Service -Name postgresql*
|
||||
Stop-Service -InputObject $pgService
|
||||
Set-Service -InputObject $pgService -StartupType Disabled
|
||||
@@ -1,15 +0,0 @@
|
||||
################################################################################
|
||||
## File: Validate-PowershellCore.ps1
|
||||
## Desc: Validate Powershell Core
|
||||
################################################################################
|
||||
|
||||
if (Get-Command -Name 'pwsh')
|
||||
{
|
||||
Write-Host 'pwsh is on PATH'
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host 'pwsh is not on PATH'
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
################################################################################
|
||||
## File: Validate-Rust.ps1
|
||||
## Desc: Verify that Rust is on the path and output version information.
|
||||
################################################################################
|
||||
|
||||
if (Get-Command -Name 'rustc')
|
||||
{
|
||||
Push-Location -Path $env:UserProfile
|
||||
New-Item -Name ".rustup" -Value "C:\Rust\.rustup" -ItemType Junction
|
||||
New-Item -Name ".cargo" -Value "C:\Rust\.cargo" -ItemType Junction
|
||||
$RustcVersion = rustc --version
|
||||
Write-Host "$RustcVersion is on the path"
|
||||
Pop-Location
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "rustc is not on the path"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-Not (Get-Command -Name 'cargo-audit')){
|
||||
Write-Host "cargo audit is not on the path"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-Not (Get-Command -Name 'cargo-outdated')){
|
||||
Write-Host "cargo outdated is not on the path"
|
||||
exit 1
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
################################################################################
|
||||
## File: Validate-Sbt.ps1
|
||||
## Desc: Validate sbt for Windows
|
||||
################################################################################
|
||||
|
||||
if (Get-Command -Name 'sbt')
|
||||
{
|
||||
Write-Host 'sbt is on the path'
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host 'sbt is not on path.'
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
################################################################################
|
||||
## File: Validate-ServiceFabricSDK.ps1
|
||||
## Desc: Validate ServiceFabricSDK
|
||||
################################################################################
|
||||
|
||||
$modules = Get-Module -Name ServiceFabric -ListAvailable
|
||||
|
||||
if (($modules | Measure-Object).Count -gt 0)
|
||||
{
|
||||
$modules
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "ServiceFabric Module is not present, it might not be installed"
|
||||
throw "ServiceFabric Module is not present, it might not be installed"
|
||||
}
|
||||
|
||||
@@ -134,3 +134,17 @@ Describe "Internet Explorer" {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Selenium" {
|
||||
It "Selenium 'C:\selenium' path exists" {
|
||||
"C:\selenium" | Should -Exist
|
||||
}
|
||||
|
||||
It "Selenium Server 'selenium-server-standalone.jar' is installed" {
|
||||
"C:\selenium\selenium-server-standalone.jar" | Should -Exist
|
||||
}
|
||||
|
||||
It "SELENIUM_JAR_PATH environment variable exists" {
|
||||
Get-EnvironmentVariable "SELENIUM_JAR_PATH" | Should -BeExactly "C:\selenium\selenium-server-standalone.jar"
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,52 @@ Describe "MongoDB" {
|
||||
"$ToolName --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "PostgreSQL" {
|
||||
$psqlTests = @(
|
||||
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT"}
|
||||
@{envVar = "PGBIN"; pgPath = Get-EnvironmentVariable "PGBIN"}
|
||||
@{envVar = "PGDATA"; pgPath = Get-EnvironmentVariable "PGDATA"}
|
||||
)
|
||||
|
||||
Context "Environment variable" {
|
||||
It "PGUSER contains postgres" {
|
||||
Get-EnvironmentVariable "PGUSER" | Should -Be "postgres"
|
||||
}
|
||||
|
||||
It "PGPASSWORD contains root" {
|
||||
Get-EnvironmentVariable "PGPASSWORD" | Should -Be "root"
|
||||
}
|
||||
|
||||
It "<envVar> environment variable exists" -TestCases $psqlTests {
|
||||
Get-EnvironmentVariable $envVar | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Context "Path" {
|
||||
It "<pgPath> path exists" -TestCases $psqlTests {
|
||||
$pgPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Service" {
|
||||
$psqlService = Get-Service -Name postgresql*
|
||||
$psqlServiceTests = @{
|
||||
Name = $psqlService.Name
|
||||
Status = $psqlService.Status
|
||||
StartType = $psqlService.StartType
|
||||
}
|
||||
|
||||
It "<Name> service is stopped" -TestCases $psqlServiceTests {
|
||||
$Status | Should -Be "Stopped"
|
||||
}
|
||||
|
||||
It "<Name> service is disabled" -TestCases $psqlServiceTests {
|
||||
$StartType | Should -Be "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "MySQL" {
|
||||
It "MySQL CLI" {
|
||||
"mysql -V" | Should -ReturnZeroExitCode
|
||||
|
||||
27
images/win/scripts/Tests/Rust.Tests.ps1
Normal file
27
images/win/scripts/Tests/Rust.Tests.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
Describe "Rust" {
|
||||
$rustTools = @(
|
||||
@{ToolName = "rustup"; binPath = "C:\Rust\.cargo\bin\rustup.exe"}
|
||||
@{ToolName = "rustc"; binPath = "C:\Rust\.cargo\bin\rustc.exe"}
|
||||
@{ToolName = "cargo"; binPath = "C:\Rust\.cargo\bin\cargo.exe"}
|
||||
@{ToolName = "cargo audit"; binPath = "C:\Rust\.cargo\bin\cargo-audit.exe"}
|
||||
@{ToolName = "cargo outdated"; binPath = "C:\Rust\.cargo\bin\cargo-outdated.exe"}
|
||||
)
|
||||
|
||||
$rustEnvNotExists = @(
|
||||
@{envVar = "RUSTUP_HOME"}
|
||||
@{envVar = "CARGO_HOME"}
|
||||
)
|
||||
|
||||
It "C:\Rust\.rustup and C:\Rust\.cargo folders exist" {
|
||||
"C:\Rust\.rustup", "C:\Rust\.cargo" | Should -Exist
|
||||
}
|
||||
|
||||
It "<envVar> environment variable does not exist" -TestCases $rustEnvNotExists {
|
||||
[Environment]::GetEnvironmentVariables("Machine").ContainsKey($envVar) | Should -BeFalse
|
||||
}
|
||||
|
||||
It "<ToolName> is installed to the '<binPath>' folder" -TestCases $rustTools {
|
||||
"$ToolName --version" | Should -ReturnZeroExitCode
|
||||
$binPath | Should -Exist
|
||||
}
|
||||
}
|
||||
@@ -134,3 +134,25 @@ Describe "Perl" {
|
||||
"perl --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "PowerShell Core" {
|
||||
It "pwsh" {
|
||||
"pwsh --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Execute 2+2 command" {
|
||||
pwsh -Command "2+2" | Should -BeExactly 4
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Sbt" {
|
||||
It "sbt" {
|
||||
"sbt --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "ServiceFabricSDK" {
|
||||
It "PowerShell Module" {
|
||||
Get-Module -Name ServiceFabric -ListAvailable | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user