RC production acceptance / MySQL, permission, browser and package acceptance (push) Failing after 2m10s
139 lines
4.8 KiB
PowerShell
139 lines
4.8 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$MySqlConnectionString,
|
|
[switch]$SkipBrowser,
|
|
[string]$OutputDirectory = '.artifacts/rc-acceptance'
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$repositoryRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
|
$reportRoot = if ([System.IO.Path]::IsPathRooted($OutputDirectory)) {
|
|
[System.IO.Path]::GetFullPath($OutputDirectory)
|
|
} else {
|
|
[System.IO.Path]::GetFullPath((Join-Path $repositoryRoot $OutputDirectory))
|
|
}
|
|
$results = [System.Collections.Generic.List[object]]::new()
|
|
|
|
function Add-Result {
|
|
param([string]$Name, [string]$Status, [string]$Detail)
|
|
$results.Add([pscustomobject]@{
|
|
Name = $Name
|
|
Status = $Status
|
|
Detail = $Detail
|
|
})
|
|
}
|
|
|
|
function Invoke-Check {
|
|
param([string]$Name, [scriptblock]$Action)
|
|
Write-Host "`n==> $Name"
|
|
try {
|
|
& $Action
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Command exited with code $LASTEXITCODE."
|
|
}
|
|
Add-Result $Name 'PASS' 'completed'
|
|
} catch {
|
|
Add-Result $Name 'FAIL' $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
New-Item -ItemType Directory -Path $reportRoot -Force | Out-Null
|
|
Push-Location $repositoryRoot
|
|
$previousMySql = $env:JIAOWU_TEST_MYSQL
|
|
$previousRequired = $env:JIAOWU_REQUIRE_MYSQL_TESTS
|
|
try {
|
|
Invoke-Check 'Restore .NET dependencies' {
|
|
& dotnet restore 'Jiaowu.slnx'
|
|
}
|
|
Invoke-Check 'Build backend (Release)' {
|
|
& dotnet build 'Jiaowu.slnx' '--configuration' 'Release' '--no-restore'
|
|
}
|
|
Invoke-Check 'Run backend regression tests' {
|
|
& dotnet test 'Jiaowu.slnx' '--configuration' 'Release' '--no-build' '--no-restore'
|
|
}
|
|
|
|
if ([string]::IsNullOrWhiteSpace($MySqlConnectionString)) {
|
|
Add-Result 'Run disposable MySQL 8.4 acceptance' 'SKIP' 'Pass -MySqlConnectionString to execute the live migration/query test.'
|
|
} else {
|
|
$env:JIAOWU_TEST_MYSQL = $MySqlConnectionString
|
|
$env:JIAOWU_REQUIRE_MYSQL_TESTS = '1'
|
|
Invoke-Check 'Run disposable MySQL 8.4 acceptance' {
|
|
& dotnet test 'tests/Jiaowu.Api.Tests/Jiaowu.Api.Tests.csproj' '--configuration' 'Release' '--no-build' '--no-restore' '--filter' 'Category=LiveMySql'
|
|
}
|
|
}
|
|
|
|
Push-Location (Join-Path $repositoryRoot 'web')
|
|
try {
|
|
Invoke-Check 'Install locked frontend dependencies' {
|
|
& npm ci '--ignore-scripts'
|
|
}
|
|
Invoke-Check 'Audit frontend dependencies' {
|
|
& npm audit '--audit-level=moderate'
|
|
}
|
|
Invoke-Check 'Build web frontend' {
|
|
& npm run build
|
|
}
|
|
Invoke-Check 'Build Capacitor frontend' {
|
|
& npm run 'build:capacitor'
|
|
}
|
|
if ($SkipBrowser) {
|
|
Add-Result 'Run Chromium smoke tests' 'SKIP' 'Skipped by -SkipBrowser.'
|
|
} else {
|
|
Invoke-Check 'Install Playwright Chromium' {
|
|
& npx playwright install chromium
|
|
}
|
|
Invoke-Check 'Run Chromium smoke tests' {
|
|
& npm run 'test:e2e'
|
|
}
|
|
}
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|
|
Invoke-Check 'List production MySQL migrations' {
|
|
& dotnet ef migrations list '--project' 'src/Jiaowu.Api/Jiaowu.Api.csproj' '--startup-project' 'src/Jiaowu.Api/Jiaowu.Api.csproj' '--no-connect'
|
|
}
|
|
Invoke-Check 'Publish backend artifact' {
|
|
& dotnet publish 'src/Jiaowu.Api/Jiaowu.Api.csproj' '--configuration' 'Release' '--no-restore' '--output' (Join-Path $reportRoot 'publish') '-p:BuildFrontendOnPublish=false'
|
|
}
|
|
Invoke-Check 'Check whitespace errors' {
|
|
& git diff '--check'
|
|
}
|
|
} finally {
|
|
$env:JIAOWU_TEST_MYSQL = $previousMySql
|
|
$env:JIAOWU_REQUIRE_MYSQL_TESTS = $previousRequired
|
|
Pop-Location
|
|
}
|
|
|
|
$failed = @($results | Where-Object Status -eq 'FAIL').Count
|
|
$skipped = @($results | Where-Object Status -eq 'SKIP').Count
|
|
$overall = if ($failed -gt 0) { 'FAIL' } elseif ($skipped -gt 0) { 'PARTIAL' } else { 'PASS' }
|
|
$timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss K'
|
|
$rows = $results | ForEach-Object {
|
|
$detail = $_.Detail.Replace('|', '\|').Replace("`r", ' ').Replace("`n", ' ')
|
|
"| $($_.Name) | $($_.Status) | $detail |"
|
|
}
|
|
$markdown = @(
|
|
'# Jiaowu RC acceptance report'
|
|
''
|
|
"- Result: **$overall**"
|
|
"- Generated: $timestamp"
|
|
"- Commit: $(& git -C $repositoryRoot rev-parse HEAD)"
|
|
''
|
|
'| Check | Status | Detail |'
|
|
'|---|---|---|'
|
|
$rows
|
|
) -join "`n"
|
|
|
|
$markdown | Set-Content -LiteralPath (Join-Path $reportRoot 'report.md') -Encoding utf8
|
|
[pscustomobject]@{
|
|
Result = $overall
|
|
GeneratedAt = $timestamp
|
|
Commit = (& git -C $repositoryRoot rev-parse HEAD)
|
|
Checks = $results
|
|
} | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $reportRoot 'report.json') -Encoding utf8
|
|
|
|
Write-Host "`nRC acceptance result: $overall"
|
|
Write-Host "Report: $(Join-Path $reportRoot 'report.md')"
|
|
if ($failed -gt 0) { exit 1 }
|