Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
90f359f
Add CI for win-arm64
adityapatwardhan Jan 13, 2023
2e18541
Install Powershell
adityapatwardhan Jan 13, 2023
aaeeafe
Fix condition
adityapatwardhan Jan 13, 2023
eb65d14
Add Sync-PStags
adityapatwardhan Jan 13, 2023
8f4bac9
Add missing switch
adityapatwardhan Jan 13, 2023
b54a899
Add explicit checkout
adityapatwardhan Jan 13, 2023
6181cd1
Make test stages use the correct image
adityapatwardhan Jan 13, 2023
494b607
Install pscore
adityapatwardhan Jan 14, 2023
7e127ea
Fix typo
adityapatwardhan Jan 14, 2023
4f0c9ea
Add logging
adityapatwardhan Jan 14, 2023
e6e34ad
fix path
adityapatwardhan Jan 14, 2023
089212c
Fix bootstrap
adityapatwardhan Jan 14, 2023
fbc67e2
fix unelevated tests
TravisEz13 Jan 26, 2023
24badb1
update image name
TravisEz13 Jan 26, 2023
87459f5
update build image name
TravisEz13 Jan 26, 2023
a0ec3eb
Add note
TravisEz13 Jan 26, 2023
2fdabeb
make step name more descriptive
TravisEz13 Jan 26, 2023
f952733
fix test failures
TravisEz13 Jan 26, 2023
0e7095a
fix test failures
TravisEz13 Jan 26, 2023
ad65b7a
fix test issues
TravisEz13 Jan 27, 2023
679b896
fix test issues
TravisEz13 Jan 27, 2023
0b1cba6
fix test issue
TravisEz13 Jan 27, 2023
6735561
Fix test issues
TravisEz13 Jan 27, 2023
0398853
Fix test issue
TravisEz13 Jan 27, 2023
32290f8
fix test issues
TravisEz13 Jan 27, 2023
871da5a
fix issues again
TravisEz13 Jan 27, 2023
2554ed8
Update .vsts-ci/templates/ci-build.yml
TravisEz13 Jan 27, 2023
e668afa
fix a typo
TravisEz13 Jan 27, 2023
79e5d98
Update .vsts-ci/templates/ci-build.yml
TravisEz13 Jan 27, 2023
5130c31
Add common function to test for windows arm64
TravisEz13 Jan 31, 2023
4f5da10
Update because string where items need investigation
TravisEz13 Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions .vsts-ci/templates/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
parameters:
pool: 'windows-latest'
jobName: 'win_build'
displayName: Windows Build
- name: pool
default: 'windows-latest'
- name: imageName
default: 'PSWindows11-ARM64'
- name: jobName
default: 'win_build'
- name: displayName
default: Windows Build
- name: PoolType
default: AzDoHosted
type: string
values:
- AzDoHosted
- 1esHosted

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.pool }}
${{ if eq( parameters.PoolType, 'AzDoHosted') }}:
vmImage: ${{ parameters.pool }}
${{ else }}:
name: ${{ parameters.pool }}
demands:
- ImageOverride -equals ${{ parameters.imageName }}

displayName: ${{ parameters.displayName }}

steps:
- powershell: |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$pwsh = Get-Command pwsh -ErrorAction SilentlyContinue -CommandType Application

if ($null -eq $pwsh) {
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
}

displayName: Install PowerShell

- checkout: self
fetchDepth: 1000

- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
Expand All @@ -26,6 +60,9 @@ jobs:
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
Write-Verbose -Verbose "Start Sync-PSTags"
Sync-PSTags -AddRemoteIfMissing
Write-Verbose -Verbose "End Sync-PSTags"
displayName: Bootstrap
condition: succeeded()

Expand Down
24 changes: 23 additions & 1 deletion .vsts-ci/templates/windows-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
pool: 'windows-2019'
imageName: 'PSWindows11-ARM64'
parentJobs: []
purpose: ''
tagSet: 'CI'
Expand All @@ -9,11 +10,32 @@ jobs:
dependsOn:
${{ parameters.parentJobs }}
pool:
vmImage: ${{ parameters.pool }}
${{ if startsWith( parameters.pool, 'windows-') }}:
vmImage: ${{ parameters.pool }}
${{ else }}:
name: ${{ parameters.pool }}
demands:
- ImageOverride -equals ${{ parameters.imageName }}

displayName: Windows Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }}

steps:
- powershell: |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$pwsh = Get-Command pwsh -ErrorAction SilentlyContinue -CommandType Application

if ($null -eq $pwsh) {
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
}

displayName: Install PowerShell if missing
condition: ne('${{ parameters.pool }}', 'windows-2019')

- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
Expand Down
95 changes: 95 additions & 0 deletions .vsts-ci/windows-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
trigger:
# Batch merge builds together while a merge build is running
batch: true
branches:
include:
- master
- release*
- feature*
paths:
include:
- '*'
exclude:
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- test/perf/*
pr:
branches:
include:
- master
- release*
- feature*
paths:
include:
- '*'
exclude:
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- tools/cgmanifest.json
- LICENSE.txt
- test/common/markdown/*
- test/perf/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- README.md
- .spelling

variables:
- name: GIT_CONFIG_PARAMETERS
value: "'core.autocrlf=false'"
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: POWERSHELL_TELEMETRY_OPTOUT
value: 1
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 1
- name: __SuppressAnsiEscapeSequences
value: 1
- group: PoolNames

resources:
- repo: self
clean: true

stages:
- stage: BuildWin
displayName: Build for Windows
jobs:
- template: templates/ci-build.yml
parameters:
pool: $(armPool)
PoolType: 1esHosted

- stage: TestWin
displayName: Test for Windows
jobs:
- template: templates/windows-test.yml
parameters:
purpose: UnelevatedPesterTests
tagSet: CI
pool: $(armPool)

- template: templates/windows-test.yml
parameters:
purpose: ElevatedPesterTests
tagSet: CI
pool: $(armPool)

- template: templates/windows-test.yml
parameters:
purpose: UnelevatedPesterTests
tagSet: Others
pool: $(armPool)

- template: templates/windows-test.yml
parameters:
purpose: ElevatedPesterTests
tagSet: Others
pool: $(armPool)

- template: templates/verify-xunit.yml
1 change: 1 addition & 0 deletions .vsts-ci/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ variables:
# Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
__SuppressAnsiEscapeSequences: 1
NugetSecurityAnalysisWarningLevel: none

resources:
- repo: self
Expand Down
11 changes: 9 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $script:Options = $null
$dotnetMetadata = Get-Content $PSScriptRoot/DotnetRuntimeMetadata.json | ConvertFrom-Json
$dotnetCLIChannel = $dotnetMetadata.Sdk.Channel
$dotnetCLIQuality = $dotnetMetadata.Sdk.Quality
$dotnetAzureFeed = $env:__DONET_RUNTIME_FEED ?? $dotnetMetadata.Sdk.azureFeed
$dotnetAzureFeed = if (-not $env:__DONET_RUNTIME_FEED ) { $dotnetMetadata.Sdk.azureFeed }
$dotnetAzureFeedSecret = $env:__DONET_RUNTIME_FEED_KEY
$dotnetSDKVersionOveride = $dotnetMetadata.Sdk.sdkImageOverride
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
Expand Down Expand Up @@ -138,6 +138,7 @@ function Get-EnvironmentInformation
{
$environment += @{'IsAdmin' = (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)}
$environment += @{'nugetPackagesRoot' = "${env:USERPROFILE}\.nuget\packages", "${env:NUGET_PACKAGES}"}
$environment += @{ 'OSArchitecture' = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture }
}
else
{
Expand Down Expand Up @@ -1343,7 +1344,7 @@ function Start-PSPester {
$command += " *> $outputBufferFilePath; '__UNELEVATED_TESTS_THE_END__' >> $outputBufferFilePath"
}

Write-Verbose $command
Write-Verbose $command -Verbose

$script:nonewline = $true
$script:inerror = $false
Expand Down Expand Up @@ -1600,11 +1601,17 @@ function script:Start-UnelevatedProcess
[string]$process,
[string[]]$arguments
)

if (-not $environment.IsWindows)
{
throw "Start-UnelevatedProcess is currently not supported on non-Windows platforms"
}

if (-not $environment.OSArchitecture -eq 'arm64')
{
throw "Start-UnelevatedProcess is currently not supported on arm64 platforms"
}

runas.exe /trustlevel:0x20000 "$process $arguments"
}

Expand Down
8 changes: 8 additions & 0 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
}

It "Clear-Host does not injects data into PowerShell output stream" {
if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "ARM64 runs in non-interactively mode and Clear-Host does not work."
}

& { Clear-Host; 'hi' } | Should -BeExactly 'hi'
}

Expand Down Expand Up @@ -997,6 +1001,10 @@ public enum ShowWindowCommands : int
) {
param ($WindowStyle)

if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "All windows are showing up as hidden or ARM64"
}

try {
$ps = Start-Process $powershell -ArgumentList "-WindowStyle $WindowStyle -noexit -interactive" -PassThru
$startTime = Get-Date
Expand Down
6 changes: 5 additions & 1 deletion test/powershell/Host/ScreenReader.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ Describe "Validate start of console host" -Tag CI {
}

It "PSReadLine should not be auto-loaded when screen reader status is active" -Skip:(-not $IsWindows) {
if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "Needs investigation, PSReadline loads on ARM64"
}

$output = & "$PSHOME/pwsh" -noprofile -noexit -c "Get-Module PSReadLine; exit"
$output.Length | Should -BeExactly 2
$output.Length | Should -BeExactly 2 -Because "There should be two lines of output but we got: $output"

## The warning message about screen reader should be returned, but the PSReadLine module should not be loaded.
$output[0] | Should -BeLike "Warning:*'Import-Module PSReadLine'."
Expand Down
8 changes: 8 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,9 @@ Verb-Noun -Param1 Hello ^
}

It "Tab completion UNC path" -Skip:(!$IsWindows) {
if (!$env:HOMEDRIVE) {
Set-ItResult -Skipped -Because "Homerdrive is not set"
}
$homeDrive = $env:HOMEDRIVE.Replace(":", "$")
$beforeTab = "\\localhost\$homeDrive\wind"
$afterTab = "& '\\localhost\$homeDrive\Windows'"
Expand Down Expand Up @@ -1995,6 +1998,11 @@ dir -Recurse `
It "Input '<inputStr>' should successfully complete" -TestCases $testCases -Skip:(!$IsWindows) {
param($inputStr, $expected)

if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "TBD"
}


$res = TabExpansion2 -inputScript $inputStr -cursorColumn $inputStr.Length
$res.CompletionMatches.Count | Should -BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should -BeExactly $expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ Describe "Native Command Processor" -tags "Feature" {
}

It "Should not block running Windows executables" -Skip:(!$IsWindows -or !(Get-Command notepad.exe)) {
if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "Needs investigation"
}

function FindNewNotepad
{
Get-Process -Name notepad -ErrorAction Ignore | Where-Object { $_.Id -NotIn $dontKill }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ Describe "Native streams behavior with PowerShell" -Tags 'CI' {
($out | Out-String).Replace("`r", '') | Should -BeExactly "foo`n`nbar`n`nbazmiddlefoo`n`nbar`n`nbaz`n"
}

It 'does not get truncated or split when redirected' {
It 'Does not get truncated or split when redirected' {
if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "IOException: The handle is invalid."
}

$longtext = "0123456789"
while ($longtext.Length -lt [console]::WindowWidth) {
$longtext += $longtext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ try
$originalWarningPreference = $WarningPreference
$WarningPreference = "SilentlyContinue"
# Skip all tests if can't write to $PSHOME as Register-PSSessionConfiguration writes to $PSHOME
$IsNotSkipped = ($IsWindows -and $IsCoreCLR -and (Test-IsElevated) -and (Test-CanWriteToPsHome))
# or if the processor architecture is Arm64
$IsNotSkipped = ($IsWindows -and $IsCoreCLR -and (Test-IsElevated) -and (Test-CanWriteToPsHome) -and [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -ne [System.Runtime.InteropServices.Architecture]::Arm64)
$PSDefaultParameterValues["it:skip"] = !$IsNotSkipped

#
Expand Down Expand Up @@ -830,6 +831,12 @@ namespace PowershellTestConfigNamespace

Describe "Validate Enable-PSSession Cmdlet" -Tags @("Feature", 'RequireAdminOnWindows') {
BeforeAll {
if (Test-IsWindowsArm64) {
Write-Verbose "remoting is not setup on ARM64, skipping tests" -Verbose
$PSDefaultParameterValues["it:skip"] = $true
return
}

if ($IsNotSkipped) {
Enable-PSRemoting
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
) {
param ($cmdline, $expectedError)

if (Test-IsElevated) {
Set-ItResult -Skipped -Because "Process must NOT be elevated"
}

$scriptBlock = [scriptblock]::Create($cmdline)
$scriptBlock | Should -Throw -ErrorId $expectedError
}
Expand Down Expand Up @@ -1551,6 +1555,9 @@ Describe "Remove-Item UnAuthorized Access" -Tags "CI", "RequireAdminOnWindows" {
}

It "Access-denied test for removing a folder" -Skip:(-not $IsWindows) {
if (Test-IsWindowsArm64) {
Set-ItResult -Pending -Because "runas.exe /trustlevel:0x20000 is not supported on ARM64"
}

# The expected error is returned when there is a empty directory with the user does not have authorization to is deleted.
# It cannot have 'System. 'Hidden' or 'ReadOnly' attribute as well as -Force should not be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Describe "Get-HotFix Tests" -Tag CI {
if (!$IsWindows) {
$skip = $true
}
elseif (Test-IsWindowsArm64) {
# Win32Exception: Failed to load required native library 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\wminet_utils.dll'.
Write-Verbose "needed provider not on ARM64, skipping tests" -Verbose
$PSDefaultParameterValues["it:skip"] = $true
return
}
else {
# skip the tests if there are no hotfixes returned
$qfe = Get-CimInstance Win32_QuickFixEngineering
Expand Down
Loading