Skip to content

Commit f3b8726

Browse files
committed
change variable to parameter
1 parent 2e5fe55 commit f3b8726

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@ $artifactsDir = Join-Path $RepoRoot 'artifacts'
1515

1616
$changedModulesDict = @{}
1717
$changedSubModulesDict = @{}
18-
if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
18+
if ($env:TEST_CHANGED_MODULES_ONLY -eq "True") {
19+
Write-Host "Run test on generated folder changed modules"
20+
# Only generated folder change should trigger the test
21+
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
22+
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.Autorest)/') {
23+
$moduleName = $Matches[1]
24+
$subModuleName = $Matches[2]
25+
$subModule = "$moduleName/$subModuleName"
26+
27+
$changedModulesDict[$moduleName] = $true
28+
$changedSubModulesDict[$subModule] = $true
29+
}
30+
}
31+
}
32+
else {
1933
Write-Host "Run test on all modules"
2034
$V4ModulesFile = Join-Path $artifactsDir "generationTargets.json"
2135
$V4ModuleMaps = Get-Content -Raw -Path $V4ModulesFile | ConvertFrom-Json
@@ -31,20 +45,6 @@ if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
3145
}
3246
}
3347
}
34-
else {
35-
Write-Host "Run test on generated folder changed modules"
36-
# Only generated folder change should trigger the test
37-
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
38-
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.Autorest)/') {
39-
$moduleName = $Matches[1]
40-
$subModuleName = $Matches[2]
41-
$subModule = "$moduleName/$subModuleName"
42-
43-
$changedModulesDict[$moduleName] = $true
44-
$changedSubModulesDict[$subModule] = $true
45-
}
46-
}
47-
}
4848

4949
$changedModules = $changedModulesDict.Keys | Sort-Object
5050
$changedSubModules = $changedSubModulesDict.Keys | Sort-Object

.azure-pipelines/batch-generation.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
parameters:
2+
- name: TestChangedModulesOnly
3+
displayName: 'Only run tests on modules that are changed by regeneration'
4+
type: string
5+
default: 'True'
6+
17
variables:
28
IntermediateStepTimeoutInMinutes: 30
39
GenerateTimeoutInMinutes: 120
@@ -212,7 +218,7 @@ stages:
212218
-ChangedFiles $changedFiles `
213219
-RepoRoot "$(Build.SourcesDirectory)"
214220
env:
215-
RUN_TEST_ON_ALL_MODULES: $(RUN_TEST_ON_ALL_MODULES)
221+
TEST_CHANGED_MODULES_ONLY: ${{ parameters.TestChangedModulesOnly }}
216222

217223
- task: PublishPipelineArtifact@1
218224
displayName: 'Upload filtered targets'

0 commit comments

Comments
 (0)