Files
reims-vgpu/packaging/windows-runtime/scripts/test-plan-runtime-release.ps1
T
YXC0915 98f1677b5f 🆕 Select Alpha versions by suspend compatibility [ci skip]
Publish the version planner and compatibility manifest contract.
Wait for a new runtime baseline before building the next Alpha.
2026-12-02 03:22:02 +08:00

118 lines
5.6 KiB
PowerShell

[CmdletBinding()]
param([Parameter(Mandatory)][string]$TempRoot)
$ErrorActionPreference = 'Stop'
$root = (Resolve-Path -LiteralPath $TempRoot).Path
$fixture = Join-Path $root ("alpha-version-test-" + [guid]::NewGuid())
$planner = Join-Path $PSScriptRoot 'plan-runtime-release.ps1'
$source = Join-Path $fixture 'runtime'
$packaging = Join-Path $fixture 'packaging'
$fixtureReleases = [System.Collections.Generic.List[hashtable]]::new()
$testRepo = 'test/runtime'
function gh {
$global:LASTEXITCODE = 0
'[' + (ConvertTo-Json -InputObject $fixtureReleases.ToArray() -Depth 5 -Compress) + ']'
}
function Test-Git([string]$repo, [string[]]$argv) {
$result = & git -C $repo @argv
if ($LASTEXITCODE) { throw "git $($argv -join ' ') failed in fixture" }
return $result
}
function Write-Commit([string]$repo, [string]$path, [string]$content, [string]$message = 'Fixture update') {
$file = Join-Path $repo $path
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $file) | Out-Null
Set-Content -LiteralPath $file -Encoding utf8NoBOM -Value $content
Test-Git $repo @('add', '--', $path) | Out-Null
Test-Git $repo @('commit', '-q', '-m', $message) | Out-Null
return Test-Git $repo @('rev-parse', 'HEAD')
}
function Add-Published([string]$id, [string]$commit, [string]$pack, [string]$family) {
$tag = "runtime-$id"
Test-Git $source @('tag', $tag, $commit) | Out-Null
$fixtureReleases.Add(@{
tag_name = $tag
draft = $false
published_at = [DateTimeOffset]::UnixEpoch.AddMinutes($fixtureReleases.Count).ToString('o')
body = "Packaging commit: ``$pack```nSuspend compatibility ID: ``$family``"
})
}
function Approval([string]$predecessor, [string]$other) {
return "Fixture verified`n`nSuspend-Compatible-With: $predecessor`nSuspend-Verified-Inputs: $other`nSuspend-Verification: https://example.invalid/runtime-test"
}
function Plan([string]$commit, [string]$pack, [switch]$PackagingPush) {
& $planner -RuntimeRepo $source -RuntimeCommit $commit -PackagingRepo $packaging -PackagingCommit $pack `
-Repository $testRepo -Rebuild:$PackagingPush -PackagingPush:$PackagingPush
}
function Assert-Version($plan, [string]$id, [string]$family) {
if ($plan.Skip -or $plan.ReleaseId -ne $id -or $plan.SuspendCompatID -ne $family) {
throw "Expected $id in family $family, got $($plan | ConvertTo-Json -Compress)"
}
}
try {
foreach ($repo in $source, $packaging) {
New-Item -ItemType Directory -Path $repo -Force | Out-Null
Test-Git $repo @('init', '-q') | Out-Null
Test-Git $repo @('config', 'user.name', 'Version Fixture') | Out-Null
Test-Git $repo @('config', 'user.email', 'fixture@example.invalid') | Out-Null
}
Test-Git $source @('remote', 'add', 'origin', $source) | Out-Null
$old = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'original state path'
$pack = Write-Commit $packaging 'packaging/windows-runtime/patches/series.txt' 'original patch queue'
$base = Test-Git $source @('rev-parse', '--short=7', $old)
Assert-Version (Plan $old $pack) $base $base
Add-Published $base $old $pack $base
if (!(Plan $old $pack).Skip -or !(Plan $old $pack -PackagingPush).Skip) {
throw 'Already published build was not skipped'
}
$compatiblePack = Write-Commit $packaging 'packaging/windows-runtime/notice.txt' 'packaging adjustment' (Approval "runtime-$base" $old)
Assert-Version (Plan $old $compatiblePack -PackagingPush) "$base-p1" $base
$breakingPack = Write-Commit $packaging 'packaging/windows-runtime/patches/series.txt' 'changed snapshot patch queue' (Approval "runtime-$base" $old)
try {
$null = Plan $old $breakingPack -PackagingPush
throw 'Incompatible packaging change reused the old runtime commit'
} catch {
if ($_ -notmatch 'A new runtime baseline commit is required') { throw }
}
$compatible = Write-Commit $source 'docs/build.md' 'safe runtime change' (Approval "runtime-$base" $pack)
Assert-Version (Plan $compatible $pack) "$base-p1" $base
Add-Published "$base-p1" $compatible $pack $base
if (!(Plan $compatible $pack).Skip) {
throw 'A published revision with a different source prefix rebuilt'
}
$next = Write-Commit $source 'docs/build.md' 'another verified change' (Approval "runtime-$base-p1" $pack)
Assert-Version (Plan $next $pack) "$base-p2" $base
$breaking = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'different state path' (Approval "runtime-$base-p1" $pack)
$breakingBase = Test-Git $source @('rev-parse', '--short=7', $breaking)
Assert-Version (Plan $breaking $pack) $breakingBase $breakingBase
Add-Published $breakingBase $breaking $pack $breakingBase
$reverted = Write-Commit $source 'crates/reims-ctl/src/qemu.rs' 'original state path' (Approval "runtime-$base-p1" $pack)
$revertedBase = Test-Git $source @('rev-parse', '--short=7', $reverted)
Assert-Version (Plan $reverted $pack) $revertedBase $revertedBase
$unverified = Write-Commit $source 'docs/build.md' 'unverified change'
$unverifiedBase = Test-Git $source @('rev-parse', '--short=7', $unverified)
Assert-Version (Plan $unverified $pack) $unverifiedBase $unverifiedBase
Write-Host 'PASS Alpha family selection, exact-source deduplication, and suspend input guards'
} finally {
if (Test-Path -LiteralPath $fixture) {
$resolved = (Resolve-Path -LiteralPath $fixture).Path
if ($resolved -ne $fixture -or (Split-Path -Parent $resolved) -ne $root) {
throw "Unexpected test fixture path: $resolved"
}
Remove-Item -LiteralPath $resolved -Recurse -Force
}
}