Skip to content

Commit d9a9b3c

Browse files
authored
Add AzDevOps CI implementations (#631)
* Fix yaml indentation * More format fixes * Temporarily remove compliance reference * Fix test job * Fix job name * Update image pool * Add build results copy * Fix build copy typo * Param fix * Fix build artifact download * Remove unneeded dir from install * Fix Pester version comaptible with tests * Fix unit tests * Fix unit test location * Fix unit test path * Disable Bash tests * Fix testpassed * Re-enable CygWin bash tests * Fix cygwin check error * Typo * Debug bash tests * Save config.h from build for bash tests * Fix config.h copy * Change test clean up * Allow some tests to run after others fail * Reinstate Invoke-AzDOBuild * Fix syntax errors * Restore opensshtestinfo * Fix typo * Upload bash test results * Debug bash tests 1 * Debug 2 * Remove debug code * Fix test path error * Set Pester version to 3.4.6 for AppVeyor runs
1 parent 5124f3d commit d9a9b3c

File tree

7 files changed

+423
-268
lines changed

7 files changed

+423
-268
lines changed

.azdo/ci.yml

Lines changed: 97 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pr:
1010
include:
1111
- latestw_all
1212

13-
resources:
14-
repositories:
15-
- repository: ComplianceRepo
16-
type: github
17-
endpoint: ComplianceGHRepo
18-
name: PowerShell/compliance
13+
#resources:
14+
# repositories:
15+
# - repository: ComplianceRepo
16+
# type: github
17+
# endpoint: ComplianceGHRepo
18+
# name: PowerShell/compliance
1919

2020
stages:
2121
- stage: Build
@@ -24,7 +24,7 @@ stages:
2424
- job: BuildPkg
2525
displayName: Build Package
2626
pool:
27-
name: 1ES
27+
name: PS-PowerShell-x64
2828
demands:
2929
- ImageOverride -equals PSMMS2019-OpenSSH-Secure
3030

@@ -53,19 +53,39 @@ stages:
5353
5454
- pwsh: |
5555
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
56+
#
57+
# Copy build artifacts
5658
$BuildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH"
5759
if (Test-Path -Path $BuildDestPath) {
5860
Remove-Item -Path $BuildDestPath -Recurse -Force -ErrorAction SilentlyContinue
5961
}
6062
$null = New-Item -ItemType Directory -Path $BuildDestPath -Force
61-
# Copy build artifacts
6263
$BuildDestx86Path = Join-Path -Path $BuildDestPath -ChildPath 'x86/Release'
63-
Start-OpenSSHPackage -NativeHostArch x86 -Configuration Release -DestinationPath $BuildDestx86Path
64+
Copy-BuildResults -BuildResultsPath $BuildDestx86Path -NativeHostArch x86 -Configuration Release
6465
$BuildDestX64Path = Join-Path -Path $BuildDestPath -ChildPath 'x64/Release'
65-
Start-OpenSSHPackage -NativeHostArch x64 -Configuration Release -DestinationPath $BuildDestx64Path
66+
Copy-BuildResults -BuildResultsPath $BuildDestx64Path -NativeHostArch x64 -Configuration Release
67+
#
6668
# Upload build artifacts
69+
Write-Verbose -Verbose -Message "Uploading build artifacts"
6770
$artifactName = 'Win32-OpenSSH'
6871
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$BuildDestPath"
72+
#
73+
# Copy unit tests
74+
$BuildOutPath = "$(Build.SourcesDirectory)/bin"
75+
$UnitTestDestPath = "$(Build.SourcesDirectory)/UnitTests"
76+
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x86 -Configuration Release
77+
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x64 -Configuration Release
78+
#
79+
# Upload unit test artifacts
80+
Write-Verbose -Verbose -Message "Uploading unit test artifacts"
81+
$artifactName = 'UnitTests'
82+
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$UnitTestDestPath"
83+
#
84+
# Upload bash tests config.h file
85+
Write-Verbose -Verbose -Message "Uploading config.h file for bash tests"
86+
$artifactName = 'ConfigFile'
87+
$configFilePath = "$(Build.SourcesDirectory)/config.h"
88+
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$configFilePath"
6989
displayName: Upload Win32-OpenSSH build artifacts
7090
7191
#- stage: Compliance
@@ -91,17 +111,19 @@ stages:
91111
displayName: Test Win32-OpenSSH
92112
dependsOn: Build
93113
jobs:
94-
pool:
95-
vmImage: windows-latest
96-
steps:
97-
- powershell: |
114+
- job: TestPkgWin32OpenSSH
115+
pool:
116+
vmImage: windows-latest
117+
displayName: Win32-OpenSSH On Windows
118+
steps:
119+
- powershell: |
98120
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
99121
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
100122
./install-powershell.ps1 -Destination $powerShellPath
101123
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
102124
Write-Host "sending " + $vstsCommandString
103125
Write-Host "##$vstsCommandString"
104-
displayName: Install PowerShell Core
126+
displayName: 'Install PowerShell Core'
105127
106128
- task: DownloadBuildArtifacts@0
107129
displayName: 'Download build artifacts'
@@ -111,25 +133,81 @@ stages:
111133
artifactName: Win32-OpenSSH
112134
downloadPath: '$(System.ArtifactsDirectory)'
113135

136+
- task: DownloadBuildArtifacts@0
137+
displayName: 'Download unit test artifacts'
138+
inputs:
139+
buildType: current
140+
downloadType: single
141+
artifactName: UnitTests
142+
downloadPath: '$(System.ArtifactsDirectory)'
143+
144+
- task: DownloadBuildArtifacts@0
145+
displayName: 'Download bash test config file artifact'
146+
inputs:
147+
buildType: current
148+
downloadType: single
149+
artifactName: ConfigFile
150+
downloadPath: '$(System.ArtifactsDirectory)'
151+
114152
- pwsh: |
115-
Get-ChildItem -Path "$(System.ArtifactsDirectory)/* -Recurse"
153+
$artifactDir = "$(System.ArtifactsDirectory)"
154+
Write-Verbose -Verbose -Message "Artifacts directory: $artifactDir"
155+
Get-ChildItem -Path $artifactDir -Recurse
116156
displayName: Capture downloaded artifact directory
117157
118158
- pwsh: |
119159
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
120-
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH/x64/Release/*" -OpenSSHDir "$env:SystemDrive/OpenSSH" -NativeHostArch x64 -Configuration Release -Verbose
160+
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
121161
displayName: Install Win32-OpenSSH
122-
162+
123163
- pwsh: |
164+
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
165+
Install-UnitTests -SourceDir "$(System.ArtifactsDirectory)/UnitTests/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
166+
displayName: Install Unit Tests
167+
168+
- pwsh: |
169+
$configFileSrc = "$(System.ArtifactsDirectory)/ConfigFile/config.h"
170+
$configFileDest = "$(Build.SourcesDirectory)"
171+
Write-Verbose -Verbose -Message "Copying config file from: ${configFileSrc} to: ${configFileDest}"
172+
Copy-Item -Path $configFileSrc -Dest $configFileDest -Force
173+
displayName: Copy config file artifact for bash tests
174+
175+
- pwsh: |
176+
$sourceDir = "$(Build.SourcesDirectory)"
177+
Write-Verbose -Verbose -Message "Source repo directory: $sourceDir"
178+
Get-ChildItem -Path $sourceDir
179+
displayName: Capture source repo directory for test
180+
181+
- pwsh: |
182+
$installedOpenSSHDir = "$env:SystemDrive/OpenSSH"
183+
Write-Verbose -Verbose -Message "Installed OpenSSH directory: $installedOpenSSHDir"
184+
Get-ChildItem -Path $installedOpenSSHDir -Recurse
185+
displayName: Capture installed OpenSSH directory
186+
187+
- pwsh: |
188+
# Run OpenSSH tests
124189
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
125190
Invoke-OpenSSHTests -OpenSSHBinPath "$env:SystemDrive/OpenSSH"
191+
displayName: Run tests
192+
193+
- pwsh: |
194+
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
195+
#
126196
# Copy test results to results directory
127197
$ResultsDirectory = "$(Build.SourcesDirectory)/Win32OpenSSHTestResults"
128198
Copy-OpenSSHTestResults -ResultsPath $ResultsDirectory
199+
#
129200
# Upload test results artifact
130201
if (Test-Path -Path $ResultsDirectory)
131202
{
132203
$artifactName = 'Win32-OpenSSH-TestResults'
133204
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$ResultsDirectory"
134205
}
135-
displayName: Run tests and publish results
206+
displayName: Upload test results
207+
condition: always()
208+
209+
- pwsh: |
210+
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
211+
Clear-TestEnvironmentSetup
212+
displayName: Clean up OpenSSH test environment
213+
condition: always()

contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psd1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ NestedModules = @(
2828
'../OpenSSHTestHelper.psm1')
2929

3030
FunctionsToExport = @(
31-
'Invoke-AllLocally',
3231
'Invoke-AzDOBuild',
3332
'Install-OpenSSH',
3433
'Invoke-OpenSSHTests',
35-
'Copy-OpenSSHTestResults')
36-
34+
'Copy-OpenSSHTestResults',
35+
'Copy-BuildResults',
36+
'Copy-UnitTests',
37+
'Install-UnitTests',
38+
'Clear-TestEnvironmentSetup')
3739
}

0 commit comments

Comments
 (0)