@@ -148,7 +148,6 @@ function Get-dotnet-AdditionalValidationPackagesFromPackageSet {
148148 )
149149 $additionalValidationPackages = @ ()
150150 $uniqueResultSet = @ ()
151-
152151 function isOther ($fileName ) {
153152 $startsWithPrefixes = @ (" .config" , " .devcontainer" , " .github" , " .vscode" , " common" , " doc" , " eng" , " samples" )
154153
@@ -162,23 +161,42 @@ function Get-dotnet-AdditionalValidationPackagesFromPackageSet {
162161 return $startsWith
163162 }
164163
165- # this section will identify the list of packages that we should treat as
166- # "directly" changed for a given service level change. While that doesn't
167- # directly change a package within the service, I do believe we should directly include all
168- # packages WITHIN that service. This is because the service level file changes are likely to
169- # have an impact on the packages within that service.
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.
170177 $changedServices = @ ()
171- if ($diffObj .ChangedFiles ) {
172- foreach ($file in $diffObj .ChangedFiles ) {
178+ if ($targetedFiles ) {
179+ foreach ($file in $targetedFiles ) {
173180 $pathComponents = $file -split " /"
174- # handle changes only in sdk/<service>/<file>/ <extension>
181+ # handle changes only in sdk/<service>/<file>. <extension>
175182 if ($pathComponents.Length -eq 3 -and $pathComponents [0 ] -eq " sdk" ) {
176- $changedServices += $pathComponents [1 ]
183+ if (-not $changedServices.Contains ($pathComponents [1 ])) {
184+ $changedServices += $pathComponents [1 ]
185+ }
177186 }
178187
179188 # handle any changes under sdk/<file>.<extension>
180189 if ($pathComponents.Length -eq 2 -and $pathComponents [0 ] -eq " sdk" ) {
181- $changedServices += " template"
190+ if (-not $changedServices.Contains (" template" )) {
191+ $changedServices += " template"
192+ }
193+ }
194+
195+ # changes to a Azure.*.Shared within a service directory should include all packages within that service directory
196+ if ($file.Replace (' \' , ' /' ) -match " .*sdk/.*/.*\.Shared/.*" ) {
197+ if (-not $changedServices.Contains ($pathComponents [1 ])) {
198+ $changedServices += $pathComponents [1 ]
199+ }
182200 }
183201 }
184202 foreach ($changedService in $changedServices ) {
@@ -195,9 +213,10 @@ function Get-dotnet-AdditionalValidationPackagesFromPackageSet {
195213 }
196214 }
197215
216+ # handle any changes to files that are not within a package directory
198217 $othersChanged = @ ()
199- if ($diffObj .ChangedFiles ) {
200- $othersChanged = $diffObj .ChangedFiles | Where-Object { isOther($_ ) }
218+ if ($targetedFiles ) {
219+ $othersChanged = $targetedFiles | Where-Object { isOther($_ ) }
201220 }
202221
203222 if ($othersChanged ) {
@@ -208,6 +227,8 @@ function Get-dotnet-AdditionalValidationPackagesFromPackageSet {
208227 $additionalValidationPackages += $additionalPackages
209228 }
210229
230+ # walk the packages added purely for validation, if they haven't been added yet, add them
231+ # these packages aren't considered "directly" changed, so we will set IncludedForValidation to true for them
211232 foreach ($pkg in $additionalValidationPackages ) {
212233 if ($uniqueResultSet -notcontains $pkg -and $LocatedPackages -notcontains $pkg ) {
213234 $pkg.IncludedForValidation = $true
0 commit comments