@@ -77,11 +77,13 @@ class PackageProps {
77
77
$this.ArtifactName = $artifactName
78
78
$this.Initialize ($name , $version , $directoryPath , $serviceDirectory )
79
79
}
80
- hidden [PSCustomObject ]ParseYmlForArtifact([string ]$ymlPath ) {
80
+
81
+ hidden [PSCustomObject ]ParseYmlForArtifact([string ]$ymlPath , [bool ]$soleCIYml = $false ) {
81
82
$content = LoadFrom- Yaml $ymlPath
82
83
if ($content ) {
83
84
$artifacts = GetValueSafelyFrom- Yaml $content @ (" extends" , " parameters" , " Artifacts" )
84
- $artifactForCurrentPackage = $null
85
+ $artifactForCurrentPackage = @ {}
86
+
85
87
if ($artifacts ) {
86
88
# If there's an artifactName match that to the name field from the yml
87
89
if ($this.ArtifactName ) {
@@ -98,8 +100,9 @@ class PackageProps {
98
100
}
99
101
}
100
102
101
- # if we found an artifact for the current package, we should count this ci file as the source of the matrix for this package
102
- if ($artifactForCurrentPackage ) {
103
+ # if we found an artifact for the current package OR this is the sole ci.yml for the given service directory,
104
+ # we should count this ci file as the source of the matrix for this package
105
+ if ($artifactForCurrentPackage -or $soleCIYml ) {
103
106
$result = [PSCustomObject ]@ {
104
107
ArtifactConfig = [HashTable ]$artifactForCurrentPackage
105
108
ParsedYml = $content
@@ -116,11 +119,12 @@ class PackageProps {
116
119
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot " .." " .." " .." )
117
120
118
121
$ciFolderPath = Join-Path - Path $RepoRoot - ChildPath (Join-Path " sdk" $this.ServiceDirectory )
119
- $ciFiles = Get-ChildItem - Path $ciFolderPath - Filter " ci*.yml" - File
122
+ $ciFiles = @ ( Get-ChildItem - Path $ciFolderPath - Filter " ci*.yml" - File)
120
123
$ciArtifactResult = $null
124
+ $soleCIYml = ($ciFiles.Count -eq 1 )
121
125
122
126
foreach ($ciFile in $ciFiles ) {
123
- $ciArtifactResult = $this.ParseYmlForArtifact ($ciFile.FullName )
127
+ $ciArtifactResult = $this.ParseYmlForArtifact ($ciFile.FullName , $soleCIYml )
124
128
if ($ciArtifactResult ) {
125
129
break
126
130
}
@@ -137,7 +141,7 @@ class PackageProps {
137
141
if (-not $this.ArtifactDetails ) {
138
142
$ciArtifactResult = $this.GetCIYmlForArtifact ()
139
143
140
- if ($ciArtifactResult ) {
144
+ if ($ciArtifactResult -and $null -ne $ciArtifactResult .ArtifactConfig ) {
141
145
$this.ArtifactDetails = [Hashtable ]$ciArtifactResult.ArtifactConfig
142
146
143
147
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot " .." " .." " .." )
@@ -147,27 +151,32 @@ class PackageProps {
147
151
if (-not $this.ArtifactDetails [" triggeringPaths" ]) {
148
152
$this.ArtifactDetails [" triggeringPaths" ] = @ ()
149
153
}
150
- else {
151
- $adjustedPaths = @ ()
152
-
153
- # we need to convert relative references to absolute references within the repo
154
- # this will make it extremely easy to compare triggering paths to files in the deleted+changed file list.
155
- for ($i = 0 ; $i -lt $this.ArtifactDetails [" triggeringPaths" ].Count; $i ++ ) {
156
- $currentPath = $this.ArtifactDetails [" triggeringPaths" ][$i ]
157
- $newPath = Join-Path $repoRoot $currentPath
158
- if (! $currentPath.StartsWith (" /" )) {
159
- $newPath = Join-Path $repoRoot $relRoot $currentPath
160
- }
161
- # it is a possibility that users may have a triggerPath dependency on a file that no longer exists.
162
- # before we resolve it to get rid of possible relative references, we should check if the file exists
163
- # if it doesn't, we should just leave it as is. Otherwise we would _crash_ here when a user accidentally
164
- # left a triggeringPath on a file that had been deleted
165
- if (Test-Path $newPath ) {
166
- $adjustedPaths += (Resolve-Path - Path $newPath - Relative - RelativeBasePath $repoRoot ).TrimStart(" ." ).Replace(" `\" , " /" )
167
- }
154
+
155
+ # if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
156
+ $serviceTriggeringPaths = GetValueSafelyFrom- Yaml $ciArtifactResult.ParsedYml @ (" extends" , " parameters" , " TriggeringPaths" )
157
+ if ($serviceTriggeringPaths ){
158
+ $this.ArtifactDetails [" triggeringPaths" ] += $serviceTriggeringPaths
159
+ }
160
+
161
+ $adjustedPaths = @ ()
162
+
163
+ # we need to convert relative references to absolute references within the repo
164
+ # this will make it extremely easy to compare triggering paths to files in the deleted+changed file list.
165
+ for ($i = 0 ; $i -lt $this.ArtifactDetails [" triggeringPaths" ].Count; $i ++ ) {
166
+ $currentPath = $this.ArtifactDetails [" triggeringPaths" ][$i ]
167
+ $newPath = Join-Path $repoRoot $currentPath
168
+ if (! $currentPath.StartsWith (" /" )) {
169
+ $newPath = Join-Path $repoRoot $relRoot $currentPath
170
+ }
171
+ # it is a possibility that users may have a triggerPath dependency on a file that no longer exists.
172
+ # before we resolve it to get rid of possible relative references, we should check if the file exists
173
+ # if it doesn't, we should just leave it as is. Otherwise we would _crash_ here when a user accidentally
174
+ # left a triggeringPath on a file that had been deleted
175
+ if (Test-Path $newPath ) {
176
+ $adjustedPaths += (Resolve-Path - Path $newPath - Relative - RelativeBasePath $repoRoot ).TrimStart(" ." ).Replace(" `\" , " /" )
168
177
}
169
- $this.ArtifactDetails [" triggeringPaths" ] = $adjustedPaths
170
178
}
179
+ $this.ArtifactDetails [" triggeringPaths" ] = $adjustedPaths
171
180
$this.ArtifactDetails [" triggeringPaths" ] += $ciYamlPath
172
181
173
182
$this.CIParameters [" CIMatrixConfigs" ] = @ ()
@@ -215,6 +224,22 @@ function Get-PkgProperties {
215
224
return $null
216
225
}
217
226
227
+ function Get-PackagesFromPackageInfo ([string ]$PackageInfoFolder , [bool ]$IncludeIndirect , [ScriptBlock ]$CustomCompareFunction = $null ) {
228
+ $packages = Get-ChildItem - R - Path $PackageInfoFolder - Filter " *.json" | ForEach-Object {
229
+ Get-Content $_.FullName | ConvertFrom-Json
230
+ }
231
+
232
+ if (-not $includeIndirect ) {
233
+ $packages = $packages | Where-Object { $_.IncludedForValidation -eq $false }
234
+ }
235
+
236
+ if ($CustomCompareFunction ) {
237
+ $packages = $packages | Where-Object { & $CustomCompareFunction $_ }
238
+ }
239
+
240
+ return $packages
241
+ }
242
+
218
243
219
244
function Get-TriggerPaths ([PSCustomObject ]$AllPackageProperties ) {
220
245
$existingTriggeringPaths = @ ()
@@ -447,7 +472,8 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
447
472
# finally, if we have gotten all the way here and we still don't have any packages, we should include the template service
448
473
# packages. We should never return NO validation.
449
474
if ($packagesWithChanges.Count -eq 0 ) {
450
- $packagesWithChanges += ($allPackageProperties | Where-Object { $_.ServiceDirectory -eq " template" })
475
+ # most of our languages use `template` as the service directory for the template service, but `go` uses `template/aztemplate`.
476
+ $packagesWithChanges += ($allPackageProperties | Where-Object { $_.ServiceDirectory -eq " template" -or $_.ServiceDirectory -eq " template/aztemplate" })
451
477
foreach ($package in $packagesWithChanges ) {
452
478
$package.IncludedForValidation = $true
453
479
}
0 commit comments