Skip to content
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

Sync eng/common directory with azure-sdk-tools for PR 8053 #39640

Merged
merged 2 commits into from
Apr 10, 2024
Merged
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
38 changes: 16 additions & 22 deletions eng/common/scripts/ChangeLog-Operations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -188,15 +184,15 @@ 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
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
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}."
Expand Down Expand Up @@ -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)"
}
}
Expand All @@ -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)"
}
}
Expand All @@ -401,15 +395,15 @@ 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)"
}
}
}
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)"
}
}
Expand All @@ -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)"
}
}
Expand All @@ -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)"
}
}
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Validate-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading