Files
story/scripts/smoke-safari-conformance-toolchain.ps1
T

39 lines
2.9 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$root = Split-Path -Parent $PSScriptRoot
Set-Location -LiteralPath $root
$temporaryRoot = Join-Path ([System.IO.Path]::GetTempPath()) ('safari-conformance-toolchain-' + [Guid]::NewGuid().ToString('N'))
$capturePath = Join-Path $temporaryRoot 'capture.json'
$reportPath = Join-Path $temporaryRoot 'report.json'
try {
New-Item -ItemType Directory -Path $temporaryRoot | Out-Null
$imageDigest = (docker image inspect data-terminal-cloud-api --format '{{.Id}}').Trim()
if ($imageDigest -notmatch '^sha256:[a-f0-9]{64}$') { throw '无法取得API镜像摘要' }
$startedAt = (Get-Date).ToUniversalTime().AddMinutes(-2)
$endedAt = $startedAt.AddMinutes(1)
$workflows = @('AUTH_SESSION','FAMILY_WORKSPACE','OPERATIONS_WORKSPACES','REALTIME_NAVIGATION','MEDIA_FILE_CONTROLS','CONTROLLED_ACTIONS')
$viewports = @('DESKTOP_1440X1000','TABLET_1024X900')
$results = @()
foreach ($workflow in $workflows) {
foreach ($viewport in $viewports) {
$results += @{ workflow = $workflow; viewport = $viewport; status = 'PASS'; console_error_count = 0; unexpected_failed_request_count = 0; horizontal_overflow_count = 0; evidence_ref = "local-schema-smoke:${workflow}:${viewport}" }
}
}
$capture = @{
schema_version = 'safari-compatibility-capture-v1'; evidence_source = 'NON_SAFARI_TOOLCHAIN'; candidate_version = '0.63.0-rc.local'; build_digest = $imageDigest
environment = 'LOCAL'; release_reference_ref = 'not-applicable-local'; change_ticket_ref = 'local-smoke'; executed_by_ref = 'local-toolchain'; attested_by_ref = 'local-toolchain'
attested_at = $endedAt.ToString('o'); collected_at = (Get-Date).ToUniversalTime().ToString('o')
runs = @(@{ release_rank = 'CURRENT'; browser_name = 'NON_SAFARI'; browser_version = 'local-toolchain'; macos_version = 'not-applicable'; machine_ref = 'local-windows'; execution_mode = 'SCHEMA_SMOKE'; started_at = $startedAt.ToString('o'); ended_at = $endedAt.ToString('o'); results = $results })
}
[System.IO.File]::WriteAllText($capturePath, ($capture | ConvertTo-Json -Depth 12), [System.Text.UTF8Encoding]::new($false))
go run ./cmd/safari-conformance -capture $capturePath -candidate-version '0.63.0-rc.local' -build-digest $imageDigest -output $reportPath
$report = Get-Content -Raw -LiteralPath $reportPath | ConvertFrom-Json
if ($report.result -ne 'PASS' -or $report.evidence_scope -ne 'NON_SAFARI_TOOLCHAIN' -or -not $report.external_validation_required -or $report.result_count -ne 12) { throw '非Safari工具链报告边界不正确' }
Write-Host 'Safari证据工具链冒烟通过:结构化12项本地结果;报告固定为NON_SAFARI_TOOLCHAIN,真实Safari门禁继续待验。'
} finally {
if (Test-Path -LiteralPath $temporaryRoot) { Remove-Item -LiteralPath $temporaryRoot -Recurse -Force }
Write-Host '已清理Safari工具链冒烟临时文件。'
}