Skip to content

Commit 30f2df6

Browse files
Removed PowerShell 7.0 for live test and added placeholder for PowerShell latest (#21547)
* Removed ps 7.0 for live test and added ps latest * Fixed issues --------- Co-authored-by: Yunchi Wang <[email protected]>
1 parent addb46e commit 30f2df6

File tree

4 files changed

+53
-35
lines changed

4 files changed

+53
-35
lines changed

.azure-pipelines/live-test.yml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ parameters:
1919
displayName: Windows PowerShell 5.1 Version
2020
type: string
2121
default: 5.1
22-
- name: ps_7_0_x
23-
displayName: PowerShell 7.0.x Version
24-
type: string
25-
default: 7.0.*
2622
- name: ps_7_2_x
2723
displayName: PowerShell 7.2.x Version
2824
type: string
@@ -76,14 +72,6 @@ jobs:
7672
psVersion: ${{ parameters.win_ps_5_1 }}
7773
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
7874

79-
- template: util/live-test-steps.yml
80-
parameters:
81-
name: 'ps_7_0_x_win_2019'
82-
vmImage: ${{ parameters.img_windows_2019 }}
83-
osType: 'Windows'
84-
psVersion: ${{ parameters.ps_7_0_x }}
85-
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
86-
8775
- template: util/live-test-steps.yml
8876
parameters:
8977
name: 'ps_7_2_x_win_2019'
@@ -102,11 +90,11 @@ jobs:
10290

10391
- template: util/live-test-steps.yml
10492
parameters:
105-
name: 'ps_7_0_x_win_2022'
106-
vmImage: ${{ parameters.img_windows_2022 }}
93+
name: 'ps_latest_win_2019'
94+
vmImage: ${{ parameters.img_windows_2019 }}
10795
osType: 'Windows'
108-
psVersion: ${{ parameters.ps_7_0_x }}
109-
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
96+
psVersion: ${{ parameters.ps_latest }}
97+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
11098

11199
- template: util/live-test-steps.yml
112100
parameters:
@@ -126,11 +114,11 @@ jobs:
126114

127115
- template: util/live-test-steps.yml
128116
parameters:
129-
name: 'ps_7_0_x_linux'
130-
vmImage: ${{ parameters.img_linux }}
131-
osType: 'Linux'
132-
psVersion: ${{ parameters.ps_7_0_x }}
133-
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
117+
name: 'ps_latest_win_2022'
118+
vmImage: ${{ parameters.img_windows_2022 }}
119+
osType: 'Windows'
120+
psVersion: ${{ parameters.ps_latest }}
121+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
134122

135123
- template: util/live-test-steps.yml
136124
parameters:
@@ -150,11 +138,11 @@ jobs:
150138

151139
- template: util/live-test-steps.yml
152140
parameters:
153-
name: 'ps_7_0_x_macOS'
154-
vmImage: ${{ parameters.img_macos }}
155-
osType: 'MacOS'
156-
psVersion: ${{ parameters.ps_7_0_x }}
157-
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
141+
name: 'ps_latest_linux'
142+
vmImage: ${{ parameters.img_linux }}
143+
osType: 'Linux'
144+
psVersion: ${{ parameters.ps_latest }}
145+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
158146

159147
- template: util/live-test-steps.yml
160148
parameters:
@@ -171,3 +159,11 @@ jobs:
171159
osType: 'MacOS'
172160
psVersion: ${{ parameters.ps_7_3_x }}
173161
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
162+
163+
- template: util/live-test-steps.yml
164+
parameters:
165+
name: 'ps_latest_macOS'
166+
vmImage: ${{ parameters.img_macos }}
167+
osType: 'MacOS'
168+
psVersion: ${{ parameters.ps_latest }}
169+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}

.azure-pipelines/util/live-test-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
pwsh: true
120120
targetType: filePath
121121
filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1
122-
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 -RunPlatform ${{ parameters.osType }} -RepoLocation $(Build.SourcesDirectory) -DataLocation $(DataLocation)'
122+
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)'
123123

124124
- task: PowerShell@2
125125
displayName: Save live test results to Kusto

tools/TestFx/Live/InvokeLiveTestScenarios.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ param (
33
[ValidateNotNullOrEmpty()]
44
[string] $RunPlatform,
55

6+
[Parameter(Mandatory)]
7+
[ValidateNotNullOrEmpty()]
8+
[string] $RunPowerShell,
9+
10+
[Parameter(Mandatory)]
11+
[ValidateNotNullOrEmpty()]
12+
[string] $PowerShellLatest,
13+
614
[Parameter(Mandatory)]
715
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })]
816
[string] $RepoLocation,
@@ -12,20 +20,31 @@ param (
1220
[string] $DataLocation
1321
)
1422

23+
if ($RunPowerShell -eq "latest") {
24+
$curPSVer = (Get-Variable -Name PSVersionTable -ValueOnly).PSVersion
25+
$curMajorVer = $curPSVer.Major
26+
$curMinorVer = $curPSVer.Minor
27+
$curSimpleVer = "$curMajorVer.$curMinorVer"
28+
if ($curSimpleVer -eq $PowerShellLatest) {
29+
Write-Host "##[section]Skipping live tests for PowerShell $curSimpleVer as it has already been explicitly specified in the pipeline." -ForegroundColor Green
30+
return
31+
}
32+
}
33+
1534
$srcDir = Join-Path -Path $RepoLocation -ChildPath "src"
1635
$liveScenarios = Get-ChildItem -Path $srcDir -Directory -Exclude "Accounts" | Get-ChildItem -Directory -Filter "LiveTests" -Recurse | Get-ChildItem -File -Filter "TestLiveScenarios.ps1" | Select-Object -ExpandProperty FullName
1736
$liveScenarios | ForEach-Object {
1837
$moduleName = [regex]::match($_, "[\\|\/]src[\\|\/](?<ModuleName>[a-zA-Z]+)[\\|\/]").Groups["ModuleName"].Value
1938
Import-Module "./tools/TestFx/Assert.ps1" -Force
20-
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $DataLocation -Force
39+
Import-Module "./tools/TestFx/Live/LiveTestUtility.psd1" -ArgumentList $moduleName, $RunPlatform, $PowerShellLatest, $DataLocation -Force
2140
. $_
2241
}
2342

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

tools/TestFx/Live/LiveTestUtility.psm1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ param (
2020
[ValidateNotNullOrEmpty()]
2121
[string] $RunPlatform,
2222

23+
[Parameter(Mandatory)]
24+
[ValidateNotNullOrEmpty()]
25+
[string] $PowerShellLatest,
26+
2327
[Parameter()]
2428
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Container })]
2529
[string] $DataLocation
@@ -39,8 +43,6 @@ New-Variable -Name LiveTestAnalysisDirectory -Value (Join-Path -Path $DataLocati
3943
New-Variable -Name LiveTestRawDirectory -Value (Join-Path -Path $script:LiveTestAnalysisDirectory -ChildPath "Raw") -Scope Script -Option Constant
4044
New-Variable -Name LiveTestRawCsvFile -Value (Join-Path -Path $script:LiveTestRawDirectory -ChildPath "Az.$ModuleName.csv") -Scope Script -Option Constant
4145

42-
New-Variable -Name PowerShellLatestVersion -Value "7.3" -Scope Script -Option Constant
43-
4446
function InitializeLiveTestModule {
4547
[CmdletBinding()]
4648
param ()
@@ -177,12 +179,13 @@ function Invoke-LiveTestCommand {
177179

178180
do {
179181
try {
180-
Write-Host "##[section]Start executing the command `"$Command`"." -ForegroundColor Green
181-
Write-Host "##[command]The command `"$Command`" is running." -ForegroundColor Cyan
182+
$expandedCommand = $ExecutionContext.InvokeCommand.ExpandString($Command)
183+
Write-Host "##[section]Start executing the command `"$expandedCommand`"." -ForegroundColor Green
184+
Write-Host "##[command]The command `"$expandedCommand`" is running." -ForegroundColor Cyan
182185

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

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

187190
$cmdResult
188191
break
@@ -249,7 +252,7 @@ function Invoke-LiveTestScenario {
249252

250253
$curPSVer = (Get-Variable -Name PSVersionTable -ValueOnly).PSVersion
251254
if ($PSBoundParameters.ContainsKey("PowerShellVersion")) {
252-
$psSimpleVer = $PowerShellVersion -replace "Latest", $script:PowerShellLatestVersion
255+
$psSimpleVer = $PowerShellVersion -replace "Latest", $PowerShellLatest
253256
$curMajorVer = $curPSVer.Major
254257
$curMinorVer = $curPSVer.Minor
255258
$curSimpleVer = "$curMajorVer.$curMinorVer"

0 commit comments

Comments
 (0)