Skip to content
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
75 changes: 73 additions & 2 deletions .github/scripts/Invoke-ReleaseFixture.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@
#>
[CmdletBinding(SupportsShouldProcess)]
param(
# Resolve a producer SHA, start a fixture case, or verify a merged fixture case.
# 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')]
[ValidateSet('Resolve', 'Start', 'Verify', 'StartLegacy', 'StartPairCandidate', 'ComparePair')]
[string] $Mode,

# Producer pull request number in Resolve mode or fixture pull request number in Verify mode.
# The candidate fixture pull request number in ComparePair mode.
[Parameter()]
[AllowEmptyString()]
[string] $PullRequest,

# Merged legacy fixture pull request number in StartPairCandidate and ComparePair modes.
[Parameter()]
[AllowEmptyString()]
[string] $LegacyPullRequest,

# Scenario name in Start mode.
[Parameter()]
[string] $Scenario,
Expand Down Expand Up @@ -65,6 +71,71 @@ switch ($Mode) {
Add-ReleaseFixtureLabel -Case $case -Confirm:$false
$runType = 'Open pull request'
}
'StartLegacy' {
$caseId = "$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
if (-not $PSCmdlet.ShouldProcess("Legacy fixture case $caseId", 'Start')) {
return
}
$case = Start-ReleaseFixtureLegacyCase -CaseId $caseId -Confirm:$false
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @(
"Legacy fixture pull request: [#$($case.number)]($($case.url))"
''
"Case: $($case.caseId) | Action pin: $($case.candidate) | Head: $($case.head)"
''
)
Write-Information -MessageData "Opened $($case.url)" -InformationAction Continue
Add-ReleaseFixtureLabel -Case $case -Confirm:$false
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @(
'Approve and squash merge this pull request through the normal process. Then dispatch the candidate step.'
''
)
return
}
'StartPairCandidate' {
if (-not $PSCmdlet.ShouldProcess("Paired candidate case for legacy pull request #$LegacyPullRequest", 'Start')) {
return
}
$caseId = "$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT"
$case = Start-ReleaseFixturePairCandidate -LegacyPullRequest $LegacyPullRequest -Candidate $Candidate -CaseId $caseId -Confirm:$false
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @(
"Candidate fixture pull request: [#$($case.number)]($($case.url))"
''
"Case: $($case.caseId) (after legacy pull request #$LegacyPullRequest) | Action pin: $($case.candidate) | Head: $($case.head)"
''
)
Write-Information -MessageData "Opened $($case.url)" -InformationAction Continue
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 ' | ') |"
}
$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
return
}
'Verify' {
$case = Get-MergedReleaseFixtureCase -PullRequest $PullRequest
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Value @(
Expand Down
Loading
Loading