Skip to content

Commit 1e33e82

Browse files
halliprscbedd
andauthored
Test core and template when no packages changed (Azure#2142)
* Test core and template when no packages changed * Test projects if their service files change * Update eng/scripts/Language-Settings.ps1 Co-authored-by: Scott Beddall <[email protected]> * Move array declaration down for easier reading --------- Co-authored-by: Scott Beddall <[email protected]>
1 parent 8d667a4 commit 1e33e82

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,28 @@ function Get-AllPackageInfoFromRepo ([string] $ServiceDirectory) {
118118
return $allPackageProps
119119
}
120120

121+
function Get-rust-AdditionalValidationPackagesFromPackageSet ($packagesWithChanges, $diff, $allPackageProperties) {
122+
# if the change was in a service directory, but not in a package directory, test all the packages in the service directory
123+
[array]$serviceFiles = ($diff.ChangedFiles + $diff.DeletedFiles) | ForEach-Object { $_ -replace '\\', '/' } | Where-Object { $_ -match "^sdk/.+/" }
124+
# remove files that target any specific package
125+
foreach ($package in $allPackageProperties) {
126+
$serviceFiles = $serviceFiles | Where-Object { "$RepoRoot/$_" -notmatch "^$($package.DirectoryPath)/" }
127+
}
128+
129+
$affectedServiceDirectories = $serviceFiles | ForEach-Object { $_ -replace '^sdk/(.+?)/.*', '$1' } | Sort-Object -Unique
130+
131+
$affectedPackages = $allPackageProperties | Where-Object { $affectedServiceDirectories -contains $_.ServiceDirectory }
132+
133+
[array]$additionalPackages = $affectedPackages | Where-Object { $packagesWithChanges -notcontains $_ }
134+
135+
# if the change affected no packages, e.g. eng/common change, we use core and template for validation
136+
if ($additionalPackages.Length -eq 0) {
137+
$additionalPackages += $allPackageProperties | Where-Object { $_.Name -eq "azure_core" -or $_.Name -eq "azure_template" }
138+
}
139+
140+
return $additionalPackages
141+
}
142+
121143
function Get-rust-PackageInfoFromPackageFile([IO.FileInfo]$pkg, [string]$workingDirectory) {
122144
#$pkg will be a FileInfo object for the cargo-metadata.json file in a package artifact directory
123145
$package = Get-Content -Path $pkg.FullName -Raw | ConvertFrom-Json

0 commit comments

Comments
 (0)