Skip to content

Commit 830099f

Browse files
authored
update CI to build vcpkg dependencies in separate stage (#821)
* build vcpkg dependencies in separate stage * address copilot feedback * need to install vcpkg for both build stages
1 parent 0ec5feb commit 830099f

3 files changed

Lines changed: 107 additions & 20 deletions

File tree

.azdo/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,36 @@ pr:
1111
- latestw_all
1212

1313
stages:
14+
- stage: BuildDependencies
15+
displayName: Build Dependencies
16+
jobs:
17+
- job: InstallDeps_x64
18+
displayName: Install vcpkg Dependencies (x64)
19+
pool:
20+
name: PS-PowerShell-x64
21+
demands:
22+
- ImageOverride -equals PSMMS2022-OpenSSH-Secure
23+
steps:
24+
- template: ./templates/install-vcpkg-dependencies.yml
25+
parameters:
26+
triplet: x64-custom
27+
artifactSuffix: x64
28+
29+
- job: InstallDeps_x86
30+
displayName: Install vcpkg Dependencies (x86)
31+
pool:
32+
name: PS-PowerShell-x64
33+
demands:
34+
- ImageOverride -equals PSMMS2022-OpenSSH-Secure
35+
steps:
36+
- template: ./templates/install-vcpkg-dependencies.yml
37+
parameters:
38+
triplet: x86-custom
39+
artifactSuffix: x86
40+
1441
- stage: Build
1542
displayName: Build Win32-OpenSSH
43+
dependsOn: BuildDependencies
1644
jobs:
1745
- job: BuildPkg_x64
1846
displayName: Build Package (x64)
@@ -26,6 +54,7 @@ stages:
2654
nativeHostArch: x64
2755
buildOutputDir: x64
2856
artifactSuffix: x64
57+
dependenciesArtifactName: vcpkg-dependencies-x64
2958
includeConfig: true
3059

3160
- job: BuildPkg_x86
@@ -40,6 +69,7 @@ stages:
4069
nativeHostArch: x86
4170
buildOutputDir: Win32
4271
artifactSuffix: x86
72+
dependenciesArtifactName: vcpkg-dependencies-x86
4373

4474
- stage: Test
4575
displayName: Test Win32-OpenSSH

.azdo/templates/build-win32-openssh-job.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,27 @@ parameters:
55
type: string
66
- name: artifactSuffix
77
type: string
8+
- name: dependenciesArtifactName
9+
type: string
810
- name: includeConfig
911
type: boolean
1012
default: false
1113

1214
steps:
1315
- 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: |-
16+
$ErrorActionPreference = 'Stop'
3317
git clone https://github.com/microsoft/vcpkg
3418
cd vcpkg
3519
& ./bootstrap-vcpkg.bat
3620
& ./vcpkg.exe integrate install
37-
displayName: Install vcpkg
21+
displayName: Install and bootstrap vcpkg
22+
23+
- task: DownloadPipelineArtifact@2
24+
displayName: 'Download vcpkg dependencies (${{ parameters.dependenciesArtifactName }})'
25+
inputs:
26+
buildType: current
27+
artifactName: ${{ parameters.dependenciesArtifactName }}
28+
targetPath: '$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_installed'
3829

3930
- pwsh: |
4031
$nativeArch = '${{ parameters.nativeHostArch }}'
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
parameters:
2+
- name: triplet
3+
type: string
4+
- name: artifactSuffix
5+
type: string
6+
7+
steps:
8+
- pwsh: |
9+
# Compare LibreSSL versions in vcpkg.json and add-resource-file.patch
10+
$vcpkgObj = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg.json" | ConvertFrom-Json
11+
$libresslVersionJson = $vcpkgObj | Select-Object -ExpandProperty overrides | Where-Object { $_.name -eq 'libressl' } | Select-Object -ExpandProperty version
12+
13+
# resource file version needs to be trimmed (e.g. 4.0.0.0 to 4.0.0)
14+
$patchContent = Get-Content "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_overlay_ports/libressl/add-version-file.patch"
15+
$libresslVersionPatch = ($patchContent -join "`n" | Select-String -Pattern '"FileVersion",\s*"(\d+\.\d+\.\d+\.\d+)"' -AllMatches).Matches | ForEach-Object { $_.Groups[1].Value }
16+
$libresslVersionPatchParts = $libresslVersionPatch -split '\.'
17+
$libresslVersionPatchShort = ($libresslVersionPatchParts[0..2] -join '.')
18+
19+
if ($libresslVersionJson -ne $libresslVersionPatchShort) {
20+
Write-Error "LibreSSL version mismatch: vcpkg.json has $libresslVersionJson, patch file has $libresslVersionPatch"
21+
exit 1
22+
} else {
23+
Write-Verbose -Verbose "LibreSSL versions match: $libresslVersionJson"
24+
}
25+
displayName: 'Verify version info'
26+
27+
- pwsh: |
28+
$ErrorActionPreference = 'Stop'
29+
git clone https://github.com/microsoft/vcpkg
30+
cd vcpkg
31+
& ./bootstrap-vcpkg.bat
32+
& ./vcpkg.exe integrate install
33+
displayName: Install and bootstrap vcpkg
34+
35+
- pwsh: |
36+
$triplet = '${{ parameters.triplet }}'
37+
Write-Verbose -Verbose "Installing vcpkg dependencies for triplet: $triplet"
38+
39+
Push-Location "$(Build.SourcesDirectory)/contrib/win32/openssh"
40+
try {
41+
& "$(Build.SourcesDirectory)/vcpkg/vcpkg.exe" install --triplet $triplet --overlay-triplets=.\vcpkg_triplets --overlay-ports=.\vcpkg_overlay_ports
42+
if ($LASTEXITCODE -ne 0) {
43+
throw "vcpkg install failed with exit code $LASTEXITCODE"
44+
}
45+
} finally {
46+
Pop-Location
47+
}
48+
displayName: Install vcpkg dependencies (${{ parameters.triplet }})
49+
50+
- pwsh: |
51+
$artifactSuffix = '${{ parameters.artifactSuffix }}'
52+
$vcpkgInstalledPath = "$(Build.SourcesDirectory)/contrib/win32/openssh/vcpkg_installed"
53+
54+
if (Test-Path -Path $vcpkgInstalledPath) {
55+
Write-Verbose -Verbose "vcpkg_installed directory contents:"
56+
Get-ChildItem -Path $vcpkgInstalledPath -Recurse -Depth 2 | Select-Object -First 50
57+
58+
# Upload vcpkg dependencies artifact
59+
Write-Verbose -Verbose -Message "Uploading vcpkg dependencies artifact"
60+
$artifactName = "vcpkg-dependencies-$artifactSuffix"
61+
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$vcpkgInstalledPath"
62+
} else {
63+
Write-Error "vcpkg_installed directory not found at: $vcpkgInstalledPath"
64+
exit 1
65+
}
66+
displayName: Upload vcpkg dependencies (${{ parameters.artifactSuffix }})

0 commit comments

Comments
 (0)