Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container to Linux CI #17233

Merged
merged 64 commits into from May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
859c411
Update set-buildvariable to support isOutput
TravisEz13 Apr 29, 2022
b775b25
stop running static analysis on release branches
TravisEz13 Apr 29, 2022
f0a8ccf
placeholder to get container info
TravisEz13 Apr 29, 2022
1ee59cc
remove codecov
TravisEz13 Apr 29, 2022
7f1564d
Add one container job
TravisEz13 Apr 29, 2022
215e05f
make *nix test support containers
TravisEz13 Apr 29, 2022
8e189d5
rename existing jobs to Ubuntu
TravisEz13 Apr 29, 2022
f712d18
move xUnit verify to end
TravisEz13 Apr 29, 2022
38d6e8d
don't use an output for jobname
TravisEz13 Apr 29, 2022
191faba
set vmImage to get container info
TravisEz13 Apr 29, 2022
fc7059a
try other format
TravisEz13 Apr 29, 2022
10c0ab1
split into two stages
TravisEz13 Apr 29, 2022
a6ed369
try using stage variables
TravisEz13 Apr 29, 2022
7ad1005
add conditon
TravisEz13 Apr 29, 2022
b017cc6
add type to names
TravisEz13 Apr 29, 2022
16b1369
hard code image
TravisEz13 Apr 29, 2022
8323bde
fix container name
TravisEz13 Apr 29, 2022
c4b8e34
add unzip
TravisEz13 Apr 29, 2022
287aaf6
get image list from docker repo
TravisEz13 Apr 29, 2022
3cc5e29
use azure devops checkout for docker
TravisEz13 Apr 29, 2022
7fcd510
continue on error for now
TravisEz13 Apr 29, 2022
cc28651
add another stage that tries to use the container
TravisEz13 Apr 29, 2022
55380bd
finish move to azDevOps checkout
TravisEz13 Apr 29, 2022
64724bf
use sudo to install
TravisEz13 Apr 29, 2022
12923a1
put job name twice
TravisEz13 Apr 29, 2022
a67f0c3
comment out condition
TravisEz13 Apr 29, 2022
10d8698
ignore that we may not be able to build
TravisEz13 Apr 29, 2022
b3a8ae7
move finding the container into the stage
TravisEz13 Apr 29, 2022
f57dfa3
fix depenecy
TravisEz13 Apr 29, 2022
ef57181
fix mariner bootstrap
TravisEz13 Apr 29, 2022
b4563f1
try docker way of evaluating dependecies
TravisEz13 Apr 29, 2022
9f376ad
trying random stuff
TravisEz13 Apr 29, 2022
6b67596
try using a variable
TravisEz13 Apr 29, 2022
82d5034
fix parameter syntax
TravisEz13 Apr 29, 2022
0d05851
allow either a static name or an expression
TravisEz13 Apr 29, 2022
35226cc
use expression param
TravisEz13 Apr 29, 2022
8b385ef
delete unused variables
TravisEz13 Apr 29, 2022
06a6001
misc fixes
TravisEz13 Apr 29, 2022
27e103a
try to eliminate expression parse error
TravisEz13 Apr 30, 2022
ac65b38
add a default expression
TravisEz13 Apr 30, 2022
969ad82
default to the static variable
TravisEz13 Apr 30, 2022
e2ca78e
fix default expression
TravisEz13 Apr 30, 2022
3425bff
move expression into template - paring but then get unrecognized error
TravisEz13 Apr 30, 2022
2ca09ba
simplify more
TravisEz13 Apr 30, 2022
c4e09b4
make dependsOn more explicit
TravisEz13 Apr 30, 2022
a08d688
oops
TravisEz13 Apr 30, 2022
3c703c8
split into two templates
TravisEz13 Apr 30, 2022
a0614b7
set container statically 🎉working
TravisEz13 Apr 30, 2022
6fdaa77
try runtime evaluation
TravisEz13 Apr 30, 2022
35c8e49
Fix ping fake host
TravisEz13 Apr 30, 2022
ce3ca85
wsman doesn't work on mariner
TravisEz13 Apr 30, 2022
41270f7
add function to determine if WSMan availible
TravisEz13 Apr 30, 2022
fc5a15d
switch to queried variable
TravisEz13 Apr 30, 2022
95a5897
expose new function
TravisEz13 Apr 30, 2022
8f615c2
make work with 5.1
TravisEz13 Apr 30, 2022
0a8dfba
add other container test jobs
TravisEz13 Apr 30, 2022
5ba5be6
remove unused variables and set __INCONTAINER
TravisEz13 May 1, 2022
42b7aaf
Update .vsts-ci/linux.yml
TravisEz13 May 2, 2022
c876b4e
Update .vsts-ci/linux.yml
TravisEz13 May 2, 2022
0b1e737
Update .vsts-ci/linux.yml
TravisEz13 May 2, 2022
ec88d98
Update .vsts-ci/linux.yml
TravisEz13 May 2, 2022
165118e
remove install command now that images have the packages
TravisEz13 May 2, 2022
9bbaa4d
Update test/tools/Modules/HelpersCommon/HelpersCommon.psm1
TravisEz13 May 2, 2022
1ae439b
Update test/tools/Modules/HelpersCommon/HelpersCommon.psm1
TravisEz13 May 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
101 changes: 77 additions & 24 deletions .vsts-ci/linux.yml
Expand Up @@ -47,11 +47,15 @@ variables:
__SuppressAnsiEscapeSequences: 1

resources:
- repo: self
clean: true
repositories:
- repository: Docker
type: github
endpoint: PowerShell
name: PowerShell/PowerShell-Docker
ref: master

stages:
- stage: BuildLinux
- stage: BuildLinuxStage
displayName: Build for Linux
jobs:
- template: templates/ci-build.yml
Expand All @@ -60,33 +64,34 @@ stages:
jobName: linux_build
displayName: linux Build

- stage: TestLinux
displayName: Test for Linux
- stage: TestUbuntu
displayName: Test for Ubuntu
dependsOn: [BuildLinuxStage]
jobs:
- template: templates/nix-test.yml
parameters:
name: Linux
name: Ubuntu
Copy link
Member

Choose a reason for hiding this comment

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

i suppose eventually we should be using ubuntu-latest and provide a little more future proofing

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's open a separate PR for that. I don't particularly like that because the people on build duty usually just decide to roll back if there is an actual version upgrade.

pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: CI

- template: templates/nix-test.yml
parameters:
name: Linux
name: Ubuntu
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: CI

- template: templates/nix-test.yml
parameters:
name: Linux
name: Ubuntu
pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: Others

- template: templates/nix-test.yml
parameters:
name: Linux
name: Ubuntu
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: Others
Expand All @@ -95,24 +100,72 @@ stages:
parameters:
pool: ubuntu-20.04

- stage: TestContainer
displayName: Test in a container
dependsOn: [BuildLinuxStage]
jobs:
- job: getContainerJob
displayName: Choose a container
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
clean: true

- checkout: Docker
clean: true

- pwsh: |
$matrix = ./PowerShell-Docker/build.ps1 -GenerateMatrixJson -FullJson -Channel preview | ConvertFrom-Json
# Filter out containers that won't run on AzDevOps Linux host as an agent
# Windows, nano server, alpine, and any ARM image
$linuxImages = $matrix.preview |
TravisEz13 marked this conversation as resolved.
Show resolved Hide resolved
Where-Object {$_.osversion -notmatch 'windows|nano|alpine|arm'} |
Select-Object JobName, Taglist |
Sort-Object -property JobName
# Force mariner for now, later we will add automated rotation by the month.
$marinerImage = $linuxImages | where-object {$_.JobName -like 'mariner*'}
TravisEz13 marked this conversation as resolved.
Show resolved Hide resolved
Import-Module ./PowerShell/tools/ci.psm1
$tag = $marinerImage.Taglist -split ';' | select-object -first 1
$containerName = "mcr.microsoft.com/powershell/test-deps:$tag"
Set-BuildVariable -Name containerName -Value $containerName -IsOutput
Set-BuildVariable -Name containerBuildName -Value $marinerImage.JobName -IsOutput
name: getContainerTask
displayName: Get Container
continueOnError: true

- template: templates/test/nix-container-test.yml
parameters:
name: container
pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: CI

- template: templates/test/nix-container-test.yml
parameters:
name: container
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: CI

- template: templates/test/nix-container-test.yml
parameters:
name: container
pool: ubuntu-20.04
purpose: UnelevatedPesterTests
tagSet: Others

- template: templates/test/nix-container-test.yml
parameters:
name: container
pool: ubuntu-20.04
purpose: ElevatedPesterTests
tagSet: Others

- stage: PackageLinux
displayName: Package Linux
dependsOn: ["BuildLinux"]
dependsOn: ["BuildLinuxStage"]
jobs:
- template: linux/templates/packaging.yml
parameters:
pool: ubuntu-20.04

- stage: CodeCovTestPackage
Copy link
Member

Choose a reason for hiding this comment

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

On checking a part of this is required, where we create test packages.

Copy link
Member

Choose a reason for hiding this comment

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

New-TestPackage -Destination $destBasePath

Copy link
Member Author

Choose a reason for hiding this comment

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

spoke offline and we use this from another pipeline.

displayName: CodeCoverage and Test Packages
dependsOn: [] # by specifying an empty array, this stage doesn't depend on the stage before it
jobs:
- job: CodeCovTestPackage
displayName: CodeCoverage and Test Packages
pool:
vmImage: ubuntu-20.04
steps:
- pwsh: |
Import-Module .\tools\ci.psm1
New-CodeCoverageAndTestPackage
displayName: CodeCoverage and Test Package
2 changes: 0 additions & 2 deletions .vsts-ci/misc-analysis.yml
Expand Up @@ -5,14 +5,12 @@ trigger:
branches:
include:
- master
- release*
- feature*

pr:
branches:
include:
- master
- release*
- feature*

resources:
Expand Down
62 changes: 5 additions & 57 deletions .vsts-ci/templates/nix-test.yml
@@ -1,71 +1,19 @@
parameters:
pool: 'macOS-latest'
parentJobs: []
purpose: ''
tagSet: 'CI'
name: 'mac'

jobs:
- job: ${{ parameters.name }}_test_${{ parameters.purpose }}_${{ parameters.tagSet }}
dependsOn:
${{ parameters.parentJobs }}

pool:
vmImage: ${{ parameters.pool }}

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

steps:
- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()

- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
downloadType: specific
itemPattern: |
build/**/*
downloadPath: '$(System.ArtifactsDirectory)'

- pwsh: |
Get-ChildItem "$(System.ArtifactsDirectory)\*" -Recurse
displayName: 'Capture Artifacts Directory'
continueOnError: true

- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
displayName: Bootstrap

- task: ExtractFiles@1
displayName: 'Extract Build ZIP'
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/build/build.zip'
destinationFolder: '$(System.ArtifactsDirectory)/bins'

- bash: |
find "$(System.ArtifactsDirectory)/bins" -type d -exec chmod +rwx {} \;
find "$(System.ArtifactsDirectory)/bins" -type f -exec chmod +rw {} \;
displayName: 'Fix permissions'
continueOnError: true

- pwsh: |
Get-ChildItem "$(System.ArtifactsDirectory)\bins\*" -Recurse -ErrorAction SilentlyContinue
displayName: 'Capture Extracted Build ZIP'
continueOnError: true

- pwsh: |
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions)
$rootPath = '$(System.ArtifactsDirectory)\bins'
$originalRootPath = Split-Path -path $options.Output
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)
$pwshPath = Join-Path -path $path -ChildPath 'pwsh'
chmod a+x $pwshPath
$options.Output = $pwshPath
Set-PSOptions $options
Invoke-CITest -Purpose '${{ parameters.purpose }}' -TagSet '${{ parameters.tagSet }}'
displayName: Test
condition: succeeded()
- template: ./test/nix-test-steps.yml
parameters:
purpose: ${{ parameters.purpose }}
tagSet: ${{ parameters.tagSet }}
28 changes: 28 additions & 0 deletions .vsts-ci/templates/test/nix-container-test.yml
@@ -0,0 +1,28 @@
parameters:
pool: 'macOS-latest'
purpose: ''
tagSet: 'CI'
name: 'mac'

jobs:
- job: ${{ parameters.name }}_test_${{ parameters.purpose }}_${{ parameters.tagSet }}

dependsOn:
- getContainerJob

variables:
getContainerJob: $[ dependencies.getContainerJob.outputs['getContainerTask.containerName'] ]
__INCONTAINER: 1

container: $[ variables.getContainerJob ]

pool:
vmImage: ${{ parameters.pool }}

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

steps:
- template: ./nix-test-steps.yml
parameters:
purpose: ${{ parameters.purpose }}
tagSet: ${{ parameters.tagSet }}
59 changes: 59 additions & 0 deletions .vsts-ci/templates/test/nix-test-steps.yml
@@ -0,0 +1,59 @@
parameters:
purpose: ''
tagSet: 'CI'

steps:
- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()

- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
downloadType: specific
itemPattern: |
build/**/*
downloadPath: '$(System.ArtifactsDirectory)'

- pwsh: |
Get-ChildItem "$(System.ArtifactsDirectory)\*" -Recurse
displayName: 'Capture Artifacts Directory'
continueOnError: true

- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
displayName: Bootstrap

- task: ExtractFiles@1
displayName: 'Extract Build ZIP'
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/build/build.zip'
destinationFolder: '$(System.ArtifactsDirectory)/bins'

- bash: |
find "$(System.ArtifactsDirectory)/bins" -type d -exec chmod +rwx {} \;
find "$(System.ArtifactsDirectory)/bins" -type f -exec chmod +rw {} \;
TravisEz13 marked this conversation as resolved.
Show resolved Hide resolved
displayName: 'Fix permissions'
continueOnError: true

- pwsh: |
Get-ChildItem "$(System.ArtifactsDirectory)\bins\*" -Recurse -ErrorAction SilentlyContinue
displayName: 'Capture Extracted Build ZIP'
continueOnError: true

- pwsh: |
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
$options = (Get-PSOptions)
$rootPath = '$(System.ArtifactsDirectory)\bins'
$originalRootPath = Split-Path -path $options.Output
$path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)
$pwshPath = Join-Path -path $path -ChildPath 'pwsh'
chmod a+x $pwshPath
$options.Output = $pwshPath
Set-PSOptions $options
Invoke-CITest -Purpose '${{ parameters.purpose }}' -TagSet '${{ parameters.tagSet }}'
displayName: Test
condition: succeeded()
Expand Up @@ -97,15 +97,8 @@ Describe "Test-Connection" -tags "CI", "RequireSudoOnUnix" {
{ Test-Connection "fakeHost" -Count 1 -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
$platform = Get-PlatformInfo
if ($platform.Platform -match "raspbian" -or ( $platform.Platform -match 'ubuntu' -and $platform.Version -eq '20.04')) {
$code = 11
} elseif (!$IsWindows) {
$code = -131073
} else {
$code = 11001
}
$error[0].Exception.InnerException.ErrorCode | Should -Be $code
# Error code = -131073 - Invalid address
$error[0].Exception.InnerException.ErrorCode | Should -BeIn 11, -131073, 11001
TravisEz13 marked this conversation as resolved.
Show resolved Hide resolved
}

It "Force IPv4 with implicit PingOptions" {
Expand Down
10 changes: 2 additions & 8 deletions test/powershell/engine/Remoting/PSSession.Tests.ps1
Expand Up @@ -79,14 +79,8 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS
It "<Name>" -TestCases $testCases {
param ($scriptBlock, $expectedErrorCode)

$platformInfo = Get-PlatformInfo
if (
($platformInfo.Platform -match "alpine|raspbian") -or
($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID
($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or
($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04')
) {
Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8"
if ( -not (Get-WsManSupport)) {
Set-ItResult -Skipped -Because "MI library not available for this platform"
return
}

Expand Down