Skip to content

Commit

Permalink
Fix many many bugs in the changelog generation script:
Browse files Browse the repository at this point in the history
84: Pass StartDate and EndDate to Get-MergedPullRequests instead of special casing only Credentials
109+130: Fix calculating negative progress caused by seeing PRs in the future because GitHub returns times in UTC
268: Actually make filtering for infrastructure PRs functional
303: Fix extraction of port-version from vcpkg.json. This really should be handled by diffing baseline.json in the future.
374-382: Fix expression ordering and casting problem which prevented non-CONTROL ports from ever being considered "new"

Also skip emitting headers for empty blocks, update and sort current triplet list, and move infrastructure bits below
port modifications.

Example output:

vcpkg (2022.02.19 - 2022.02.22)
---
#### Total port count:
#### Total port count per triplet (tested):
|triplet|ports available|
|---|---|
|x86-windows|NUM|
|**x64-windows**|NUM|
|x64-windows-static|NUM|
|x64-windows-static-md|NUM|
|x64-uwp|NUM|
|arm64-windows|NUM|
|arm-uwp|NUM|
|**x64-osx**|NUM|
|**x64-linux**|NUM|
<details>
<summary><b>The following 2 ports have been added:</b></summary>

|port|version|
|---|---|
|[libcurl-simple-https](microsoft#22917
|[triton](microsoft#23111

</details>
<details>
<summary><b>The following 18 ports have been updated:</b></summary>

- polyhook2 `2022-02-06#0` -> `2022-02-21#0`
    - [(microsoft#23203)](microsoft#23203) [polyhook2] Update to latest (2022-02-21) (by @acidicoala)
- graphviz `2.49.1#1` -> `2.49.1#2`
    - [(microsoft#23148)](microsoft#23148) [graphviz] Fix tools (by @Ace314159)
- itk `5.1.0#7` -> `5.2.1#0`
    - [(microsoft#23158)](microsoft#23158) [ITK] update to v5.2.1 (by @Adela0814)
- qhull `8.0.2#2` -> `8.0.2#3`
    - [(microsoft#23129)](microsoft#23129) [qhull] Fix copyright, pc files, cmake usage (by @dg0yt)
- tgui `2021-04-19#2` -> `2021-04-19#3`
    - [(microsoft#23211)](microsoft#23211) [tgui] fix absolute paths (by @autoantwort)
- json-dto `0.3.0#0` -> `0.3.1#0`
    - [(microsoft#23224)](microsoft#23224) [json-dto] Update to 0.3.1 (by @eao197)
- leveldb `1.22#4` -> `1.22#5`
    - [(microsoft#23180)](microsoft#23180) [leveldb] Fix homepage (by @MarcoFalke)
- openxr-loader `1.0.22#0` -> `1.0.22#1`
    - [(microsoft#23191)](microsoft#23191) [openxr-loader] Fix build failure in world rebuild CI. (by @Hoikas)
- ngspice `35#1` -> `35#2`
    - [(microsoft#23151)](microsoft#23151) [ngspice] Fix error C2065 (by @Cheney-W)
- openmvg `2.0#1` -> `2.0#2`
    - [(microsoft#23114)](microsoft#23114) [cereal] Update to 1.3.1 (by @mapret)
- lazy-importer `2021-10-23#0` -> `2022-02-09#0`
    - [(microsoft#23192)](microsoft#23192) [lazy-importer] Update to 2022-02-09 (by @Thomas1664)
- gstreamer `1.19.2#3` -> `1.19.2#4`
    - [(microsoft#23125)](microsoft#23125) [gstreamer] Support arm-windows and add features (by @JackBoosY)
- charls `2.2.0#2` -> `2.3.4#0`
    - [(microsoft#23189)](microsoft#23189) [charls] Update to 2.3.4 (by @Thomas1664)
- arrow `7.0.0#0` -> `7.0.0#1`
    - [(microsoft#23188)](microsoft#23188) [arrow] add plasma support for non Windows platforms (by @fran6co)
- trantor `1.5.4#0` -> `1.5.5#0`
    - [(microsoft#23182)](microsoft#23182) [trantor] Update to 1.5.5 (by @an-tao)
- capstone `4.0.2#2` -> `4.0.2#3`
    - [(microsoft#23122)](microsoft#23122) [capstone] Use static runtime if capstone wants to be statically linked (by @illera88)
- gainput `1.0.0#4` -> `1.0.0#5`
    - [(microsoft#23219)](microsoft#23219) [gainput] Support Linux (by @JackBoosY)
- cereal `1.3.0#1` -> `1.3.1#0`
    - [(microsoft#23114)](microsoft#23114) [cereal] Update to 1.3.1 (by @mapret)

</details>
<details>
<summary>The following additional changes have been made to vcpkg's infrastructure:</summary>

- [(microsoft#23045)](microsoft#23045) [vcpkg docs] Update ko_KR translation (by @jnooree)
- [(microsoft#23181)](microsoft#23181) [vcpkg doc] Fixes typo in vcpkg_download_distfile.cmake (by @acd1034)

</details>
-- vcpkg team vcpkg@microsoft.com Thu, 24 February 00:29:57 -0800
  • Loading branch information
BillyONeal committed Feb 24, 2022
1 parent db26420 commit 9161eae
Showing 1 changed file with 65 additions and 30 deletions.
95 changes: 65 additions & 30 deletions scripts/Get-Changelog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,21 @@ Param (
[Parameter(Mandatory=$True, Position=0)]
[ValidateScript({$_ -le (Get-Date)})]
[DateTime]$StartDate,

# The end date range (exclusive)
[Parameter(Mandatory, Position=1)]
[ValidateScript({$_ -le (Get-Date)})]
[DateTime]$EndDate,

[Parameter(Mandatory=$True)]
[String]$OutFile,

# GitHub credentials (username and PAT)
[Parameter()]
[Credential()]
[PSCredential]$Credentials
)


Set-StrictMode -Version 2

if (-not $Credentials) {
Expand Down Expand Up @@ -82,6 +81,15 @@ function Get-MergedPullRequests {
[CmdletBinding()]
[OutputType([Object[]])]
Param(
[Parameter(Mandatory=$True, Position=0)]
[ValidateScript({$_ -le (Get-Date)})]
[DateTime]$StartDate,

# The end date range (exclusive)
[Parameter(Mandatory, Position=1)]
[ValidateScript({$_ -le (Get-Date)})]
[DateTime]$EndDate,

[Parameter(Mandatory=$True)]
[Credential()]
[PSCredential]$Credentials
Expand All @@ -98,7 +106,7 @@ function Get-MergedPullRequests {
page = 1
}
}
$Epoch = Get-Date
$Epoch = Get-Date -AsUTC
$DeltaEpochStart = ($Epoch - $StartDate).Ticks

$ProgressSplat = @{
Expand All @@ -119,7 +127,9 @@ function Get-MergedPullRequests {

foreach ($_ in $response) {
foreach ($x in 'created_at', 'merged_at', 'updated_at', 'closed_at') {
if ($_.$x) { $_.$x = [DateTime]::Parse($_.$x) }
if ($_.$x) { $_.$x = [DateTime]::Parse($_.$x,
[System.Globalization.CultureInfo]::InvariantCulture,
[System.Globalization.DateTimeStyles]::AdjustToUniversal -bor [System.Globalization.DateTimeStyles]::AssumeUniversal) }
}

if (-not $_.merged_at) { continue }
Expand Down Expand Up @@ -255,9 +265,11 @@ function Select-InfrastructurePullRequests {
[PRFileMap]$PRFileMap
)
Process {
switch -Wildcard ($PRFileMap.Files | Get-Member 'filename') {
switch -Wildcard ($PRFileMap.Files | Foreach-Object {$_.filename}) {
"docs/*" { continue }
"ports/*" { continue }
"versions/*" { continue }
"scripts/ci.baseline.txt" { continue }
Default { return $PRFileMap.Pull }
}
}
Expand Down Expand Up @@ -288,7 +300,7 @@ function Select-Version {
'(?<operation>^[\+|\-]|)(?<field>Version|[\+|\-]Port-Version):\s(?<version>\S+)'
}
'vcpkg.json' {
'(?<operation>^[\+|\-]|)\s*\"(?<field>version-string|port-version)\":\s\"(?<version>.+)\"'
'(?<operation>^[\+|\-]|)\s*(\"(?<field>version|version-date|version-string|version-semver)\":\s\"(?<version>.+)\"|\"(?<field>port-version)\":\s(?<version>.+))'
}
Default { return }
}
Expand Down Expand Up @@ -359,23 +371,23 @@ function Select-UpdatedPorts {
$versionFiles = $_.Value.VersionFiles
if (-not ($versionChange = $versionFiles | Select-Version)) { return }

function Find-File($x) { $versionFiles | Where-Object { $_.filename -like "*$x" } }
function Find-File($x) { [bool]($versionFiles | Where-Object { $_.filename -like "*$x" }) }
function Find-NewFile($x)
{ $versionFiles | Where-Object { $_.filename -like "*$x" -and $_.status -eq 'added' } }
{ [bool]($versionFiles | Where-Object { $_.filename -like "*$x" -and $_.status -eq 'added' }) }

[PortUpdate]@{
Port = $_.Key
Pulls = $_.Value.Pulls
Version = $versionChange
New = Find-NewFile 'CONTROL' -or (-not (Find-File 'CONTROL') -and (Find-NewFile 'vcpkg.json'))
New = (Find-NewFile 'CONTROL') -or (-not (Find-File 'CONTROL') -and (Find-NewFile 'vcpkg.json'))
}
}
}
}

$PRFileMaps = (Get-MergedPullRequests $Credentials) | Sort-Object -Property 'number' | Get-PullRequestFileMap -Credentials $Credentials

Write-Progress -Activity 'Selecting updates from pull request files' -PercentComplete -1
$MergedPRs = Get-MergedPullRequests -StartDate $StartDate -EndDate $EndDate -Credentials $Credentials
$MergedPRsSorted = $MergedPRs | Sort-Object -Property 'number'
$PRFileMaps = $MergedPRsSorted | Get-PullRequestFileMap -Credentials $Credentials

$sortSplat = @{ Property =
@{ Expression = 'New'; Descending = $True }, @{ Expression = 'Path'; Descending = $False } }
Expand All @@ -388,24 +400,28 @@ $ChangedPorts = $UpdatedPorts | Where-Object { -not $_.New }
Write-Progress -Activity 'Selecting updates from pull request files' -Completed

Write-Progress -Activity 'Writing changelog file' -PercentComplete -1
@"

$output = @"
vcpkg ($($StartDate.ToString('yyyy.MM.dd')) - $((($EndDate).AddSeconds(-1)).ToString('yyyy.MM.dd')))
---
#### Total port count:
#### Total port count per triplet (tested):
|triplet|ports available|
|---|---|
|**x64-windows**|NUM|
|x86-windows|NUM|
|**x64-windows**|NUM|
|x64-windows-static|NUM|
|**x64-osx**|NUM|
|**x64-linux**|NUM|
|arm64-windows|NUM|
|x64-windows-static-md|NUM|
|x64-uwp|NUM|
|arm64-windows|NUM|
|arm-uwp|NUM|
|**x64-osx**|NUM|
|**x64-linux**|NUM|
#### The following commands and options have been updated:
"@

if ($UpdatedDocumentation) {
$output += @"
#### The following documentation has been updated:
$(-join ($UpdatedDocumentation | ForEach-Object {
Expand All @@ -416,24 +432,19 @@ $(-join ($UpdatedDocumentation | ForEach-Object {
}
}))
#### The following *remarkable* changes have been made to vcpkg's infrastructure:
<details>
<summary>The following <i>additional</i> changes have been made to vcpkg's infrastructure:</summary>
$(-join ($UpdatedInfrastructure | ForEach-Object {
"- [(#{0})]({1}) {2} (by @{3})`n" -f $_.number, $_.html_url, $_.title, $_.user.login
}))
</details>
"@
}

if ($NewPorts) {
$output += @"
<details>
<summary><b>The following $($NewPorts.Length) ports have been added:</b></summary>
|port|version|
|---|---|
$(-join ($NewPorts | ForEach-Object {
"|[{0}]({1})" -f $_.Port, $_.Pulls[0].html_url
if ($_.Pulls.Length -gt 1 ) {
'<sup>'
$_.Pulls[1..($_.Pulls.Length - 1)] | ForEach-Object {
Expand All @@ -446,6 +457,11 @@ $(-join ($NewPorts | ForEach-Object {
}))
</details>
"@
}

if ($ChangedPorts) {
$output += @"
<details>
<summary><b>The following $($ChangedPorts.Length) ports have been updated:</b></summary>
Expand All @@ -460,7 +476,26 @@ $(-join ($ChangedPorts | ForEach-Object {
}))
</details>
"@
}

if ($UpdatedInfrastructure) {
$output += @"
<details>
<summary>The following additional changes have been made to vcpkg's infrastructure:</summary>
$(-join ($UpdatedInfrastructure | ForEach-Object {
"- [(#{0})]({1}) {2} (by @{3})`n" -f $_.number, $_.html_url, $_.title, $_.user.login
}))
</details>
"@
}

$output += @"
-- vcpkg team vcpkg@microsoft.com $(Get-Date -UFormat "%a, %d %B %T %Z00")
"@ | Out-File -FilePath $OutFile
"@

Set-Content -Value $Output -Path $OutFile

Write-Progress -Activity 'Writing changelog file' -Completed

0 comments on commit 9161eae

Please sign in to comment.