Skip to content
Draft
6 changes: 3 additions & 3 deletions .azure-pipelines/PipelineSteps/build-steps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Write-Host -ForegroundColor DarkGreen "-------------------- End filtering change
if (Test-Path $SubTasksFilePath) {
Write-Host -ForegroundColor Green "-------------------- Start setting subtasks ... --------------------"
Get-Content $SubTasksFilePath | ForEach-Object {
if ($_ && 'Predictor' -eq $_) {
if ($_ -and 'Predictor' -eq $_) {
$subTaskPredictor = $true
} elseif ($_ && 'Installer' -eq $_) {
} elseif ($_ -and 'Installer' -eq $_) {
Write-Host "##vso[task.setvariable variable=SubTaskInstaller]true"
$subTaskInstaller = $true
} elseif ($_ && 'all' -eq $_) {
} elseif ($_ -and 'all' -eq $_) {
$subTaskAll = $true
}
}
Expand Down
33 changes: 33 additions & 0 deletions .azure-pipelines/PipelineSteps/test-steps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,39 @@ $ErrorActionPreference = $preference
Set-Location $currentPath
Write-Host -ForegroundColor DarkGreen "-------------------- End testing AutoGen modules with PowerShell Core ... --------------------`n`n`n`n`n"

# Test AutoGen Modules With Windows PowerShell 5.1
if ($IsWindows) {
Write-Host -ForegroundColor Green "-------------------- Start testing AutoGen modules with Windows PowerShell 5.1 ... --------------------"
$executeCIStepScriptPath = Join-Path $RepoRoot "tools" "ExecuteCIStep.ps1"
$currentPath = $PWD
$debugFolderPath = Join-Path $RepoRoot "artifacts" "Debug"
Set-Location $debugFolderPath

$winPs = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe'
& $winPs -NoLogo -NoProfile -NonInteractive -Command @"
`$ErrorActionPreference = 'Stop'
`$IsWindows = `$true
`$IsLinux = `$false
`$IsMacOS = `$false
Comment thread
YangAn-microsoft marked this conversation as resolved.
`$env:PowerShellPlatform = 'Windows PowerShell'
Install-Module -Name Pester -Repository PSGallery -RequiredVersion 4.10.1 -Force -ErrorAction Stop
`$env:PSModulePath = `$env:PSModulePath + ';' + (pwd).Path
`$rootFolder = (Get-Item `$PWD -ErrorAction Stop).Parent.Parent.FullName
Get-ChildItem -Recurse -File -Filter test-module.ps1 -ErrorAction Stop | ForEach-Object {
Write-Host `$_.Directory.FullName
Set-Location `$rootFolder
& '$executeCIStepScriptPath' -TestAutorest -AutorestDirectory `$_.Directory.FullName
Comment on lines +65 to +78
}
Comment on lines +73 to +79
"@
$winPsExitCode = $LASTEXITCODE

Set-Location $currentPath
if ($winPsExitCode -ne 0) {
throw "Windows PowerShell 5.1 AutoGen module tests failed with exit code $winPsExitCode."
}
Write-Host -ForegroundColor DarkGreen "-------------------- End testing AutoGen modules with Windows PowerShell 5.1 ... --------------------`n`n`n`n`n"
}

# Analyze test coverage
Write-Host -ForegroundColor Green "-------------------- Start analyzing test coverage ... --------------------"
$validateTestCoverageScriptPath = Join-Path $RepoRoot 'tools' 'TestFx' 'Coverage' 'ValidateTestCoverage.ps1'
Expand Down
6 changes: 3 additions & 3 deletions .azure-pipelines/util/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ steps:
script: |
if (Test-Path "${{ parameters.subTasksFilePath }}") {
Get-Content "${{ parameters.subTasksFilePath }}" | ForEach-Object {
if ($_ && 'Predictor' -eq $_) {
if ($_ -and 'Predictor' -eq $_) {
Write-Host "##vso[task.setvariable variable=SubTaskPredictor]true"
} elseif ($_ && 'Installer' -eq $_) {
} elseif ($_ -and 'Installer' -eq $_) {
Write-Host "##vso[task.setvariable variable=SubTaskInstaller]true"
} elseif ($_ && 'all' -eq $_) {
} elseif ($_ -and 'all' -eq $_) {
Write-Host "##vso[task.setvariable variable=SubTaskAll]true"
}
}
Expand Down
37 changes: 28 additions & 9 deletions .azure-pipelines/util/test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,41 @@ steps:
continueOnError: true

- pwsh: |
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
if ($IsWindows) { $sp = ";" } else { $sp = ":" }
$env:PSModulePath = $env:PSModulePath + $sp + (pwd).Path
$rootFolder = (Get-item $PWD).Parent.Parent
Get-ChildItem -File -Recurse test-module.ps1 | ForEach-Object {
Write-Host $_.Directory.FullName
cd $rootFolder
.\tools\ExecuteCIStep.ps1 -TestAutorest -AutorestDirectory $_.Directory.FullName
}
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
if ($IsWindows) { $sp = ";" } else { $sp = ":" }
$env:PSModulePath = $env:PSModulePath + $sp + (pwd).Path
$rootFolder = (Get-item $PWD).Parent.Parent.FullName
Get-ChildItem -Recurse -File -Filter test-module.ps1 | ForEach-Object {
Write-Host $_.Directory.FullName
Set-Location $rootFolder
.\tools\ExecuteCIStep.ps1 -TestAutorest -AutorestDirectory $_.Directory.FullName
Comment on lines +39 to +44
}
workingDirectory: 'artifacts/Debug'
displayName: 'Test for AutoGen Modules With PowerShell Core'
condition: and(succeeded(), eq('${{ parameters.testTarget }}', 'Test'))
continueOnError: true
env:
PowerShellPlatform: ${{ parameters.powerShellPlatform }}

- powershell: |
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
$IsWindows = $true
$IsLinux = $false
$IsMacOS = $false
$sp = [System.IO.Path]::PathSeparator
$env:PSModulePath = $env:PSModulePath + $sp + (pwd).Path
$rootFolder = (Get-item $PWD).Parent.Parent.FullName
Get-ChildItem -Recurse -File -Filter test-module.ps1 | ForEach-Object {
Write-Host $_.Directory.FullName
Set-Location $rootFolder
& .\tools\ExecuteCIStep.ps1 -TestAutorest -AutorestDirectory $_.Directory.FullName
Comment on lines +53 to +64
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

}
Comment on lines +59 to +65
workingDirectory: 'artifacts/Debug'
displayName: 'Test for AutoGen Modules With Windows PowerShell 5.1'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq('${{ parameters.testTarget }}', 'Test'))
env:
PowerShellPlatform: Windows PowerShell

- task: PowerShell@2
displayName: Analyze Test Coverage
inputs:
Expand Down
2 changes: 1 addition & 1 deletion tools/ExecuteCIStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ If ($Build)
}
$Template.$DependencyStep.Details += $Detail
}
If ($PSBoundParameters.ContainsKey("TriggerType") && $PSBoundParameters.ContainsKey("Trigger")) {
If ($PSBoundParameters.ContainsKey("TriggerType") -and $PSBoundParameters.ContainsKey("Trigger")) {
$Template | Add-Member -NotePropertyName "$TriggerType triggered" -NotePropertyValue $Trigger
}

Expand Down
Loading