Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
*.png binary
*.dll binary
*.so binary

# Fixture seed files must keep the exact bytes of the fixture blobs.
fixtures/release-fixture/seed/** -text -whitespace
145 changes: 118 additions & 27 deletions .github/scripts/Invoke-ReleaseFixture.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
param(
# Resolve a producer SHA, start a fixture case, verify a merged fixture case, or run a baseline-first pair step.
[Parameter(Mandatory)]
[ValidateSet('Resolve', 'Start', 'Verify', 'StartLegacy', 'StartPairCandidate', 'ComparePair')]
[ValidateSet('Resolve', 'Start', 'Run', 'Verify', 'StartLegacy', 'StartPairCandidate', 'ComparePair', 'RunPair', 'RunLegacy')]
[string] $Mode,

# Producer pull request number in Resolve mode or fixture pull request number in Verify mode.
Expand All @@ -32,9 +32,15 @@ param(
[Parameter()]
[string] $Scenario,

# Resolved producer SHA in Start mode.
# Resolved producer SHA in Start, StartPairCandidate, and RunPair modes.
[Parameter()]
[string] $Candidate
[string] $Candidate,

# Exact head SHA of the open legacy fixture pull request to resume in RunPair and RunLegacy modes.
# Omit it in RunPair mode when the legacy pull request is already merged.
[Parameter()]
[AllowEmptyString()]
[string] $LegacyHead
)

$ErrorActionPreference = 'Stop'
Expand All @@ -45,6 +51,44 @@ if ($env:GITHUB_EVENT_NAME -cne 'workflow_dispatch' -or $env:GITHUB_REPOSITORY -
}
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'ReleaseFixture.psm1')

function Write-ReleaseFixturePairSummary {
<#
.SYNOPSIS
Write the pair evidence and comparison to the job summary. Fail after writing it if any comparison does not match.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[System.Collections.IDictionary] $Pair
)

$lines = @(
'Baseline-first pair comparison'
''
'| Lane | Pull request | Action pin | Squash | Parent | Tag | Run |'
'| --- | --- | --- | --- | --- | --- | --- |'
)
foreach ($lane in 'legacy', 'candidate') {
$item = $Pair[$lane]
$caseLink = "[#$($item.case.number)]($($item.case.url))"
$runLink = "[$($item.report.run)]($($item.report.run))"
$cells = @($lane, $caseLink, $item.case.candidate, $item.case.source, $item.case.parent, $item.release.tag, $runLink)
$lines += "| $($cells -join ' | ') |"
}
$lines += ''
$lines += '| Check | Value | Reference | Result |'
$lines += '| --- | --- | --- | --- |'
foreach ($row in $Pair.comparison.rows) {
$result = $row.match ? 'match' : 'MISMATCH'
$lines += "| $($row.check) | $($row.value) | $($row.reference) | $result |"
}
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value ($lines + '')
if (-not $Pair.comparison.match) {
throw 'The legacy and candidate evidence do not match. See the job summary for every compared value.'
}
Write-Information -MessageData 'The legacy and candidate evidence match.' -InformationAction Continue
}

switch ($Mode) {
'Resolve' {
$sha = Resolve-ReleaseFixtureCandidate -PullRequest $PullRequest
Expand All @@ -71,6 +115,27 @@ switch ($Mode) {
Add-ReleaseFixtureLabel -Case $case -Confirm:$false
$runType = 'Open pull request'
}
'Run' {
$caseId = "$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
if (-not $PSCmdlet.ShouldProcess("Fixture case $caseId", 'Run')) {
return
}
$progress = {
param($Line)
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @("- $Line")
Write-Information -MessageData $Line -InformationAction Continue
}
$run = Invoke-ReleaseFixtureRun -Scenario $Scenario -Candidate $Candidate -CaseId $caseId -Progress $progress -Confirm:$false
$summary = "Case: $($run.case.caseId) | Scenario: $($run.case.scenario) | Candidate: $($run.case.candidate)"
if ($null -ne $run.merged) {
$summary += " | Squash SHA: $($run.merged.source)"
if ($null -ne $run.pushReport.tag) {
$summary += " | Tag: $($run.pushReport.tag)"
}
}
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @('', $summary, '')
return
}
'StartLegacy' {
$caseId = "$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
if (-not $PSCmdlet.ShouldProcess("Legacy fixture case $caseId", 'Start')) {
Expand Down Expand Up @@ -107,33 +172,59 @@ switch ($Mode) {
Add-ReleaseFixtureLabel -Case $case -Confirm:$false
$runType = 'Open pull request'
}
'ComparePair' {
$pair = Get-ReleaseFixturePairEvidence -LegacyPullRequest $LegacyPullRequest -CandidatePullRequest $PullRequest
$lines = @(
'Baseline-first pair comparison'
''
'| Lane | Pull request | Action pin | Squash | Parent | Tag | Run |'
'| --- | --- | --- | --- | --- | --- | --- |'
)
foreach ($lane in 'legacy', 'candidate') {
$item = $pair[$lane]
$caseLink = "[#$($item.case.number)]($($item.case.url))"
$runLink = "[$($item.report.run)]($($item.report.run))"
$cells = @($lane, $caseLink, $item.case.candidate, $item.case.source, $item.case.parent, $item.release.tag, $runLink)
$lines += "| $($cells -join ' | ') |"
'RunPair' {
if (-not $PSCmdlet.ShouldProcess("Baseline-first pair for candidate $Candidate", 'Run')) {
return
}
# Two case IDs per attempt, so the legacy and candidate IDs never collide, even across attempts.
$attempt = [int] $env:GITHUB_RUN_ATTEMPT
$legacyCaseId = "$env:GITHUB_RUN_ID-$(2 * $attempt - 1)"
$candidateCaseId = "$env:GITHUB_RUN_ID-$(2 * $attempt)"
$progress = {
param($Line)
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @("- $Line")
Write-Information -MessageData $Line -InformationAction Continue
}
$parameters = @{
Candidate = $Candidate
LegacyCaseId = $legacyCaseId
CandidateCaseId = $candidateCaseId
LegacyPullRequest = $LegacyPullRequest
LegacyHead = $LegacyHead
Progress = $progress
}
$pair = Invoke-ReleaseFixturePair @parameters -Confirm:$false
Write-ReleaseFixturePairSummary -Pair $pair
return
}
'RunLegacy' {
if (-not $PSCmdlet.ShouldProcess('Legacy lane', 'Run')) {
return
}
$lines += ''
$lines += '| Check | Value | Reference | Result |'
$lines += '| --- | --- | --- | --- |'
foreach ($row in $pair.comparison.rows) {
$result = $row.match ? 'match' : 'MISMATCH'
$lines += "| $($row.check) | $($row.value) | $($row.reference) | $result |"
$attempt = [int] $env:GITHUB_RUN_ATTEMPT
$progress = {
param($Line)
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @("- $Line")
Write-Information -MessageData $Line -InformationAction Continue
}
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value ($lines + '')
if (-not $pair.comparison.match) {
throw 'The legacy and candidate evidence do not match. See the job summary for every compared value.'
$parameters = @{
CaseId = "$env:GITHUB_RUN_ID-$(2 * $attempt - 1)"
LegacyPullRequest = $LegacyPullRequest
LegacyHead = $LegacyHead
Progress = $progress
}
Write-Information -MessageData 'The legacy and candidate evidence match.' -InformationAction Continue
$legacy = Invoke-ReleaseFixtureLegacy @parameters -Confirm:$false
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @(
"Legacy baseline verified: [#$($legacy.case.number)]($($legacy.case.url)) | Squash: $($legacy.case.source) | Tag: $($legacy.report.tag)"
''
"To finish the pair, dispatch run-pair with candidate_pr and legacy_pr=$($legacy.case.number). The merge is not repeated."
''
)
return
}
'ComparePair' {
$pair = Get-ReleaseFixturePairEvidence -LegacyPullRequest $LegacyPullRequest -CandidatePullRequest $PullRequest
Write-ReleaseFixturePairSummary -Pair $pair
return
}
'Verify' {
Expand Down
Loading