Skip to content

Commit d883a79

Browse files
Sync eng/common directory with azure-sdk-tools for PR 8053 (#35135)
* Pass flag to suppress errors correctly when verifying release change log * Changes as per review comments --------- Co-authored-by: Praveen Kuttappan <[email protected]>
1 parent a5d9fd4 commit d883a79

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,23 @@ function Confirm-ChangeLogEntry {
139139
[String]$VersionString,
140140
[boolean]$ForRelease = $false,
141141
[Switch]$SantizeEntry,
142-
[PSCustomObject]$ChangeLogStatus = $null
142+
[PSCustomObject]$ChangeLogStatus = $null,
143+
[boolean]$SuppressErrors = $false
143144
)
144145

145-
$suppressErrors = $false
146146
if (!$ChangeLogStatus) {
147147
$ChangeLogStatus = [PSCustomObject]@{
148148
IsValid = $false
149149
Message = ""
150150
}
151151
}
152-
else {
153-
# Do not stop the script on error when status object is passed as param
154-
$suppressErrors = $true
155-
}
156152
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
157153
$changeLogEntry = $changeLogEntries[$VersionString]
158154

159155
if (!$changeLogEntry) {
160156
$ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] does not have an entry for version ${VersionString}."
161157
$ChangeLogStatus.IsValid = $false
162-
if (!$suppressErrors) {
158+
if (!$SuppressErrors) {
163159
LogError "$($ChangeLogStatus.Message)"
164160
}
165161
return $false
@@ -179,7 +175,7 @@ function Confirm-ChangeLogEntry {
179175
if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus)) {
180176
$ChangeLogStatus.Message = "Entry does not have a release status. Please ensure the status is set to a date '($CHANGELOG_DATE_FORMAT)' or '$CHANGELOG_UNRELEASED_STATUS' if not yet released. See https://aka.ms/azsdk/guideline/changelogs for more info."
181177
$ChangeLogStatus.IsValid = $false
182-
if (!$suppressErrors) {
178+
if (!$SuppressErrors) {
183179
LogError "$($ChangeLogStatus.Message)"
184180
}
185181
return $false
@@ -188,15 +184,15 @@ function Confirm-ChangeLogEntry {
188184
if ($ForRelease -eq $True)
189185
{
190186
LogDebug "Verifying as a release build because ForRelease parameter is set to true"
191-
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus
187+
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors
192188
}
193189

194190
# If the release status is a valid date then verify like its about to be released
195191
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
196192
if ($status -as [DateTime])
197193
{
198194
LogDebug "Verifying as a release build because the changelog entry has a valid date."
199-
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus
195+
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors
200196
}
201197

202198
$ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] has an entry for version ${VersionString}."
@@ -361,26 +357,24 @@ function Confirm-ChangeLogForRelease {
361357
$changeLogEntry,
362358
[Parameter(Mandatory = $true)]
363359
$changeLogEntries,
364-
$ChangeLogStatus = $null
360+
$ChangeLogStatus = $null,
361+
$SuppressErrors = $false
365362
)
366363

367-
$suppressErrors = $false
368364
if (!$ChangeLogStatus) {
369365
$ChangeLogStatus = [PSCustomObject]@{
370366
IsValid = $false
371367
Message = ""
372368
}
373369
}
374-
else {
375-
$suppressErrors = $true
376-
}
370+
377371
$entries = Sort-ChangeLogEntries -changeLogEntries $changeLogEntries
378372

379373
$ChangeLogStatus.IsValid = $true
380374
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
381375
$ChangeLogStatus.Message = "Entry has no release date set. Please ensure to set a release date with format '$CHANGELOG_DATE_FORMAT'. See https://aka.ms/azsdk/guideline/changelogs for more info."
382376
$ChangeLogStatus.IsValid = $false
383-
if (!$suppressErrors) {
377+
if (!$SuppressErrors) {
384378
LogError "$($ChangeLogStatus.Message)"
385379
}
386380
}
@@ -392,7 +386,7 @@ function Confirm-ChangeLogForRelease {
392386
{
393387
$ChangeLogStatus.Message = "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
394388
$ChangeLogStatus.IsValid = $false
395-
if (!$suppressErrors) {
389+
if (!$SuppressErrors) {
396390
LogError "$($ChangeLogStatus.Message)"
397391
}
398392
}
@@ -401,15 +395,15 @@ function Confirm-ChangeLogForRelease {
401395
{
402396
$ChangeLogStatus.Message = "Invalid date [ $status ]. The date for the changelog being released must be the latest in the file."
403397
$ChangeLogStatus.IsValid = $false
404-
if (!$suppressErrors) {
398+
if (!$SuppressErrors) {
405399
LogError "$($ChangeLogStatus.Message)"
406400
}
407401
}
408402
}
409403
catch {
410404
$ChangeLogStatus.Message = "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
411405
$ChangeLogStatus.IsValid = $false
412-
if (!$suppressErrors) {
406+
if (!$SuppressErrors) {
413407
LogError "$($ChangeLogStatus.Message)"
414408
}
415409
}
@@ -418,7 +412,7 @@ function Confirm-ChangeLogForRelease {
418412
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
419413
$ChangeLogStatus.Message = "Entry has no content. Please ensure to provide some content of what changed in this version. See https://aka.ms/azsdk/guideline/changelogs for more info."
420414
$ChangeLogStatus.IsValid = $false
421-
if (!$suppressErrors) {
415+
if (!$SuppressErrors) {
422416
LogError "$($ChangeLogStatus.Message)"
423417
}
424418
}
@@ -441,14 +435,14 @@ function Confirm-ChangeLogForRelease {
441435
{
442436
$ChangeLogStatus.Message = "The changelog entry has the following sections with no content ($($emptySections -join ', ')). Please ensure to either remove the empty sections or add content to the section."
443437
$ChangeLogStatus.IsValid = $false
444-
if (!$suppressErrors) {
438+
if (!$SuppressErrors) {
445439
LogError "$($ChangeLogStatus.Message)"
446440
}
447441
}
448442
if (!$foundRecommendedSection)
449443
{
450444
$ChangeLogStatus.Message = "The changelog entry did not contain any of the recommended sections ($($RecommendedSectionHeaders -join ', ')), please add at least one. See https://aka.ms/azsdk/guideline/changelogs for more info."
451-
if (!$suppressErrors) {
445+
if (!$SuppressErrors) {
452446
LogError "$($ChangeLogStatus.Message)"
453447
}
454448
}

eng/common/scripts/Validate-Package.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function ValidateChangeLog($changeLogPath, $versionString, $validationStatus)
6060
Write-Host "Path to change log: [$changeLogFullPath]"
6161
if (Test-Path $changeLogFullPath)
6262
{
63-
Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus
63+
Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus -SuppressErrors $true
6464
$validationStatus.Status = if ($ChangeLogStatus.IsValid) { "Success" } else { "Failed" }
6565
$validationStatus.Message = $ChangeLogStatus.Message
6666
}

0 commit comments

Comments
 (0)