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
29 changes: 29 additions & 0 deletions .azure-pipelines/PipelineSteps/test-steps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@ $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 -NoProfile -Command @"
Comment thread
YangAn-microsoft marked this conversation as resolved.
Outdated
`$ErrorActionPreference = 'Continue'
Install-Module -Name Pester -Repository PSGallery -RequiredVersion 4.10.1 -Force
`$env:PSModulePath = `$env:PSModulePath + ';' + (pwd).Path
`$rootFolder = (Get-item `$PWD).Parent.Parent
Get-ChildItem -File -Recurse test-module.ps1 | ForEach-Object {
Comment thread
YangAn-microsoft marked this conversation as resolved.
Outdated
Write-Host `$_.Directory.FullName
cd `$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
32 changes: 23 additions & 9 deletions .azure-pipelines/util/test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,36 @@ 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
Get-ChildItem -File -Recurse 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
Comment thread
YangAn-microsoft marked this conversation as resolved.
env:
PowerShellPlatform: ${{ parameters.powerShellPlatform }}

- powershell: |
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
$sp = [System.IO.Path]::PathSeparator
$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
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'))

- task: PowerShell@2
displayName: Analyze Test Coverage
inputs:
Expand Down
Loading