Skip to content

Commit 803cf83

Browse files
authored
Fix ci timeout (#820)
* split ci builds into separate jobs * use template for jobs * Fix template path in CI configuration
1 parent ed323d1 commit 803cf83

File tree

3 files changed

+158
-107
lines changed

3 files changed

+158
-107
lines changed

.azdo/ci.yml

Lines changed: 27 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -14,109 +14,32 @@ stages:
1414
- stage: Build
1515
displayName: Build Win32-OpenSSH
1616
jobs:
17-
- job: BuildPkg
18-
displayName: Build Package
17+
- job: BuildPkg_x64
18+
displayName: Build Package (x64)
1919
pool:
2020
name: PS-PowerShell-x64
2121
demands:
2222
- ImageOverride -equals PSMMS2022-OpenSSH-Secure
23-
2423
steps:
25-
- pwsh: |
26-
# Compare LibreSSL versions in vcpkg.json and add-resource-file.patch
27-
$vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json
28-
$libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version
29-
30-
# resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0)
31-
$patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch"
32-
$libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value }
33-
$libresslVersionPatchParts = $libresslVersionPatch -split '\.'
34-
$libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.')
35-
36-
if ($libresslVersionJson -ne $libresslVersionPatchShort) {
37-
Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch"
38-
exit 1
39-
} else {
40-
Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson"
41-
}
42-
displayName: 'Verify version info'
43-
44-
- pwsh: |-
45-
git clone https://github.com/microsoft/vcpkg
46-
cd vcpkg
47-
& ./bootstrap-vcpkg.bat
48-
& ./vcpkg.exe integrate install
49-
displayName: Install vcpkg
50-
51-
- pwsh: |
52-
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
53-
Invoke-AzDOBuild
54-
displayName: Build Win32-OpenSSH
55-
56-
- pwsh: |
57-
$BuildOutPath = "$(Build.SourcesDirectory)/bin"
58-
$BuildOutx86Path = Join-Path -Path $BuildOutPath -ChildPath 'Win32/Release'
59-
Get-ChildItem -Path $BuildOutx86Path
60-
$BuildOutx64Path = Join-Path -Path $BuildOutPath -ChildPath 'x64/Release'
61-
Get-ChildItem -Path $BuildOutx64Path
62-
displayName: Capture build results
63-
64-
- pwsh: |
65-
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
66-
#
67-
# Copy build artifacts
68-
$BuildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH"
69-
if (Test-Path -Path $BuildDestPath) {
70-
Remove-Item -Path $BuildDestPath -Recurse -Force -ErrorAction SilentlyContinue
71-
}
72-
$null = New-Item -ItemType Directory -Path $BuildDestPath -Force
73-
$BuildDestx86Path = Join-Path -Path $BuildDestPath -ChildPath 'x86/Release'
74-
Copy-BuildResults -BuildResultsPath $BuildDestx86Path -NativeHostArch x86 -Configuration Release
75-
$BuildDestX64Path = Join-Path -Path $BuildDestPath -ChildPath 'x64/Release'
76-
Copy-BuildResults -BuildResultsPath $BuildDestx64Path -NativeHostArch x64 -Configuration Release
77-
#
78-
# Upload build artifacts
79-
Write-Verbose -Verbose -Message "Uploading build artifacts"
80-
$artifactName = 'Win32-OpenSSH'
81-
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$BuildDestPath"
82-
#
83-
# Copy unit tests
84-
$BuildOutPath = "$(Build.SourcesDirectory)/bin"
85-
$UnitTestDestPath = "$(Build.SourcesDirectory)/UnitTests"
86-
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x86 -Configuration Release
87-
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x64 -Configuration Release
88-
#
89-
# Upload unit test artifacts
90-
Write-Verbose -Verbose -Message "Uploading unit test artifacts"
91-
$artifactName = 'UnitTests'
92-
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$UnitTestDestPath"
93-
#
94-
# Upload bash tests config.h file
95-
Write-Verbose -Verbose -Message "Uploading config.h file for bash tests"
96-
$artifactName = 'ConfigFile'
97-
$configFilePath = "$(Build.SourcesDirectory)/config.h"
98-
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$configFilePath"
99-
displayName: Upload Win32-OpenSSH build artifacts
100-
101-
- pwsh: |
102-
$logFileNames = @("OpenSSHReleasex64.log", "OpenSSHReleasex86.log")
103-
$uniqueLines = [System.Collections.Generic.HashSet[string]]::new()
104-
forEach ($logFile in $logFileNames) {
105-
$logFilePath = "$(Build.SourcesDirectory)/contrib/win32/openssh/$logFile"
106-
$logLines = Get-Content $logFilePath
107-
$buildSucceededIndex = $logLines.IndexOf("Build succeeded.")
108-
$linesToCheck = $logLines[($buildSucceededIndex + 1)..$logLines.Length]
109-
forEach ($line in $linesToCheck) {
110-
if ($line -match "warning C") {
111-
$uniqueLines.Add($line) | Out-Null
112-
}
113-
}
114-
}
115-
forEach ($uniqueLine in $uniqueLines) {
116-
Write-Output $uniqueLine
117-
Write-Host "##vso[task.logissue type=warning]$uniqueLine"
118-
}
119-
displayName: Surface Warnings from Build Logs
24+
- template: ./templates/build-win32-openssh-job.yml
25+
parameters:
26+
nativeHostArch: x64
27+
buildOutputDir: x64
28+
artifactSuffix: x64
29+
includeConfig: true
30+
31+
- job: BuildPkg_x86
32+
displayName: Build Package (x86)
33+
pool:
34+
name: PS-PowerShell-x64
35+
demands:
36+
- ImageOverride -equals PSMMS2022-OpenSSH-Secure
37+
steps:
38+
- template: ./templates/build-win32-openssh-job.yml
39+
parameters:
40+
nativeHostArch: x86
41+
buildOutputDir: Win32
42+
artifactSuffix: x86
12043

12144
- stage: Test
12245
displayName: Test Win32-OpenSSH
@@ -134,23 +57,23 @@ stages:
13457
inputs:
13558
buildType: current
13659
downloadType: single
137-
artifactName: Win32-OpenSSH
60+
artifactName: Win32-OpenSSH-x64
13861
downloadPath: '$(System.ArtifactsDirectory)'
13962

14063
- task: DownloadBuildArtifacts@0
14164
displayName: 'Download unit test artifacts'
14265
inputs:
14366
buildType: current
14467
downloadType: single
145-
artifactName: UnitTests
68+
artifactName: UnitTests-x64
14669
downloadPath: '$(System.ArtifactsDirectory)'
14770

14871
- task: DownloadBuildArtifacts@0
14972
displayName: 'Download bash test config file artifact'
15073
inputs:
15174
buildType: current
15275
downloadType: single
153-
artifactName: ConfigFile
76+
artifactName: ConfigFile-x64
15477
downloadPath: '$(System.ArtifactsDirectory)'
15578

15679
- pwsh: |
@@ -161,16 +84,16 @@ stages:
16184
16285
- pwsh: |
16386
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
164-
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
87+
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH-x64/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
16588
displayName: Install Win32-OpenSSH
16689
16790
- pwsh: |
16891
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
169-
Install-UnitTests -SourceDir "$(System.ArtifactsDirectory)/UnitTests/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
92+
Install-UnitTests -SourceDir "$(System.ArtifactsDirectory)/UnitTests-x64/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
17093
displayName: Install Unit Tests
17194
17295
- pwsh: |
173-
$configFileSrc = "$(System.ArtifactsDirectory)/ConfigFile/config.h"
96+
$configFileSrc = "$(System.ArtifactsDirectory)/ConfigFile-x64/config.h"
17497
$configFileDest = "$(Build.SourcesDirectory)"
17598
Write-Verbose -Verbose -Message "Copying config file from: ${configFileSrc} to: ${configFileDest}"
17699
Copy-Item -Path $configFileSrc -Dest $configFileDest -Force
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
parameters:
2+
- name: nativeHostArch
3+
type: string
4+
- name: buildOutputDir
5+
type: string
6+
- name: artifactSuffix
7+
type: string
8+
- name: includeConfig
9+
type: boolean
10+
default: false
11+
12+
steps:
13+
- pwsh: |
14+
# Compare LibreSSL versions in vcpkg.json and add-resource-file.patch
15+
$vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json
16+
$libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version
17+
18+
# resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0)
19+
$patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch"
20+
$libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value }
21+
$libresslVersionPatchParts = $libresslVersionPatch -split '\.'
22+
$libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.')
23+
24+
if ($libresslVersionJson -ne $libresslVersionPatchShort) {
25+
Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch"
26+
exit 1
27+
} else {
28+
Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson"
29+
}
30+
displayName: 'Verify version info'
31+
32+
- pwsh: |-
33+
git clone https://github.com/microsoft/vcpkg
34+
cd vcpkg
35+
& ./bootstrap-vcpkg.bat
36+
& ./vcpkg.exe integrate install
37+
displayName: Install vcpkg
38+
39+
- pwsh: |
40+
$nativeArch = '${{ parameters.nativeHostArch }}'
41+
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
42+
Invoke-AzDOBuild -NativeHostArch $nativeArch
43+
displayName: Build Win32-OpenSSH (${{ parameters.nativeHostArch }})
44+
45+
- pwsh: |
46+
$buildOutPath = "$(Build.SourcesDirectory)/bin"
47+
$buildOutputDir = '${{ parameters.buildOutputDir }}'
48+
$fullPath = Join-Path -Path $buildOutPath -ChildPath $buildOutputDir
49+
$releasePath = Join-Path -Path $fullPath -ChildPath 'Release'
50+
Get-ChildItem -Path $releasePath
51+
displayName: Capture build results (${{ parameters.artifactSuffix }})
52+
53+
- pwsh: |
54+
$nativeArch = '${{ parameters.nativeHostArch }}'
55+
$artifactSuffix = '${{ parameters.artifactSuffix }}'
56+
$includeConfig = [System.Convert]::ToBoolean('${{ parameters.includeConfig }}')
57+
58+
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
59+
#
60+
# Copy build artifacts
61+
$buildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH-$artifactSuffix"
62+
if (Test-Path -Path $buildDestPath) {
63+
Remove-Item -Path $buildDestPath -Recurse -Force -ErrorAction SilentlyContinue
64+
}
65+
$null = New-Item -ItemType Directory -Path $buildDestPath -Force
66+
$buildDestArchPath = Join-Path -Path $buildDestPath -ChildPath "$nativeArch/Release"
67+
Copy-BuildResults -BuildResultsPath $buildDestArchPath -NativeHostArch $nativeArch -Configuration Release
68+
#
69+
# Upload build artifacts
70+
Write-Verbose -Verbose -Message "Uploading build artifacts"
71+
$artifactName = "Win32-OpenSSH-$artifactSuffix"
72+
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$buildDestPath"
73+
#
74+
# Copy unit tests
75+
$buildOutPath = "$(Build.SourcesDirectory)/bin"
76+
$unitTestDestPath = "$(Build.SourcesDirectory)/UnitTests-$artifactSuffix"
77+
if (Test-Path -Path $unitTestDestPath) {
78+
Remove-Item -Path $unitTestDestPath -Recurse -Force -ErrorAction SilentlyContinue
79+
}
80+
$null = New-Item -ItemType Directory -Path $unitTestDestPath -Force
81+
Copy-UnitTests -UnitTestsSrcDir $buildOutPath -UnitTestsDestDir $unitTestDestPath -NativeHostArch $nativeArch -Configuration Release
82+
#
83+
# Upload unit test artifacts
84+
Write-Verbose -Verbose -Message "Uploading unit test artifacts"
85+
$unitTestArtifactName = "UnitTests-$artifactSuffix"
86+
Write-Host "##vso[artifact.upload containerfolder=$unitTestArtifactName;artifactname=$unitTestArtifactName;]$unitTestDestPath"
87+
#
88+
# Optionally upload bash tests config.h file
89+
if ($includeConfig) {
90+
Write-Verbose -Verbose -Message "Uploading config.h file for bash tests"
91+
$configArtifactName = "ConfigFile-$artifactSuffix"
92+
$configFilePath = "$(Build.SourcesDirectory)/config.h"
93+
Write-Host "##vso[artifact.upload containerfolder=$configArtifactName;artifactname=$configArtifactName;]$configFilePath"
94+
}
95+
displayName: Upload Win32-OpenSSH build artifacts (${{ parameters.artifactSuffix }})
96+
97+
- pwsh: |
98+
$artifactSuffix = '${{ parameters.artifactSuffix }}'
99+
$logFileName = "OpenSSHRelease$artifactSuffix.log"
100+
$uniqueLines = [System.Collections.Generic.HashSet[string]]::new()
101+
$logFilePath = "$(Build.SourcesDirectory)/contrib/win32/openssh/$logFileName"
102+
if (Test-Path -Path $logFilePath) {
103+
$logLines = Get-Content $logFilePath
104+
$buildSucceededIndex = $logLines.IndexOf("Build succeeded.")
105+
if ($buildSucceededIndex -ge 0) {
106+
$linesToCheck = $logLines[($buildSucceededIndex + 1)..$logLines.Length]
107+
foreach ($line in $linesToCheck) {
108+
if ($line -match "warning C") {
109+
$uniqueLines.Add($line) | Out-Null
110+
}
111+
}
112+
}
113+
}
114+
foreach ($uniqueLine in $uniqueLines) {
115+
Write-Output $uniqueLine
116+
Write-Host "##vso[task.logissue type=warning]$uniqueLine"
117+
}
118+
displayName: Surface warnings from build logs (${{ parameters.artifactSuffix }})

contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ function Write-BuildMessage
3535
#>
3636
function Invoke-AzDOBuild
3737
{
38-
Start-OpenSSHBuild -Configuration Release -NativeHostArch x64 -Verbose
39-
Start-OpenSSHBuild -Configuration Release -NativeHostArch x86 -Verbose
40-
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
38+
[CmdletBinding()]
39+
param (
40+
[Parameter()]
41+
[ValidateSet('x64', 'x86')]
42+
[string[]] $NativeHostArch = @('x64', 'x86')
43+
)
44+
45+
foreach ($arch in $NativeHostArch)
46+
{
47+
Start-OpenSSHBuild -Configuration Release -NativeHostArch $arch -Verbose
48+
}
49+
50+
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
4151
}
4252

4353
<#

0 commit comments

Comments
 (0)