From 0d228f2665a8700552ae5d63b9ceb116a2a0500f Mon Sep 17 00:00:00 2001 From: Malcolm Daigle Date: Thu, 27 Feb 2025 09:06:05 -0800 Subject: [PATCH 1/3] Allow sni version override. --- .../templates/steps/override-sni-version.yml | 99 +++++++++++++++++++ eng/pipelines/dotnet-sqlclient-ci-core.yml | 42 ++++++-- src/Microsoft.Data.SqlClient.sln | 7 +- 3 files changed, 139 insertions(+), 9 deletions(-) create mode 100644 eng/pipelines/common/templates/steps/override-sni-version.yml diff --git a/eng/pipelines/common/templates/steps/override-sni-version.yml b/eng/pipelines/common/templates/steps/override-sni-version.yml new file mode 100644 index 0000000000..9cc93acc4b --- /dev/null +++ b/eng/pipelines/common/templates/steps/override-sni-version.yml @@ -0,0 +1,99 @@ +################################################################################# +# Licensed to the .NET Foundation under one or more agreements. # +# The .NET Foundation licenses this file to you under the MIT license. # +# See the LICENSE file in the project root for more information. # +################################################################################# + +parameters: +- name: SNIVersion + type: string + +- name: SNIValidationFeed + type: string + +steps: +- task: PowerShell@2 + displayName: Update SNI Version in Nuget.config + inputs: + targetType: inline + script: | + #Purpose: Updates Nuget.config to add SNIValidation Internal Feed and the required credentials + Write-Host "Starting update to Nuget.config" + Write-Host "SNI Version to test = ${{parameters.SNIVersion}}" + + # define file to update + $NugetCfg = Join-Path -Path '.' -ChildPath 'NuGet.config' + type $NugetCfg + + # define an xml object + $xml = New-Object XML + + # load content of xml from file defined above + $xml.Load($NugetCfg) + + # define namespace used to read a node + $nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable) + $nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI) + + # get the package sources node + $packageSources = $xml.SelectSingleNode('//ns:packageSources', $nsm) + + # define new package source + $newSource = $xml.CreateElement("add") + $newSource.SetAttribute("key","SNIValidation") + $newSource.SetAttribute("value","${{parameters.SNIValidationFeed}}") + + # add the new package source + $packageSources.AppendChild($newSource) + + # save the xml file + $xml.Save($NugetCfg) + type $NugetCfg +- task: PowerShell@2 + displayName: Update SNI Version in Versions.props + inputs: + targetType: inline + script: | + #Purpose: Updates SNI Version + Write-Host "Starting update to Versions.props" + Write-Host "SNI Version to test = ${{parameters.SNIVersion}}" + + #Get the SNI Version to test from the user entered version. + $SharedSNIVersion = "${{parameters.SNIVersion}}" + + # define file to update + $PropsPath = Join-Path -Path '.' -ChildPath 'tools\props\Versions.props' + type $PropsPath + + # new version number to update to + ##Write-Host "SNI Version to test = $(SNIValidationVersion)" + Write-Host "SNI Version to test = $SharedSNIVersion" + + + # define an xml object + $xml = New-Object XML + + # load content of xml from file defined above + $xml.Load($PropsPath) + + # define namespace used to read a node + $nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable) + $nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI) + $netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm) + + Write-Host "Node NetFx SNI Version = $($netFxSniVersion.InnerText)" + + # update the node inner text + $netFxSniVersion.InnerText = "$SharedSNIVersion" + + $netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm) + + # update the node inner text + $netCoreSniVersion.InnerText = "$SharedSNIVersion" + + # save the xml file + $xml.Save($PropsPath) + + type $PropsPath +- task: NuGetAuthenticate@1 + displayName: 'NuGet Authenticate with SNI Validation Feed' diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml index b80ce7465a..d8a9a67b18 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-core.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml @@ -41,6 +41,18 @@ parameters: type: object default: [false, true] +- name: SNIVersion + displayName: | + Use a specific SNI version from the internal validation feed + type: string + default: '' + +- name: SNIValidationFeed + displayName: | + The specific SNI test version is pulled from this feed + type: string + default: https://sqlclientdrivers.pkgs.visualstudio.com/ADO.Net/_packaging/SNIValidation/nuget/v3/index.json + - name: codeCovTargetFrameworks displayName: 'Code Coverage Target Frameworks' type: object @@ -73,6 +85,12 @@ stages: - template: common/templates/jobs/ci-build-nugets-job.yml@self parameters: artifactName: $(artifactName) + ${{if ne(parameters.SNIVersion, '')}}: + prebuildSteps: + - template: common/templates/steps/override-sni-version.yml@self + parameters: + SNIVersion: ${{parameters.SNIVersion}} + SNIValidationFeed: ${{parameters.SNIValidationFeed}} - template: common/templates/stages/ci-run-tests-stage.yml@self parameters: @@ -81,12 +99,24 @@ stages: ${{ if eq(parameters.buildType, 'Package') }}: dependsOn: build_nugets - prebuildSteps: # steps to run prior to building and running tests on each job - - template: common/templates/steps/ci-prebuild-step.yml@self - parameters: - debug: ${{ parameters.debug }} - artifactName: $(artifactName) - buildType: ${{ parameters.buildType }} + ${{if ne(parameters.SNIVersion, '')}}: + prebuildSteps: # steps to run prior to building and running tests on each job + - template: common/templates/steps/override-sni-version.yml@self + parameters: + SNIVersion: ${{parameters.SNIVersion}} + SNIValidationFeed: ${{parameters.SNIValidationFeed}} + - template: common/templates/steps/ci-prebuild-step.yml@self + parameters: + debug: ${{ parameters.debug }} + artifactName: $(artifactName) + buildType: ${{ parameters.buildType }} + ${{else}}: + prebuildSteps: # steps to run prior to building and running tests on each job + - template: common/templates/steps/ci-prebuild-step.yml@self + parameters: + debug: ${{ parameters.debug }} + artifactName: $(artifactName) + buildType: ${{ parameters.buildType }} ${{ if eq(parameters.buildType, 'Project') }}: # only run the code coverage job if the build type is project postTestJobs: # jobs to run after the tests are done diff --git a/src/Microsoft.Data.SqlClient.sln b/src/Microsoft.Data.SqlClient.sln index a2608cc803..9662a8519a 100644 --- a/src/Microsoft.Data.SqlClient.sln +++ b/src/Microsoft.Data.SqlClient.sln @@ -262,6 +262,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "steps", "steps", "{EABE3A3E ..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml = ..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml ..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml = ..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml = ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml + ..\eng\pipelines\common\templates\steps\override-sni-version.yml = ..\eng\pipelines\common\templates\steps\override-sni-version.yml ..\eng\pipelines\common\templates\steps\pre-build-step.yml = ..\eng\pipelines\common\templates\steps\pre-build-step.yml ..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml = ..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml ..\eng\pipelines\common\templates\steps\publish-symbols-step.yml = ..\eng\pipelines\common\templates\steps\publish-symbols-step.yml @@ -559,6 +560,8 @@ Global {8DC9D1A0-351B-47BC-A90F-B9DA542550E9} = {0CC4817A-12F3-4357-912C-09315FAAD008} {D2D1E2D1-B6E0-489F-A36D-1F3047AB87B9} = {0CC4817A-12F3-4357-912C-09315FAAD008} {37431336-5307-4184-9356-C4B7E47DC714} = {28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} + {28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} + {3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} {D1392B54-998A-4F27-BC17-4CE149117BCC} = {CDE508A5-F5D0-4A59-A4EF-978833830727} {45DB5F86-7AE3-45C6-870D-F9357B66BDB5} = {0CC4817A-12F3-4357-912C-09315FAAD008} {6C88F00F-9597-43AD-9E5F-9B344DA3B16F} = {CDE508A5-F5D0-4A59-A4EF-978833830727} @@ -568,6 +571,7 @@ Global {1C9FC4B8-54BC-4B6C-BB3A-F5CD59D80A9B} = {A2E7E470-5EFF-4828-B55E-FCBA3650F51C} {771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D} = {3FDD425C-FE01-4B56-863E-1FCDD0677CF5} {412BCCC8-19F6-489A-B594-E9A506816155} = {771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D} + {9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} {71F356DC-DFA3-4163-8BFE-D268722CE189} = {ED952CF7-84DF-437A-B066-F516E9BE1C2C} {908C7DD3-C999-40A6-9433-9F5ACA7C36F5} = {71F356DC-DFA3-4163-8BFE-D268722CE189} {0CE216CE-8072-4985-B248-61F0D0BE9C2E} = {71F356DC-DFA3-4163-8BFE-D268722CE189} @@ -584,9 +588,6 @@ Global {869A9BCC-D303-4365-9BF7-958CD6387916} = {71F356DC-DFA3-4163-8BFE-D268722CE189} {CDE508A5-F5D0-4A59-A4EF-978833830727} = {0CC4817A-12F3-4357-912C-09315FAAD008} {9A8996A8-6484-4AA7-B50F-F861430EDE2F} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} - {9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} - {28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} - {3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45} {4CAE9195-4F1A-4D48-854C-1C9FBC512C66} = {4600328C-C134-499F-AAE2-964E8AD5472C} {FD4D7A96-79B1-4F89-B64D-29FACCC9232F} = {4CAE9195-4F1A-4D48-854C-1C9FBC512C66} {E76A4ED5-9137-4E4B-AE91-7AEDB2683823} = {FD4D7A96-79B1-4F89-B64D-29FACCC9232F} From 394883ee74514a7f4ac6257d5f036c9e4e3c91ce Mon Sep 17 00:00:00 2001 From: Malcolm Daigle Date: Thu, 27 Feb 2025 09:40:11 -0800 Subject: [PATCH 2/3] Clean up scripts. --- .../templates/steps/override-sni-version.yml | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/eng/pipelines/common/templates/steps/override-sni-version.yml b/eng/pipelines/common/templates/steps/override-sni-version.yml index 9cc93acc4b..e3754b40b7 100644 --- a/eng/pipelines/common/templates/steps/override-sni-version.yml +++ b/eng/pipelines/common/templates/steps/override-sni-version.yml @@ -13,22 +13,18 @@ parameters: steps: - task: PowerShell@2 - displayName: Update SNI Version in Nuget.config + displayName: Add SNI Validation Feed in Nuget.config inputs: targetType: inline script: | - #Purpose: Updates Nuget.config to add SNIValidation Internal Feed and the required credentials - Write-Host "Starting update to Nuget.config" - Write-Host "SNI Version to test = ${{parameters.SNIVersion}}" + Write-Host "SNI validation feed to use = ${{parameters.SNIValidationFeed}}" # define file to update $NugetCfg = Join-Path -Path '.' -ChildPath 'NuGet.config' type $NugetCfg - # define an xml object - $xml = New-Object XML - # load content of xml from file defined above + $xml = New-Object XML $xml.Load($NugetCfg) # define namespace used to read a node @@ -54,46 +50,32 @@ steps: inputs: targetType: inline script: | - #Purpose: Updates SNI Version - Write-Host "Starting update to Versions.props" Write-Host "SNI Version to test = ${{parameters.SNIVersion}}" - #Get the SNI Version to test from the user entered version. - $SharedSNIVersion = "${{parameters.SNIVersion}}" - # define file to update $PropsPath = Join-Path -Path '.' -ChildPath 'tools\props\Versions.props' type $PropsPath - # new version number to update to - ##Write-Host "SNI Version to test = $(SNIValidationVersion)" - Write-Host "SNI Version to test = $SharedSNIVersion" - - - # define an xml object - $xml = New-Object XML - # load content of xml from file defined above + $xml = New-Object XML $xml.Load($PropsPath) # define namespace used to read a node $nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable) $nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI) - $netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm) - - Write-Host "Node NetFx SNI Version = $($netFxSniVersion.InnerText)" - # update the node inner text - $netFxSniVersion.InnerText = "$SharedSNIVersion" + # update the node inner text for netfx + $netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm) + Write-Host "Current .NET Framework SNI Version = $($netFxSniVersion.InnerText)" + $netFxSniVersion.InnerText = "${{parameters.SNIVersion}}" + # update the node inner text for net core $netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm) - - # update the node inner text - $netCoreSniVersion.InnerText = "$SharedSNIVersion" + Write-Host "Current .NET Core SNI Version = $($netCoreSniVersion.InnerText)" + $netCoreSniVersion.InnerText = "${{parameters.SNIVersion}}" # save the xml file $xml.Save($PropsPath) - type $PropsPath - task: NuGetAuthenticate@1 displayName: 'NuGet Authenticate with SNI Validation Feed' From 2702322e1a6a025e2290d88ead600e0ce56285c6 Mon Sep 17 00:00:00 2001 From: Malcolm Daigle Date: Fri, 28 Feb 2025 10:12:38 -0800 Subject: [PATCH 3/3] Update display names --- eng/pipelines/dotnet-sqlclient-ci-core.yml | 4 +- override.ps1 | 43 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 override.ps1 diff --git a/eng/pipelines/dotnet-sqlclient-ci-core.yml b/eng/pipelines/dotnet-sqlclient-ci-core.yml index d8a9a67b18..dd64e0a301 100644 --- a/eng/pipelines/dotnet-sqlclient-ci-core.yml +++ b/eng/pipelines/dotnet-sqlclient-ci-core.yml @@ -43,13 +43,13 @@ parameters: - name: SNIVersion displayName: | - Use a specific SNI version from the internal validation feed + SNI Version Override type: string default: '' - name: SNIValidationFeed displayName: | - The specific SNI test version is pulled from this feed + SNI Version Override Nuget Feed type: string default: https://sqlclientdrivers.pkgs.visualstudio.com/ADO.Net/_packaging/SNIValidation/nuget/v3/index.json diff --git a/override.ps1 b/override.ps1 new file mode 100644 index 0000000000..4c1a37983f --- /dev/null +++ b/override.ps1 @@ -0,0 +1,43 @@ +#Purpose: Updates SNI Version +Write-Host "SNI Version to test = 123" + +##Get the shared SNI Version from the downloaded artifact +#$SharedSNIVersion = Get-Content -path "$(Pipeline.Workspace)/SharedSNIVersion.txt" + +#Get the SNI Version to test from the user entered version. +$SharedSNIVersion = "123" + +# define file to update +$PropsPath = 'C:\Users\mdaigle\SqlClient\tools\props\Versions.props' +type $PropsPath + +# new version number to update to +##Write-Host "SNI Version to test = $(SNIValidationVersion)" +Write-Host "SNI Version to test = $SharedSNIVersion" + + +# define an xml object +$xml = New-Object XML + +# load content of xml from file defined above +$xml.Load($PropsPath) + +# define namespace used to read a node +$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable) +$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI) +$netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm) + +Write-Host "Node NetFx SNI Version = $($netFxSniVersion.InnerText)" + +# update the node inner text +$netFxSniVersion.InnerText = "$SharedSNIVersion" + +$netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm) + +# update the node inner text +$netCoreSniVersion.InnerText = "$SharedSNIVersion" + +# save the xml file +$xml.Save($PropsPath) + +type $PropsPath