Skip to content

Commit

Permalink
Removed PowerShell 7.0 for live test and added placeholder for PowerS…
Browse files Browse the repository at this point in the history
…hell latest (#21547)

* Removed ps 7.0 for live test and added ps latest

* Fixed issues

---------

Co-authored-by: Yunchi Wang <[email protected]>
  • Loading branch information
vidai-msft and wyunchi-ms authored Apr 15, 2023
1 parent addb46e commit 30f2df6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 35 deletions.
48 changes: 22 additions & 26 deletions .azure-pipelines/live-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ parameters:
displayName: Windows PowerShell 5.1 Version
type: string
default: 5.1
- name: ps_7_0_x
displayName: PowerShell 7.0.x Version
type: string
default: 7.0.*
- name: ps_7_2_x
displayName: PowerShell 7.2.x Version
type: string
Expand Down Expand Up @@ -76,14 +72,6 @@ jobs:
psVersion: ${{ parameters.win_ps_5_1 }}
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}

- template: util/live-test-steps.yml
parameters:
name: 'ps_7_0_x_win_2019'
vmImage: ${{ parameters.img_windows_2019 }}
osType: 'Windows'
psVersion: ${{ parameters.ps_7_0_x }}
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}

- template: util/live-test-steps.yml
parameters:
name: 'ps_7_2_x_win_2019'
Expand All @@ -102,11 +90,11 @@ jobs:

- template: util/live-test-steps.yml
parameters:
name: 'ps_7_0_x_win_2022'
vmImage: ${{ parameters.img_windows_2022 }}
name: 'ps_latest_win_2019'
vmImage: ${{ parameters.img_windows_2019 }}
osType: 'Windows'
psVersion: ${{ parameters.ps_7_0_x }}
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
psVersion: ${{ parameters.ps_latest }}
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}

- template: util/live-test-steps.yml
parameters:
Expand All @@ -126,11 +114,11 @@ jobs:

- template: util/live-test-steps.yml
parameters:
name: 'ps_7_0_x_linux'
vmImage: ${{ parameters.img_linux }}
osType: 'Linux'
psVersion: ${{ parameters.ps_7_0_x }}
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
name: 'ps_latest_win_2022'
vmImage: ${{ parameters.img_windows_2022 }}
osType: 'Windows'
psVersion: ${{ parameters.ps_latest }}
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}

- template: util/live-test-steps.yml
parameters:
Expand All @@ -150,11 +138,11 @@ jobs:

- template: util/live-test-steps.yml
parameters:
name: 'ps_7_0_x_macOS'
vmImage: ${{ parameters.img_macos }}
osType: 'MacOS'
psVersion: ${{ parameters.ps_7_0_x }}
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
name: 'ps_latest_linux'
vmImage: ${{ parameters.img_linux }}
osType: 'Linux'
psVersion: ${{ parameters.ps_latest }}
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}

- template: util/live-test-steps.yml
parameters:
Expand All @@ -171,3 +159,11 @@ jobs:
osType: 'MacOS'
psVersion: ${{ parameters.ps_7_3_x }}
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}

- template: util/live-test-steps.yml
parameters:
name: 'ps_latest_macOS'
vmImage: ${{ parameters.img_macos }}
osType: 'MacOS'
psVersion: ${{ parameters.ps_latest }}
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
2 changes: 1 addition & 1 deletion .azure-pipelines/util/live-test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
pwsh: true
targetType: filePath
filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 -RunPlatform ${{ parameters.osType }} -RepoLocation $(Build.SourcesDirectory) -DataLocation $(DataLocation)'
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 -RunPlatform ${{ parameters.osType }} -RunPowerShell ${{ parameters.psVersion }} -PowerShellLatest $(PowerShellLatest) -RepoLocation $(Build.SourcesDirectory) -DataLocation $(DataLocation)'

- task: PowerShell@2
displayName: Save live test results to Kusto
Expand Down
23 changes: 21 additions & 2 deletions tools/TestFx/Live/InvokeLiveTestScenarios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ param (
[ValidateNotNullOrEmpty()]
[string] $RunPlatform,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $RunPowerShell,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $PowerShellLatest,

[Parameter(Mandatory)]
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })]
[string] $RepoLocation,
Expand All @@ -12,20 +20,31 @@ param (
[string] $DataLocation
)

if ($RunPowerShell -eq "latest") {
$curPSVer = (Get-Variable -Name PSVersionTable -ValueOnly).PSVersion
$curMajorVer = $curPSVer.Major
$curMinorVer = $curPSVer.Minor
$curSimpleVer = "$curMajorVer.$curMinorVer"
if ($curSimpleVer -eq $PowerShellLatest) {
Write-Host "##[section]Skipping live tests for PowerShell $curSimpleVer as it has already been explicitly specified in the pipeline." -ForegroundColor Green
return
}
}

$srcDir = Join-Path -Path $RepoLocation -ChildPath "src"
$liveScenarios = Get-ChildItem -Path $srcDir -Directory -Exclude "Accounts" | Get-ChildItem -Directory -Filter "LiveTests" -Recurse | Get-ChildItem -File -Filter "TestLiveScenarios.ps1" | Select-Object -ExpandProperty FullName
$liveScenarios | ForEach-Object {
$moduleName = [regex]::match($_, "[\\|\/]src[\\|\/](?<ModuleName>[a-zA-Z]+)[\\|\/]").Groups["ModuleName"].Value
Import-Module "./tools/TestFx/Assert.ps1" -Force
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $DataLocation -Force
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $PowerShellLatest, $DataLocation -Force
. $_
}

$accountsDir = Join-Path -Path $srcDir -ChildPath "Accounts"
$accountsLiveScenario = Get-ChildItem -Path $accountsDir -Directory -Filter "LiveTests" -Recurse | Get-ChildItem -File -Filter "TestLiveScenarios.ps1" | Select-Object -ExpandProperty FullName
if ($null -ne $accountsLiveScenario) {
Import-Module "./tools/TestFx/Assert.ps1" -Force
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList "Accounts", $RunPlatform, $DataLocation -Force
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList "Accounts", $RunPlatform, $PowerShellLatest, $DataLocation -Force
. $accountsLiveScenario
}

Expand Down
15 changes: 9 additions & 6 deletions tools/TestFx/Live/LiveTestUtility.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ param (
[ValidateNotNullOrEmpty()]
[string] $RunPlatform,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $PowerShellLatest,

[Parameter()]
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })]
[string] $DataLocation
Expand All @@ -39,8 +43,6 @@ New-Variable -Name LiveTestAnalysisDirectory -Value (Join-Path -Path $DataLocati
New-Variable -Name LiveTestRawDirectory -Value (Join-Path -Path $script:LiveTestAnalysisDirectory -ChildPath "Raw") -Scope Script -Option Constant
New-Variable -Name LiveTestRawCsvFile -Value (Join-Path -Path $script:LiveTestRawDirectory -ChildPath "Az.$ModuleName.csv") -Scope Script -Option Constant

New-Variable -Name PowerShellLatestVersion -Value "7.3" -Scope Script -Option Constant

function InitializeLiveTestModule {
[CmdletBinding()]
param ()
Expand Down Expand Up @@ -177,12 +179,13 @@ function Invoke-LiveTestCommand {

do {
try {
Write-Host "##[section]Start executing the command `"$Command`"." -ForegroundColor Green
Write-Host "##[command]The command `"$Command`" is running." -ForegroundColor Cyan
$expandedCommand = $ExecutionContext.InvokeCommand.ExpandString($Command)
Write-Host "##[section]Start executing the command `"$expandedCommand`"." -ForegroundColor Green
Write-Host "##[command]The command `"$expandedCommand`" is running." -ForegroundColor Cyan

$cmdResult = $Command.InvokeWithContext($null, [psvariable]::new("ErrorActionPreference", "Stop"))

Write-Host "##[section]Finish executing the command `"$Command`"" -ForegroundColor Green
Write-Host "##[section]Finish executing the command `"$expandedCommand`"" -ForegroundColor Green

$cmdResult
break
Expand Down Expand Up @@ -249,7 +252,7 @@ function Invoke-LiveTestScenario {

$curPSVer = (Get-Variable -Name PSVersionTable -ValueOnly).PSVersion
if ($PSBoundParameters.ContainsKey("PowerShellVersion")) {
$psSimpleVer = $PowerShellVersion -replace "Latest", $script:PowerShellLatestVersion
$psSimpleVer = $PowerShellVersion -replace "Latest", $PowerShellLatest
$curMajorVer = $curPSVer.Major
$curMinorVer = $curPSVer.Minor
$curSimpleVer = "$curMajorVer.$curMinorVer"
Expand Down

0 comments on commit 30f2df6

Please sign in to comment.