Skip to content

Commit f3cc572

Browse files
committed
Run test on all modules
1 parent 5a09e98 commit f3cc572

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

.azure-pipelines/PipelineSteps/BatchGeneration/filter.ps1

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,41 @@ param (
1111

1212
$utilFilePath = Join-Path $RepoRoot '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'util.psm1'
1313
Import-Module $utilFilePath -Force
14+
$artifactsDir = Join-Path $RepoRoot 'artifacts'
1415

1516
$changedModulesDict = @{}
1617
$changedSubModulesDict = @{}
17-
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
18-
if ($ChangedFiles[$i] -match '^(src|generated)/([^/]+)/([^/]+\.autorest)/') {
19-
$parent = $Matches[2]
20-
$child = $Matches[3]
21-
$key = "$parent/$child"
22-
23-
$changedModulesDict[$parent] = $true
24-
$changedSubModulesDict[$key] = $true
18+
if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
19+
Write-Host "Run test on all modules"
20+
$V4ModulesFile = Join-Path $artifactsDir "generationTargets.json"
21+
$V4ModuleMaps = Get-Content -Raw -Path $V4ModulesFile | ConvertFrom-Json
22+
23+
foreach ($matrixKey in $V4ModuleMaps.PSObject.Properties.Name) {
24+
Write-Host "##[group]Matrix key: $matrixKey"
25+
$moduleMap = $V4ModuleMaps.$matrixKey
26+
foreach ($moduleName in $moduleMap.PSObject.Properties.Name) {
27+
foreach ($subModuleName in $moduleMap.$moduleName) {
28+
$subModule = "$moduleName/$subModuleName"
29+
$changedModulesDict[$moduleName] = $true
30+
$changedSubModulesDict[$subModule] = $true
31+
}
32+
}
33+
}
34+
}
35+
else {
36+
Write-Host "Run test on changed modules"
37+
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
38+
if ($ChangedFiles[$i] -match '^(src|generated)/([^/]+)/([^/]+\.autorest)/') {
39+
$moduleName = $Matches[2]
40+
$subModuleName = $Matches[3]
41+
$subModule = "$moduleName/$subModuleName"
42+
43+
$changedModulesDict[$moduleName] = $true
44+
$changedSubModulesDict[$subModule] = $true
45+
}
2546
}
2647
}
48+
2749
$changedModules = $changedModulesDict.Keys | Sort-Object
2850
$changedSubModules = $changedSubModulesDict.Keys | Sort-Object
2951

.azure-pipelines/batch-generation.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ stages:
131131
git fetch origin "${{ variables.GenerationBranch }}"
132132
git checkout "${{ variables.GenerationBranch }}"
133133
134+
- task: DownloadPipelineArtifact@2
135+
inputs:
136+
artifactName: 'prepare'
137+
targetPath: artifacts
138+
134139
- download: current
135140
patterns: '**/changed-*.patch'
136141
displayName: 'Download all .patch artifacts'
@@ -172,6 +177,8 @@ stages:
172177
173178
$filterModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'filter.ps1'
174179
& $filterModulesPath -MaxParallelBuildJobs "${{ variables.MaxParallelBuildJobs }}" -MaxParallelAnalyzeJobs "${{ variables.MaxParallelAnalyzeJobs }}" -MaxParallelTestWindowsJobs "${{ variables.MaxParallelTestWindowsJobs }}" -MaxParallelTestLinuxJobs "${{ variables.MaxParallelTestLinuxJobs }}" -MaxParallelTestMacJobs "${{ variables.MaxParallelTestMacJobs }}" -ChangedFiles $changedFiles -RepoRoot "$(Build.SourcesDirectory)"
180+
env:
181+
RUN_TEST_ON_ALL_MODULES: $(RUN_TEST_ON_ALL_MODULES)
175182

176183
- task: PublishPipelineArtifact@1
177184
displayName: 'Upload filtered targets'

0 commit comments

Comments
 (0)