92 lines
3.1 KiB
PowerShell
92 lines
3.1 KiB
PowerShell
param(
|
|
[switch]$SkipBackend,
|
|
[switch]$SkipE2E
|
|
)
|
|
|
|
$ErrorActionPreference = 'Continue'
|
|
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
|
$failures = [System.Collections.Generic.List[string]]::new()
|
|
|
|
function Invoke-Gate {
|
|
param(
|
|
[string]$Name,
|
|
[scriptblock]$Action
|
|
)
|
|
|
|
Write-Host "`n[$Name]" -ForegroundColor Cyan
|
|
$gateExit = 0
|
|
try {
|
|
& $Action
|
|
if ($LASTEXITCODE -ne 0) { $gateExit = $LASTEXITCODE }
|
|
} catch {
|
|
Write-Error $_
|
|
$gateExit = 127
|
|
}
|
|
if ($gateExit -ne 0) {
|
|
$failures.Add("$Name (exit $gateExit)")
|
|
}
|
|
}
|
|
|
|
Write-Host 'Shanyuan Danyang V1.1 - Phase 01 baseline verification' -ForegroundColor Green
|
|
Write-Host "Project root: $projectRoot"
|
|
|
|
Invoke-Gate 'Git repository' {
|
|
git -C $projectRoot status --short --branch
|
|
}
|
|
|
|
if (-not $SkipBackend) {
|
|
Invoke-Gate 'Backend unit tests' {
|
|
$java = Get-Command java -ErrorAction SilentlyContinue
|
|
$maven = Get-Command mvn -ErrorAction SilentlyContinue
|
|
if ($java -and $maven) {
|
|
$mavenRepo = Join-Path $projectRoot 'backend/local-maven'
|
|
& $maven.Source -s (Join-Path $projectRoot 'backend/maven-settings.xml') `
|
|
"-Dmaven.repo.local=$mavenRepo" `
|
|
-f (Join-Path $projectRoot 'backend/pom.xml') test
|
|
} elseif (Get-Command docker -ErrorAction SilentlyContinue) {
|
|
$mount = "${projectRoot}:/workspace"
|
|
$containerCommand = 'rm -rf /tmp/maven && mkdir -p /tmp/maven && cd /tmp/maven && jar xf /workspace/backend/maven.zip && chmod +x /tmp/maven/apache-maven-3.9.6/bin/mvn && /tmp/maven/apache-maven-3.9.6/bin/mvn -s /workspace/backend/maven-settings.xml -Dmaven.repo.local=/workspace/backend/local-maven -f /workspace/backend/pom.xml test'
|
|
docker run --rm -v $mount -w /workspace/backend eclipse-temurin:21-jdk-alpine `
|
|
sh -c $containerCommand
|
|
} else {
|
|
throw 'JDK 21 and Maven were not found, and Docker is unavailable.'
|
|
}
|
|
}
|
|
}
|
|
|
|
Invoke-Gate 'Admin type-check' {
|
|
Push-Location (Join-Path $projectRoot 'admin-web')
|
|
try { npm run type-check } finally { Pop-Location }
|
|
}
|
|
|
|
Invoke-Gate 'Admin production build' {
|
|
Push-Location (Join-Path $projectRoot 'admin-web')
|
|
try { npm run build } finally { Pop-Location }
|
|
}
|
|
|
|
Invoke-Gate 'Miniapp TypeScript' {
|
|
$tsc = Join-Path $projectRoot 'admin-web/node_modules/.bin/tsc.cmd'
|
|
if (-not (Test-Path -LiteralPath $tsc)) {
|
|
throw 'TypeScript compiler is missing. Run npm ci in admin-web first.'
|
|
} else {
|
|
& $tsc -p (Join-Path $projectRoot 'miniapp/tsconfig.json') --noEmit
|
|
}
|
|
}
|
|
|
|
if (-not $SkipE2E) {
|
|
Invoke-Gate 'V1.1 E2E collection and execution' {
|
|
Push-Location $projectRoot
|
|
try { python -m pytest tests/e2e -q } finally { Pop-Location }
|
|
}
|
|
}
|
|
|
|
Write-Host "`n[Summary]" -ForegroundColor Cyan
|
|
if ($failures.Count -eq 0) {
|
|
Write-Host 'All Phase 01 baseline gates passed.' -ForegroundColor Green
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "Failed gates: $($failures.Count)" -ForegroundColor Red
|
|
$failures | ForEach-Object { Write-Host "- $_" -ForegroundColor Red }
|
|
exit 1
|