@@ -122,126 +122,6 @@ function Get-AllPackageInfoFromRepo($serviceDirectory)
122122 return $allPackageProps
123123}
124124
125- <#
126- . DESCRIPTION
127- This function governs the logic for determining which packages should be included for validation in net - pullrequest
128- when the PR contains changes to files outside of package directories.
129-
130- . PARAMETER LocatedPackages
131- The set of packages that have been directly changed in the PR.
132-
133- . PARAMETER diffObj
134- The diff object that contains the set of changed and deleted files in the PR.
135-
136- . PARAMETER AllPkgProps
137- The entire set of package properties for the repository.
138-
139- #>
140- function Get-dotnet-AdditionalValidationPackagesFromPackageSet {
141- param (
142- [Parameter (Mandatory = $true )]
143- $LocatedPackages ,
144- [Parameter (Mandatory = $true )]
145- $diffObj ,
146- [Parameter (Mandatory = $true )]
147- $AllPkgProps
148- )
149- $additionalValidationPackages = @ ()
150- $uniqueResultSet = @ ()
151- function isOther ($fileName ) {
152- $startsWithPrefixes = @ (" .config" , " .devcontainer" , " .github" , " .vscode" , " common" , " doc" , " eng" , " samples" )
153-
154- $startsWith = $false
155- foreach ($prefix in $startsWithPrefixes ) {
156- if ($fileName.StartsWith ($prefix )) {
157- $startsWith = $true
158- }
159- }
160-
161- return $startsWith
162- }
163-
164- # ensure we observe deleted files too
165- $targetedFiles = @ ($diffObj.ChangedFiles + $diffObj.DeletedFiles )
166-
167- # The targetedFiles needs to filter out anything in the ExcludePaths
168- # otherwise it'll end up processing things below that it shouldn't be.
169- foreach ($excludePath in $diffObj.ExcludePaths ) {
170- $targetedFiles = $targetedFiles | Where-Object { -not $_.StartsWith ($excludePath ) }
171- }
172-
173- # this section will identify
174- # - any service-level changes
175- # - any shared package changes that should be treated as a service-level change. EG changes to Azure.Storage.Shared.
176- # and add all packages within that service to the validation set. these will be treated as "directly" changed packages.
177- $changedServices = @ ()
178- if ($targetedFiles ) {
179- foreach ($file in $targetedFiles ) {
180- $pathComponents = $file -split " /"
181- # handle changes only in sdk/<service>/<file>.<extension>
182- if ($pathComponents.Length -eq 3 -and $pathComponents [0 ] -eq " sdk" ) {
183- $changedServices += $pathComponents [1 ]
184- }
185-
186- # handle any changes under sdk/<file>.<extension> or any files
187- # in the repository root
188- if (($pathComponents.Length -eq 2 -and $pathComponents [0 ] -eq " sdk" ) -or
189- ($pathComponents.Length -eq 1 )) {
190- $changedServices += " template"
191- }
192-
193- # changes to a Azure.*.Shared within a service directory should include all packages within that service directory
194- if ($file.Replace (' \' , ' /' ) -match " .*sdk/.*/.*\.Shared/.*" ) {
195- $changedServices += $pathComponents [1 ]
196- }
197- }
198- # dedupe the changedServices list before processing
199- $changedServices = $changedServices | Get-Unique
200- foreach ($changedService in $changedServices ) {
201- $additionalPackages = $AllPkgProps | Where-Object { $_.ServiceDirectory -eq $changedService }
202-
203- foreach ($pkg in $additionalPackages ) {
204- if ($uniqueResultSet -notcontains $pkg -and $LocatedPackages -notcontains $pkg ) {
205- # notice the lack of setting IncludedForValidation to true. This is because these "changed services"
206- # are specifically where a file within the service, but not an individual package within that service has changed.
207- # we want this package to be fully validated
208- $uniqueResultSet += $pkg
209- }
210- }
211- }
212- }
213-
214- # handle any changes to files that are not within a package directory
215- $othersChanged = @ ()
216- if ($targetedFiles ) {
217- $othersChanged = $targetedFiles | Where-Object { isOther($_ ) }
218- }
219-
220- if ($othersChanged ) {
221- $additionalPackages = @ (
222- " Azure.Template"
223- ) | ForEach-Object { $me = $_ ; $AllPkgProps | Where-Object { $_.Name -eq $me } | Select-Object - First 1 }
224-
225- $additionalValidationPackages += $additionalPackages
226- }
227-
228- # walk the packages added purely for validation, if they haven't been added yet, add them
229- # these packages aren't considered "directly" changed, so we will set IncludedForValidation to true for them
230- foreach ($pkg in $additionalValidationPackages ) {
231- if ($uniqueResultSet -notcontains $pkg -and $LocatedPackages -notcontains $pkg ) {
232- $pkg.IncludedForValidation = $true
233- $uniqueResultSet += $pkg
234- }
235- }
236-
237- Write-Host " Returning additional packages for validation: $ ( $uniqueResultSet.Count ) "
238- foreach ($pkg in $uniqueResultSet ) {
239- Write-Host " - $ ( $pkg.Name ) "
240- }
241-
242- return $uniqueResultSet
243- }
244-
245125# Returns the nuget publish status of a package id and version.
246126function IsNugetPackageVersionPublished ($pkgId , $pkgVersion )
247127{
0 commit comments