fix: run project scenarios in quality gate
This commit is contained in:
+44
-15
@@ -13,6 +13,7 @@ New-Item -ItemType Directory -Path $LOG -Force | Out-Null
|
||||
$OVERALL = $false
|
||||
$ERRORS = @()
|
||||
$FIXES = @()
|
||||
$OWNED_GDSCRIPT_ROOTS = @("player", "simulation", "tests", "tools", "world")
|
||||
|
||||
# -- tool detection -----------------------------------------------------------
|
||||
function Find-Godot {
|
||||
@@ -26,6 +27,10 @@ function Find-Godot {
|
||||
"$env:USERPROFILE\AppData\Local\Godot\godot.exe"
|
||||
)
|
||||
foreach ($p in $common) { if (Test-Path $p) { return $p } }
|
||||
$bundled = Get-ChildItem "${env:ProgramFiles(x86)}\Godot" -Filter "Godot*_console.exe" -ErrorAction SilentlyContinue |
|
||||
Sort-Object Name -Descending |
|
||||
Select-Object -First 1
|
||||
if ($bundled) { return $bundled.FullName }
|
||||
return $null
|
||||
}
|
||||
|
||||
@@ -86,24 +91,27 @@ function To-ResPath($p) {
|
||||
}
|
||||
|
||||
function Invoke-GodotWithTimeout {
|
||||
param([string]$Args)
|
||||
param([string]$ArgumentString)
|
||||
$psi = New-Object Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $GODOT
|
||||
$psi.Arguments = $Args
|
||||
$psi.Arguments = $ArgumentString
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
$p = [Diagnostics.Process]::Start($psi)
|
||||
$outputTask = $p.StandardOutput.ReadToEndAsync()
|
||||
$errorTask = $p.StandardError.ReadToEndAsync()
|
||||
$exited = $p.WaitForExit(30000)
|
||||
if (-not $exited) {
|
||||
$p.Kill()
|
||||
$output = $p.StandardOutput.ReadToEnd()
|
||||
$err = $p.StandardError.ReadToEnd()
|
||||
$p.WaitForExit()
|
||||
$output = $outputTask.Result
|
||||
$err = $errorTask.Result
|
||||
return $output + $err, $null
|
||||
}
|
||||
$output = $p.StandardOutput.ReadToEnd()
|
||||
$err = $p.StandardError.ReadToEnd()
|
||||
$output = $outputTask.Result
|
||||
$err = $errorTask.Result
|
||||
return ($output + $err), $p.ExitCode
|
||||
}
|
||||
|
||||
@@ -139,7 +147,8 @@ if (-not $fmtAvail) {
|
||||
Add-Content -Path "$LOG/gdformat.log" -Value $msg -Encoding utf8
|
||||
}
|
||||
} else {
|
||||
$out = Invoke-GdFormat "--check" "."
|
||||
$formatArgs = @("--check") + $OWNED_GDSCRIPT_ROOTS
|
||||
$out = Invoke-GdFormat @formatArgs
|
||||
$out | Add-Content -Path "$LOG/gdformat.log" -Encoding utf8
|
||||
}
|
||||
}
|
||||
@@ -175,7 +184,7 @@ if (-not $lintAvail) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$out = Invoke-GdLint "."
|
||||
$out = Invoke-GdLint @OWNED_GDSCRIPT_ROOTS
|
||||
$out | Add-Content -Path "$LOG/gdlint.log" -Encoding utf8
|
||||
}
|
||||
}
|
||||
@@ -201,12 +210,12 @@ if ($lintLines) {
|
||||
# -- 3. godot headless check --------------------------------------------------
|
||||
$godotResult = "PASS"
|
||||
Set-Content -Path "$LOG/godot-check.log" -Value "" -Encoding utf8
|
||||
$godotArgs = "--headless --path `"$ROOT`" --quit"
|
||||
$godotOutput, $godotExit = Invoke-GodotWithTimeout -Args $godotArgs
|
||||
$godotArgs = "--headless --path `"$ROOT`" --script res://tests/simulation_definitions_test.gd"
|
||||
$godotOutput, $godotExit = Invoke-GodotWithTimeout -ArgumentString $godotArgs
|
||||
$godotOutput | Out-File -FilePath "$LOG/godot-check.log" -Encoding utf8
|
||||
if ($godotExit -eq $null) {
|
||||
$godotResult = "PASS"
|
||||
Add-Content -Path "$LOG/godot-check.log" -Value "[timed out after 30s - project runs continuously]" -Encoding utf8
|
||||
$godotResult = "FAIL"
|
||||
Add-Content -Path "$LOG/godot-check.log" -Value "[timed out after 30s]" -Encoding utf8
|
||||
} elseif ($godotExit -eq 0) {
|
||||
$godotResult = "PASS"
|
||||
} else {
|
||||
@@ -217,12 +226,30 @@ if ($godotExit -eq $null) {
|
||||
$FIXES += "Fix Godot parser errors"
|
||||
}
|
||||
|
||||
# -- 4. GUT (optional) --------------------------------------------------------
|
||||
# -- 4. project scenario tests ------------------------------------------------
|
||||
$scenarioResult = "PASS"
|
||||
Set-Content -Path "$LOG/scenarios.log" -Value "" -Encoding utf8
|
||||
$scenarioTests = Get-ChildItem "tests" -Filter "*_test.gd" | Sort-Object Name
|
||||
foreach ($test in $scenarioTests) {
|
||||
Add-Content -Path "$LOG/scenarios.log" -Value "[RUN] $($test.Name)" -Encoding utf8
|
||||
$testArgs = "--headless --path `"$ROOT`" --script res://tests/$($test.Name)"
|
||||
$testOutput, $testExit = Invoke-GodotWithTimeout -ArgumentString $testArgs
|
||||
$testOutput | Add-Content -Path "$LOG/scenarios.log" -Encoding utf8
|
||||
if ($testExit -eq $null -or $testExit -ne 0) {
|
||||
$scenarioResult = "FAIL"
|
||||
$ERRORS += "scenario: $($test.Name) failed or timed out"
|
||||
}
|
||||
}
|
||||
if ($scenarioResult -eq "FAIL") {
|
||||
$FIXES += "Fix failing project scenario tests"
|
||||
}
|
||||
|
||||
# -- 5. GUT (optional) --------------------------------------------------------
|
||||
$gutResult = "SKIPPED"
|
||||
Set-Content -Path "$LOG/gut.log" -Value "" -Encoding utf8
|
||||
if (Test-Path "addons/gut/gut_cmdln.gd") {
|
||||
$gutArgs = "--headless --path `"$ROOT`" -s addons/gut/gut_cmdln.gd --quit"
|
||||
$gutOutput, $gutExit = Invoke-GodotWithTimeout -Args $gutArgs
|
||||
$gutOutput, $gutExit = Invoke-GodotWithTimeout -ArgumentString $gutArgs
|
||||
$gutOutput | Out-File -FilePath "$LOG/gut.log" -Encoding utf8
|
||||
if ($gutExit -eq $null) {
|
||||
$gutResult = "FAIL"
|
||||
@@ -241,7 +268,7 @@ if (Test-Path "addons/gut/gut_cmdln.gd") {
|
||||
}
|
||||
|
||||
# -- summary ------------------------------------------------------------------
|
||||
if ($fmtResult -eq 'FAIL' -or $lintResult -eq 'FAIL' -or $godotResult -eq 'FAIL' -or $gutResult -eq 'FAIL') {
|
||||
if ($fmtResult -eq 'FAIL' -or $lintResult -eq 'FAIL' -or $godotResult -eq 'FAIL' -or $scenarioResult -eq 'FAIL' -or $gutResult -eq 'FAIL') {
|
||||
$OVERALL = $true
|
||||
}
|
||||
|
||||
@@ -251,6 +278,7 @@ Write-Host ""
|
||||
Write-Host " gdformat $fmtResult"
|
||||
Write-Host " gdlint $lintResult"
|
||||
Write-Host " godot-check $godotResult"
|
||||
Write-Host " scenarios $scenarioResult"
|
||||
Write-Host " gut $gutResult"
|
||||
|
||||
$seen = @{}
|
||||
@@ -286,6 +314,7 @@ QUALITY RESULT: $resultText
|
||||
gdformat $fmtResult
|
||||
gdlint $lintResult
|
||||
godot-check $godotResult
|
||||
scenarios $scenarioResult
|
||||
gut $gutResult
|
||||
"@
|
||||
Set-Content -Path "$LOG/summary.txt" -Value $summary -Encoding utf8
|
||||
|
||||
Reference in New Issue
Block a user