Sync eng/common directory with azure-sdk-tools for PR 8053 (#5507)
* Pass flag to suppress errors correctly when verifying release change log * Changes as per review comments --------- Co-authored-by: Praveen Kuttappan <prmarott@microsoft.com>
This commit is contained in:
parent
7f2f593b30
commit
ff62f2f548
@ -139,27 +139,23 @@ function Confirm-ChangeLogEntry {
|
||||
[String]$VersionString,
|
||||
[boolean]$ForRelease = $false,
|
||||
[Switch]$SantizeEntry,
|
||||
[PSCustomObject]$ChangeLogStatus = $null
|
||||
[PSCustomObject]$ChangeLogStatus = $null,
|
||||
[boolean]$SuppressErrors = $false
|
||||
)
|
||||
|
||||
$suppressErrors = $false
|
||||
if (!$ChangeLogStatus) {
|
||||
$ChangeLogStatus = [PSCustomObject]@{
|
||||
IsValid = $false
|
||||
Message = ""
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Do not stop the script on error when status object is passed as param
|
||||
$suppressErrors = $true
|
||||
}
|
||||
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
|
||||
$changeLogEntry = $changeLogEntries[$VersionString]
|
||||
|
||||
if (!$changeLogEntry) {
|
||||
$ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] does not have an entry for version ${VersionString}."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
return $false
|
||||
@ -179,7 +175,7 @@ function Confirm-ChangeLogEntry {
|
||||
if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus)) {
|
||||
$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."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
return $false
|
||||
@ -188,7 +184,7 @@ function Confirm-ChangeLogEntry {
|
||||
if ($ForRelease -eq $True)
|
||||
{
|
||||
LogDebug "Verifying as a release build because ForRelease parameter is set to true"
|
||||
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus
|
||||
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors
|
||||
}
|
||||
|
||||
# If the release status is a valid date then verify like its about to be released
|
||||
@ -196,7 +192,7 @@ function Confirm-ChangeLogEntry {
|
||||
if ($status -as [DateTime])
|
||||
{
|
||||
LogDebug "Verifying as a release build because the changelog entry has a valid date."
|
||||
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus
|
||||
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors
|
||||
}
|
||||
|
||||
$ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] has an entry for version ${VersionString}."
|
||||
@ -361,26 +357,24 @@ function Confirm-ChangeLogForRelease {
|
||||
$changeLogEntry,
|
||||
[Parameter(Mandatory = $true)]
|
||||
$changeLogEntries,
|
||||
$ChangeLogStatus = $null
|
||||
$ChangeLogStatus = $null,
|
||||
$SuppressErrors = $false
|
||||
)
|
||||
|
||||
$suppressErrors = $false
|
||||
if (!$ChangeLogStatus) {
|
||||
$ChangeLogStatus = [PSCustomObject]@{
|
||||
IsValid = $false
|
||||
Message = ""
|
||||
}
|
||||
}
|
||||
else {
|
||||
$suppressErrors = $true
|
||||
}
|
||||
|
||||
$entries = Sort-ChangeLogEntries -changeLogEntries $changeLogEntries
|
||||
|
||||
$ChangeLogStatus.IsValid = $true
|
||||
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
|
||||
$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."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
@ -392,7 +386,7 @@ function Confirm-ChangeLogForRelease {
|
||||
{
|
||||
$ChangeLogStatus.Message = "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
@ -401,7 +395,7 @@ function Confirm-ChangeLogForRelease {
|
||||
{
|
||||
$ChangeLogStatus.Message = "Invalid date [ $status ]. The date for the changelog being released must be the latest in the file."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
@ -409,7 +403,7 @@ function Confirm-ChangeLogForRelease {
|
||||
catch {
|
||||
$ChangeLogStatus.Message = "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
@ -418,7 +412,7 @@ function Confirm-ChangeLogForRelease {
|
||||
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
|
||||
$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."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
@ -441,14 +435,14 @@ function Confirm-ChangeLogForRelease {
|
||||
{
|
||||
$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."
|
||||
$ChangeLogStatus.IsValid = $false
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
if (!$foundRecommendedSection)
|
||||
{
|
||||
$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."
|
||||
if (!$suppressErrors) {
|
||||
if (!$SuppressErrors) {
|
||||
LogError "$($ChangeLogStatus.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ function ValidateChangeLog($changeLogPath, $versionString, $validationStatus)
|
||||
Write-Host "Path to change log: [$changeLogFullPath]"
|
||||
if (Test-Path $changeLogFullPath)
|
||||
{
|
||||
Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus
|
||||
Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus -SuppressErrors $true
|
||||
$validationStatus.Status = if ($ChangeLogStatus.IsValid) { "Success" } else { "Failed" }
|
||||
$validationStatus.Message = $ChangeLogStatus.Message
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user