Skip to content

Fix batch generation build artifact #27945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .azure-pipelines/PipelineSteps/BatchGeneration/filter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
}
else {
Write-Host "Run test on generated folder changed modules"
# Only generated filder change should trigger the test
# Only generated folder change should trigger the test
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.autorest)/') {
$moduleName = $Matches[2]
$subModuleName = $Matches[3]
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.Autorest)/') {
$moduleName = $Matches[1]
$subModuleName = $Matches[2]
$subModule = "$moduleName/$subModuleName"

$changedModulesDict[$moduleName] = $true
Expand All @@ -63,6 +63,11 @@ foreach ($subModule in $changedSubModules) {
Write-Host "##[endgroup]"
Write-Host

$changedModulesRecordFile = Join-Path $artifactsDir 'filteredChangedModules.txt'
$changedModules | Set-Content -Path $changedModulesRecordFile -Encoding UTF8
$changedSubModulesRecordFile = Join-Path $artifactsDir 'filteredChangedSubModules.txt'
$changedSubModules | Set-Content -Path $changedSubModulesRecordFile -Encoding UTF8

$groupedBuildModules = Group-Modules -Modules $changedModules -MaxParallelJobs $MaxParallelBuildJobs
Write-Matrix -GroupedModules $groupedBuildModules -VariableName 'buildTargets' -RepoRoot $RepoRoot

Expand Down
11 changes: 7 additions & 4 deletions .azure-pipelines/PipelineSteps/BatchGeneration/prepare.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ foreach ($moduleGroup in $groupedModules) {
$index++
}

$generationTargetsOutputDir = Join-Path $RepoRoot "artifacts"
if (-not (Test-Path -Path $generationTargetsOutputDir)) {
New-Item -ItemType Directory -Path $generationTargetsOutputDir
$artifactsDir = Join-Path $RepoRoot "artifacts"
if (-not (Test-Path -Path $artifactsDir)) {
New-Item -ItemType Directory -Path $artifactsDir
}
$generationTargetsOutputFile = Join-Path $generationTargetsOutputDir "generationTargets.json"
$generationTargetsOutputFile = Join-Path $artifactsDir "generationTargets.json"
$generationTargets | ConvertTo-Json -Depth 5 | Out-File -FilePath $generationTargetsOutputFile -Encoding utf8

if ($MatrixStr -and $MatrixStr.Length -gt 1) {
$MatrixStr = $MatrixStr.Substring(1)
}
Write-Host "##vso[task.setVariable variable=generationTargets;isOutput=true]{$MatrixStr}"

$V4ModulesRecordFile = Join-Path $artifactsDir 'preparedV4Modules.txt'
$modules | Set-Content -Path $V4ModulesRecordFile -Encoding UTF8
Loading