Skip to content

Commit ddaec90

Browse files
azure-sdkchidozieononiwubenbp
authored
Sync eng/common directory with azure-sdk-tools for PR 2963 (Azure#17496)
* Verify changelog like a release is about to take place if a vlaid date is present * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Update eng/common/scripts/ChangeLog-Operations.ps1 Co-authored-by: Ben Broderick Phillips <ben@benbp.net> * Remove strict date verification * Add function for sorting changelog entries * Minor cleanups Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com> Co-authored-by: Chidozie Ononiwu (His Righteousness) <31145988+chidozieononiwu@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
1 parent df31752 commit ddaec90

File tree

1 file changed

+99
-62
lines changed

1 file changed

+99
-62
lines changed

eng/common/scripts/ChangeLog-Operations.ps1

Lines changed: 99 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -165,61 +165,20 @@ function Confirm-ChangeLogEntry {
165165
return $false
166166
}
167167

168-
if ($ForRelease -eq $True) {
169-
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
170-
LogError "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."
171-
return $false
172-
}
173-
else {
174-
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
175-
try {
176-
$releaseDate = [DateTime]$status
177-
if ($status -ne ($releaseDate.ToString($CHANGELOG_DATE_FORMAT)))
178-
{
179-
LogError "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
180-
return $false
181-
}
182-
if (((Get-Date).AddMonths(-1) -gt $releaseDate) -or ($releaseDate -gt (Get-Date).AddMonths(1)))
183-
{
184-
LogError "The date must be within +/- one month from today. See https://aka.ms/azsdk/guideline/changelogs for more info."
185-
return $false
186-
}
187-
}
188-
catch {
189-
LogError "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
190-
return $false
191-
}
192-
}
193-
194-
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
195-
LogError "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."
196-
return $false
197-
}
168+
if ($ForRelease -eq $True)
169+
{
170+
LogDebug "Verifying as a release build because ForRelease parameter is set to true"
171+
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries
172+
}
198173

199-
$foundRecomendedSection = $false
200-
$emptySections = @()
201-
foreach ($key in $changeLogEntry.Sections.Keys)
202-
{
203-
$sectionContent = $changeLogEntry.Sections[$key]
204-
if ([System.String]::IsNullOrWhiteSpace(($sectionContent | Out-String)))
205-
{
206-
$emptySections += $key
207-
}
208-
if ($RecommendedSectionHeaders -contains $key)
209-
{
210-
$foundRecomendedSection = $true
211-
}
212-
}
213-
if ($emptySections.Count -gt 0)
214-
{
215-
LogError "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."
216-
return $false
217-
}
218-
if (!$foundRecomendedSection)
219-
{
220-
LogWarning "The changelog entry did not contain any of the recommended sections ($($RecommendedSectionHeaders -join ', ')), pease add at least one. See https://aka.ms/azsdk/guideline/changelogs for more info."
221-
}
174+
# If the release status is a valid date then verify like its about to be released
175+
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
176+
if ($status -as [DateTime])
177+
{
178+
LogDebug "Verifying like it's a release build because the changelog entry has a valid date."
179+
return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries
222180
}
181+
223182
return $true
224183
}
225184

@@ -291,15 +250,7 @@ function Set-ChangeLogContent {
291250
$changeLogContent += "$($ChangeLogEntries.InitialAtxHeader) Release History"
292251
$changeLogContent += ""
293252

294-
try
295-
{
296-
$ChangeLogEntries = $ChangeLogEntries.Values | Sort-Object -Descending -Property ReleaseStatus, `
297-
@{e = {[AzureEngSemanticVersion]::new($_.ReleaseVersion)}}
298-
}
299-
catch {
300-
LogError "Problem sorting version in ChangeLogEntries"
301-
return
302-
}
253+
$ChangeLogEntries = Sort-ChangeLogEntries -changeLogEntries $ChangeLogEntries
303254

304255
foreach ($changeLogEntry in $ChangeLogEntries) {
305256
$changeLogContent += $changeLogEntry.ReleaseTitle
@@ -362,4 +313,90 @@ function Get-LatestReleaseDateFromChangeLog
362313
$changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation
363314
$latestVersion = $changeLogEntries[0].ReleaseStatus.Trim("()")
364315
return ($latestVersion -as [DateTime])
316+
}
317+
318+
function Sort-ChangeLogEntries {
319+
param (
320+
[Parameter(Mandatory = $true)]
321+
$changeLogEntries
322+
)
323+
324+
try
325+
{
326+
$changeLogEntries = $ChangeLogEntries.Values | Sort-Object -Descending -Property ReleaseStatus, `
327+
@{e = {[AzureEngSemanticVersion]::new($_.ReleaseVersion)}}
328+
}
329+
catch {
330+
LogError "Problem sorting version in ChangeLogEntries"
331+
exit(1)
332+
}
333+
return $changeLogEntries
334+
}
335+
336+
function Confirm-ChangeLogForRelease {
337+
param (
338+
[Parameter(Mandatory = $true)]
339+
$changeLogEntry,
340+
[Parameter(Mandatory = $true)]
341+
$changeLogEntries
342+
)
343+
344+
$entries = Sort-ChangeLogEntries -changeLogEntries $changeLogEntries
345+
346+
$isValid = $true
347+
if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) {
348+
LogError "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."
349+
$isValid = $false
350+
}
351+
else {
352+
$status = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
353+
try {
354+
$releaseDate = [DateTime]$status
355+
if ($status -ne ($releaseDate.ToString($CHANGELOG_DATE_FORMAT)))
356+
{
357+
LogError "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info."
358+
$isValid = $false
359+
}
360+
361+
if (@($entries.ReleaseStatus)[0] -ne $changeLogEntry.ReleaseStatus)
362+
{
363+
LogError "Invalid date [ $status ]. The date for the changelog being released must be the latest in the file."
364+
$isValid = $false
365+
}
366+
}
367+
catch {
368+
LogError "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info."
369+
$isValid = $false
370+
}
371+
}
372+
373+
if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) {
374+
LogError "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."
375+
$isValid = $false
376+
}
377+
378+
$foundRecommendedSection = $false
379+
$emptySections = @()
380+
foreach ($key in $changeLogEntry.Sections.Keys)
381+
{
382+
$sectionContent = $changeLogEntry.Sections[$key]
383+
if ([System.String]::IsNullOrWhiteSpace(($sectionContent | Out-String)))
384+
{
385+
$emptySections += $key
386+
}
387+
if ($RecommendedSectionHeaders -contains $key)
388+
{
389+
$foundRecommendedSection = $true
390+
}
391+
}
392+
if ($emptySections.Count -gt 0)
393+
{
394+
LogError "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."
395+
$isValid = $false
396+
}
397+
if (!$foundRecommendedSection)
398+
{
399+
LogWarning "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."
400+
}
401+
return $isValid
365402
}

0 commit comments

Comments
 (0)