Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15a526a

Browse files
committedMay 14, 2025·
Add change log
1 parent f3cc572 commit 15a526a

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed
 

‎.azure-pipelines/PipelineSteps/BatchGeneration/batch-generate-modules.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
param (
22
[string]$MatrixKey,
3-
[string]$RepoRoot
3+
[string]$RepoRoot,
4+
[string]$CommitTitle
45
)
56

67
$generationTargetsOutputFile = Join-Path $RepoRoot "artifacts" "generationTargets.json"
@@ -33,6 +34,7 @@ foreach ($moduleName in $sortedModuleNames) {
3334
Module = $moduleName
3435
DurationSeconds = 0
3536
Status = "Success"
37+
Changed = "No"
3638
SubModules = @()
3739
}
3840

@@ -78,6 +80,32 @@ foreach ($moduleName in $sortedModuleNames) {
7880
$moduleResult.SubModules += $subModuleResult
7981
}
8082
}
83+
84+
Set-Location $RepoRoot
85+
$srcFolderModuleRelativePath = ".\src\$moduleName"
86+
$generatedFolderModuleRelativePath = ".\generated\$moduleName"
87+
$diffSrc = git diff --name-only HEAD -- $srcFolderModuleRelativePath
88+
$diffGenerated = git diff --name-only HEAD -- $generatedFolderModuleRelativePath
89+
$diff = $diffSrc -or $diffGenerated
90+
if ($diff) {
91+
Write-Host "Changes detected in $moduleName, adding change log"
92+
$moduleResult.Changed = "Yes"
93+
$changeLogPath = Join-Path $RepoRoot "src" $moduleName $moduleName "ChangeLog.md"
94+
$changeLogContent = Get-Content $changeLogPath
95+
$newChangeLogEntry = "* Autorest Upgration: $CommitTitle"
96+
97+
$index = $changeLogContent.IndexOf("## Upcoming Release")
98+
if ($index -ge 0) {
99+
$newChangeLogContent = $changeLogContent[0..$index] + $newChangeLogEntry + $changeLogContent[($index + 1)..($changeLogContent.Count - 1)]
100+
Set-Content $changelogPath -Value $newChangeLogContent
101+
$moduleResult.Changed = "Yes, Change Log Updated"
102+
Write-Host "New change log entry added to $changeLogPath"
103+
} else {
104+
$moduleResult.Changed = "Yes, Change Log Not Updated"
105+
Write-Host "Can not find '## Upcoming Release'"
106+
}
107+
}
108+
81109
$moduleEndTime = Get-Date
82110
$moduleResult.DurationSeconds = ($moduleEndTime - $moduleStartTime).TotalSeconds
83111
$results += $moduleResult

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
2121
$V4ModuleMaps = Get-Content -Raw -Path $V4ModulesFile | ConvertFrom-Json
2222

2323
foreach ($matrixKey in $V4ModuleMaps.PSObject.Properties.Name) {
24-
Write-Host "##[group]Matrix key: $matrixKey"
2524
$moduleMap = $V4ModuleMaps.$matrixKey
2625
foreach ($moduleName in $moduleMap.PSObject.Properties.Name) {
2726
foreach ($subModuleName in $moduleMap.$moduleName) {

‎.azure-pipelines/batch-generation.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
parameters:
2+
- name: CommitTitle
3+
displayName: 'Title of the commit that trigger batch generation'
4+
type: string
5+
default: 'Default commit title'
6+
17
variables:
28
IntermediateStepTimeoutInMinutes: 30
39
GenerateTimeoutInMinutes: 120
@@ -98,7 +104,7 @@ stages:
98104
git checkout "${{ variables.GenerationBranch }}"
99105
100106
$batchGenerateModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'batch-generate-modules.ps1'
101-
& $batchGenerateModulesPath -MatrixKey "$(MatrixKey)" -RepoRoot "$(Build.SourcesDirectory)"
107+
& $batchGenerateModulesPath -MatrixKey "$(MatrixKey)" -RepoRoot "$(Build.SourcesDirectory)" -CommitTitle "${{ parameters.CommitTitle }}"
102108
103109
workingDirectory: $(Build.SourcesDirectory)
104110

@@ -159,7 +165,7 @@ stages:
159165
}
160166
161167
git add .
162-
git commit -m "Apply matrix job patches to ${{ variables.GenerationBranch }}"
168+
git commit -m "Apply batch generation patches to ${{ variables.GenerationBranch }}"
163169
git push origin "${{ variables.GenerationBranch }}"
164170
165171
- task: PowerShell@2
@@ -176,7 +182,14 @@ stages:
176182
git checkout $sourceBranchName
177183
178184
$filterModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'filter.ps1'
179-
& $filterModulesPath -MaxParallelBuildJobs "${{ variables.MaxParallelBuildJobs }}" -MaxParallelAnalyzeJobs "${{ variables.MaxParallelAnalyzeJobs }}" -MaxParallelTestWindowsJobs "${{ variables.MaxParallelTestWindowsJobs }}" -MaxParallelTestLinuxJobs "${{ variables.MaxParallelTestLinuxJobs }}" -MaxParallelTestMacJobs "${{ variables.MaxParallelTestMacJobs }}" -ChangedFiles $changedFiles -RepoRoot "$(Build.SourcesDirectory)"
185+
& $filterModulesPath `
186+
-MaxParallelBuildJobs "${{ variables.MaxParallelBuildJobs }}" `
187+
-MaxParallelAnalyzeJobs "${{ variables.MaxParallelAnalyzeJobs }}" `
188+
-MaxParallelTestWindowsJobs "${{ variables.MaxParallelTestWindowsJobs }}" `
189+
-MaxParallelTestLinuxJobs "${{ variables.MaxParallelTestLinuxJobs }}" `
190+
-MaxParallelTestMacJobs "${{ variables.MaxParallelTestMacJobs }}" `
191+
-ChangedFiles $changedFiles `
192+
-RepoRoot "$(Build.SourcesDirectory)"
180193
env:
181194
RUN_TEST_ON_ALL_MODULES: $(RUN_TEST_ON_ALL_MODULES)
182195

0 commit comments

Comments
 (0)
Please sign in to comment.