Skip to content

Commit 74b35ea

Browse files
DavoudEshtehariDavid-Engel
authored andcommitted
Merged PR 4952: eng | Add support custom sni on CI
I'd like to propose my last change as part of SNI validation. ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request adds support for custom SNI (Server Name Indication) in the CI pipeline, facilitating the migration of MDS tests with SNI dependency to YAML/build in Onebranch. - Added `ci-custom-sni-step.yml` and `add-nuget-feed-step.yml` to handle custom SNI version updates and NuGet feed configuration. - Updated `ci-run-tests-stage.yml` to conditionally include custom SNI steps based on the `internalSNIVersion` parameter. - Modified `ci-build-nugets-job.yml` to update SNI version in nuspec files if `internalSNIVersion` is provided. - Enhanced `ci-project-build-step.yml` and `ci-prebuild-step.yml` to include custom SNI steps. - Updated main pipeline files (`dotnet-sqlclient-ci-core.yml`, `dotnet-sqlclient-ci-package-reference-pipeline.yml`, `dotnet-sqlclient-ci-project-reference-pipeline.yml`) to support the new `internalSNIVersion` parameter. Related work items: #30552
1 parent 55df6ea commit 74b35ea

11 files changed

+307
-100
lines changed

eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# See the LICENSE file in the project root for more information. #
55
#################################################################################
66
parameters:
7+
- name: debug
8+
type: boolean
9+
default: false
10+
711
- name: poolName
812
type: string
913
default: $(ci_var_defaultPoolName)
@@ -24,6 +28,10 @@ parameters:
2428
type: string
2529
default: $(Configuration)
2630

31+
- name: internalSNIVersion
32+
type: string
33+
default: ''
34+
2735
- name: prebuildSteps
2836
type: stepList
2937
default: []
@@ -44,11 +52,45 @@ jobs:
4452
- ${{ if ne(parameters.prebuildSteps, '') }}:
4553
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration
4654

55+
- ${{ if ne(parameters.internalSNIVersion, '') }}:
56+
- powershell: |
57+
$newVersion = "${{parameters.internalSNIVersion }}"
58+
$rootFolder = Get-location
59+
$filePath = Join-Path $rootFolder "tools\specs\Microsoft.Data.SqlClient.nuspec"
60+
Write-Host $filePath
61+
62+
[Xml] $xml = Get-Content -Path $filePath
63+
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
64+
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)
65+
$dependencies = $xml.SelectNodes("//ns:dependency[@id='Microsoft.Data.SqlClient.SNI' or @id='Microsoft.Data.SqlClient.SNI.runtime']", $nsm)
66+
67+
if ($dependencies.Count -eq 0) {
68+
Write-Error "No matching dependencies found."
69+
}
70+
71+
foreach($dependency in $dependencies){
72+
$dependency.version = $newVersion
73+
}
74+
75+
$xml.Save($filePath)
76+
77+
displayName: 'Update SNI version in nuspec'
78+
79+
- ${{ if parameters.debug }}:
80+
- powershell: |
81+
# Display the content of the Versions.props file
82+
$rootFolder = Get-location
83+
$filePath = Join-Path $rootFolder "tools\specs\Microsoft.Data.SqlClient.nuspec"
84+
Get-Content -Path "$filePath"
85+
displayName: 'Read Microsoft.Data.SqlClient.nuspec [debug]'
86+
4787
- template: ../steps/ci-project-build-step.yml@self
4888
parameters:
89+
debug: ${{ parameters.debug }}
4990
platform: ${{ parameters.platform }}
5091
configuration: ${{ parameters.configuration }}
5192
operatingSystem: Windows
93+
internalSNIVersion: ${{ parameters.internalSNIVersion }}
5294
build: all
5395

5496
- template: ../steps/generate-nuget-package-step.yml@self

eng/pipelines/common/templates/stages/ci-run-tests-stage.yml

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ parameters:
1515
type: string
1616
default: ''
1717

18+
- name: internalSNIVersion
19+
type: string
20+
default: ''
21+
1822
- name: buildType
1923
displayName: 'Build Type'
2024
default: Project
@@ -32,65 +36,69 @@ parameters:
3236

3337
stages:
3438
- ${{ each config in parameters.testConfigurations }}:
35-
- ${{ each image in config.value.images }}:
36-
- stage: ${{ image.key }}
37-
${{ if ne(parameters.dependsOn, '') }}:
38-
dependsOn: ${{ parameters.dependsOn }}
39-
${{ else }}:
40-
dependsOn: []
41-
jobs:
42-
- ${{ each targetFramework in config.value.TargetFrameworks }}:
43-
- ${{ each platform in config.value.buildPlatforms }}:
44-
- ${{ each testSet in config.value.TestSets }}:
45-
- ${{ if contains(targetFramework, 'net4') }}: # .NET Framework
46-
- template: ../jobs/ci-run-tests-job.yml@self
47-
parameters:
48-
debug: ${{ parameters.debug }}
49-
buildType: ${{ parameters.buildType }}
50-
poolName: ${{ config.value.pool }}
51-
hostedPool: ${{ eq(config.value.hostedPool, true) }}
52-
image: ${{ image.value }}
53-
jobDisplayName: ${{ format('{0}_{1}_{2}', replace(targetFramework, '.', '_'), platform, testSet) }}
54-
configProperties: ${{ config.value.configProperties }}
55-
prebuildSteps: ${{ parameters.prebuildSteps }}
56-
targetFramework: ${{ targetFramework }}
57-
testSet: ${{ testSet }}
58-
${{ each codeCoveTF in config.value.codeCovTargetFrameworks }}:
59-
${{ if eq(codeCoveTF, targetFramework) }}:
60-
publishTestResults: true
61-
configSqlFor: ${{ config.value.configSqlFor }}
62-
operatingSystem: ${{ config.value.operatingSystem }}
63-
${{if ne(config.value.configProperties, '{}') }}:
64-
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
65-
${{ if eq(x86TF, targetFramework) }}:
66-
enableX86Test: true
67-
- ${{ else }}: # .NET
68-
- ${{ each useManagedSNI in config.value.useManagedSNI }}:
39+
# If internalSNIVersion is not set or if it is set and the test configuration requires custom SNI
40+
- ${{ if or(eq(parameters.internalSNIVersion, ''), and(ne(parameters.internalSNIVersion, ''), config.value.configProperties.runWithCustomSNI)) }}:
41+
- ${{ each image in config.value.images }}:
42+
- stage: ${{ image.key }}
43+
${{ if ne(parameters.dependsOn, '') }}:
44+
dependsOn: ${{ parameters.dependsOn }}
45+
${{ else }}:
46+
dependsOn: []
47+
jobs:
48+
- ${{ each targetFramework in config.value.TargetFrameworks }}:
49+
- ${{ each platform in config.value.buildPlatforms }}:
50+
- ${{ each testSet in config.value.TestSets }}:
51+
- ${{ if contains(targetFramework, 'net4') }}: # .NET Framework
6952
- template: ../jobs/ci-run-tests-job.yml@self
7053
parameters:
7154
debug: ${{ parameters.debug }}
7255
buildType: ${{ parameters.buildType }}
7356
poolName: ${{ config.value.pool }}
7457
hostedPool: ${{ eq(config.value.hostedPool, true) }}
7558
image: ${{ image.value }}
76-
${{if eq(usemanagedSNI, 'true') }}:
77-
jobDisplayName: ${{ format('{0}_{1}_{2}_{3}', replace(targetFramework, '.', '_'), platform, 'ManagedSNI', testSet) }}
78-
${{ else }}:
79-
jobDisplayName: ${{ format('{0}_{1}_{2}_{3}', replace(targetFramework, '.', '_'), platform, 'NativeSNI', testSet) }}
59+
jobDisplayName: ${{ format('{0}_{1}_{2}', replace(targetFramework, '.', '_'), platform, testSet) }}
8060
configProperties: ${{ config.value.configProperties }}
81-
useManagedSNI: ${{ useManagedSNI }}
82-
prebuildSteps: ${{ parameters.prebuildSteps }}
61+
prebuildSteps: ${{ parameters.prebuildSteps }}
8362
targetFramework: ${{ targetFramework }}
8463
testSet: ${{ testSet }}
8564
${{ each codeCoveTF in config.value.codeCovTargetFrameworks }}:
8665
${{ if eq(codeCoveTF, targetFramework) }}:
8766
publishTestResults: true
8867
configSqlFor: ${{ config.value.configSqlFor }}
8968
operatingSystem: ${{ config.value.operatingSystem }}
90-
${{if and(eq(usemanagedSNI, false), ne(config.value.configProperties, '{}')) }}:
69+
${{if ne(config.value.configProperties, '{}') }}:
9170
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
9271
${{ if eq(x86TF, targetFramework) }}:
9372
enableX86Test: true
73+
- ${{ else }}: # .NET
74+
- ${{ each useManagedSNI in config.value.useManagedSNI }}:
75+
# Skips ManagedSNI if the test configuration requires custom SNI
76+
- ${{ if or(eq(parameters.internalSNIVersion, ''), and(ne(parameters.internalSNIVersion, ''), ne(config.value.operatingSystem, 'Windows')), and(ne(parameters.internalSNIVersion, ''), config.value.configProperties.runWithCustomSNI, eq(usemanagedSNI, 'false'))) }}:
77+
- template: ../jobs/ci-run-tests-job.yml@self
78+
parameters:
79+
debug: ${{ parameters.debug }}
80+
buildType: ${{ parameters.buildType }}
81+
poolName: ${{ config.value.pool }}
82+
hostedPool: ${{ eq(config.value.hostedPool, true) }}
83+
image: ${{ image.value }}
84+
${{if eq(usemanagedSNI, 'true') }}:
85+
jobDisplayName: ${{ format('{0}_{1}_{2}_{3}', replace(targetFramework, '.', '_'), platform, 'ManagedSNI', testSet) }}
86+
${{ else }}:
87+
jobDisplayName: ${{ format('{0}_{1}_{2}_{3}', replace(targetFramework, '.', '_'), platform, 'NativeSNI', testSet) }}
88+
configProperties: ${{ config.value.configProperties }}
89+
useManagedSNI: ${{ useManagedSNI }}
90+
prebuildSteps: ${{ parameters.prebuildSteps }}
91+
targetFramework: ${{ targetFramework }}
92+
testSet: ${{ testSet }}
93+
${{ each codeCoveTF in config.value.codeCovTargetFrameworks }}:
94+
${{ if eq(codeCoveTF, targetFramework) }}:
95+
publishTestResults: true
96+
configSqlFor: ${{ config.value.configSqlFor }}
97+
operatingSystem: ${{ config.value.operatingSystem }}
98+
${{if and(eq(usemanagedSNI, false), ne(config.value.configProperties, '{}')) }}:
99+
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
100+
${{ if eq(x86TF, targetFramework) }}:
101+
enableX86Test: true
94102

95103
- ${{ if ne(length(parameters.postTestJobs), 0) }}:
96104
- stage: Post_Test
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#################################################################################
2+
# Licensed to the .NET Foundation under one or more agreements. #
3+
# The .NET Foundation licenses this file to you under the MIT license. #
4+
# See the LICENSE file in the project root for more information. #
5+
#################################################################################
6+
parameters:
7+
- name: debug
8+
type: boolean
9+
default: false
10+
11+
- name: key
12+
type: string
13+
14+
- name: value
15+
type: string
16+
17+
- name: feedType
18+
default: Local
19+
values:
20+
- Local
21+
- ADO
22+
23+
steps:
24+
- powershell: |
25+
# Get a list of package sources available
26+
Get-PackageSource
27+
28+
$Value = "${{parameters.value }}"
29+
$Key = "${{parameters.key }}"
30+
31+
# Register the local nuget folder to be used by nuget.config
32+
if ("${{parameters.feedType}}" -eq "Local") {
33+
Register-PackageSource -Name "$Key" -Location $Value -Force -ProviderName NuGet -Trusted
34+
}
35+
36+
# Set the NuGet.config file in the project to use internal feed
37+
$rootFolder = Get-location
38+
[Xml] $nugetConfig = Get-Content -Path "NuGet.config"
39+
40+
$newAdd = $nugetConfig.CreateElement("add")
41+
$newAdd.SetAttribute("key","$Key")
42+
$newAdd.SetAttribute("value", "$Value" )
43+
$nugetConfig.configuration.packageSources.AppendChild($newAdd)
44+
45+
$filePath = Join-Path $rootFolder "NuGet.config"
46+
$nugetConfig.Save($filePath)
47+
48+
displayName: 'Add internal SNI feed to Nuget.config'
49+
50+
- ${{ if parameters.debug }}:
51+
- powershell: |
52+
# Display the content of the NuGet.config file
53+
Get-Content -Path "NuGet.config"
54+
displayName: 'Read NuGet.config [debug]'
55+
56+
- ${{ if eq(parameters.feedType, 'ADO') }}:
57+
- task: NuGetAuthenticate@1
58+
displayName: 'NuGet Authenticate'
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#################################################################################
2+
# Licensed to the .NET Foundation under one or more agreements. #
3+
# The .NET Foundation licenses this file to you under the MIT license. #
4+
# See the LICENSE file in the project root for more information. #
5+
#################################################################################
6+
parameters:
7+
- name: debug
8+
type: boolean
9+
default: false
10+
11+
- name: internalFeed
12+
type: string
13+
default: '$(internalFeed)'
14+
15+
- name: internalSNIVersion
16+
type: string
17+
18+
steps:
19+
- template: add-nuget-feed-step.yml@self
20+
parameters:
21+
debug: ${{ parameters.debug }}
22+
key: 'SNI Package source'
23+
value: ${{ parameters.internalFeed }}
24+
feedType: ADO
25+
26+
- powershell: |
27+
#Get the SNI Version to test from the user entered version.
28+
$newVersion = "${{parameters.internalSNIVersion }}"
29+
Write-Host "New SNI Version: "$newVersion
30+
31+
# define file to update
32+
$rootFolder = Get-location
33+
$PropsPath = Join-Path $rootFolder "tools\props\Versions.props"
34+
35+
[Xml] $versionProps = Get-Content -Path $PropsPath
36+
$nsm = New-Object Xml.XmlNamespaceManager($versionProps.NameTable)
37+
$nsm.AddNamespace('ns', $versionProps.DocumentElement.NamespaceURI)
38+
39+
$sniVersion = $versionProps.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm)
40+
Write-Host "Current SNI Version: "$sniVersion.InnerText
41+
42+
# update the node inner text
43+
$sniVersion.InnerText = "$newVersion"
44+
45+
$sniRuntimeVersion = $versionProps.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm)
46+
Write-Host "Current SNI.runtime Version: "$sniRuntimeVersion.InnerText
47+
48+
# update the node inner text
49+
$sniRuntimeVersion.InnerText = "$newVersion"
50+
51+
# save the xml file
52+
$versionProps.Save($PropsPath)
53+
54+
displayName: 'Update SNI version in Versions.props'
55+
56+
- ${{ if parameters.debug }}:
57+
- powershell: |
58+
# Display the content of the Versions.props file
59+
$rootFolder = Get-location
60+
$PropsPath = "$rootFolder\tools\props\Versions.props"
61+
Get-Content -Path "$PropsPath"
62+
displayName: 'Read Versions.props [debug]'

eng/pipelines/common/templates/steps/ci-prebuild-step.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ parameters:
1111
- name: artifactName
1212
type: string
1313
default: Artifacts
14-
14+
1515
- name: buildType
1616
displayName: 'Build Type'
1717
default: Project
1818
values:
1919
- Project
2020
- Package
2121

22+
- name: internalSNIVersion
23+
type: string
24+
default: ''
25+
2226
steps:
2327
- ${{if eq(parameters.debug, true)}}:
2428
- powershell: |
@@ -34,10 +38,21 @@ steps:
3438
patterns: '**/*.nupkg'
3539
targetPath: $(Pipeline.Workspace)/${{parameters.artifactName }}
3640

41+
# Update config and properties to use internal SNI feed
42+
- ${{ if ne(parameters.internalSNIVersion, '') }}:
43+
- template: ci-custom-sni-step.yml@self
44+
parameters:
45+
debug: ${{ parameters.debug }}
46+
internalSNIVersion: ${{ parameters.internalSNIVersion }}
47+
48+
# Update projects to read from Nuget folder downloaded from the pipeline's artifact
3749
- template: update-nuget-config-local-feed-step.yml@self
3850
parameters:
3951
downloadedNugetPath: $(Pipeline.Workspace)\${{parameters.artifactName }}
4052
debug: ${{ parameters.debug }}
4153

4254
- ${{ else }}: # project
4355
- template: ci-project-build-step.yml@self
56+
parameters:
57+
debug: ${{ parameters.debug }}
58+
internalSNIVersion: ${{ parameters.internalSNIVersion }}

0 commit comments

Comments
 (0)