Repository navigation
Fix close-window shutdown #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Native Parroty window close | |
| on: | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| native-window-close: | |
| runs-on: windows-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Parse PowerShell launcher | |
| shell: pwsh | |
| run: | | |
| $tokens = $null | |
| $errors = $null | |
| [void][System.Management.Automation.Language.Parser]::ParseFile( | |
| (Resolve-Path "parroty_window.ps1"), | |
| [ref]$tokens, | |
| [ref]$errors | |
| ) | |
| if ($errors.Count -gt 0) { | |
| $errors | Format-List | Out-String | Write-Error | |
| exit 1 | |
| } | |
| - name: Verify native window close while host remains alive | |
| id: native_test | |
| continue-on-error: true | |
| shell: pwsh | |
| run: | | |
| & .github/native_window_close_test.ps1 *> native-window-diagnostics.txt | |
| $exitCode = $LASTEXITCODE | |
| Get-Content native-window-diagnostics.txt | |
| if ($exitCode -ne 0) { exit $exitCode } | |
| - name: Upload native-window diagnostics | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-window-diagnostics | |
| path: native-window-diagnostics.txt | |
| if-no-files-found: warn | |
| - name: Enforce native-window test | |
| if: steps.native_test.outcome != 'success' | |
| shell: pwsh | |
| run: exit 1 | |
| - name: Verify recorded backend PID is stopped | |
| shell: pwsh | |
| run: | | |
| $tokens = $null | |
| $errors = $null | |
| $ast = [System.Management.Automation.Language.Parser]::ParseFile( | |
| (Resolve-Path "parroty_window.ps1"), | |
| [ref]$tokens, | |
| [ref]$errors | |
| ) | |
| $functions = $ast.FindAll({ | |
| param($node) | |
| $node -is [System.Management.Automation.Language.FunctionDefinitionAst] | |
| }, $true) | |
| foreach ($function in $functions) { Invoke-Expression $function.Extent.Text } | |
| $listener = Start-Process python -ArgumentList @( | |
| "-m", "http.server", "5000", "--bind", "127.0.0.1" | |
| ) -PassThru -WindowStyle Hidden | |
| try { | |
| $captured = @() | |
| for ($i = 0; $i -lt 40; $i++) { | |
| Start-Sleep -Milliseconds 250 | |
| $captured = @(Get-ParrotyBackendPids -ListenerPort 5000) | |
| if ($captured -contains $listener.Id) { break } | |
| } | |
| if ($captured -notcontains $listener.Id) { throw "Listener PID was not captured" } | |
| Stop-ParrotyBackend -ProcessIds $captured | |
| Start-Sleep -Milliseconds 500 | |
| if (Get-Process -Id $listener.Id -ErrorAction SilentlyContinue) { | |
| throw "Recorded backend PID remained alive" | |
| } | |
| } | |
| finally { | |
| Stop-Process -Id $listener.Id -Force -ErrorAction SilentlyContinue | |
| } | |
| - name: Enforce BAT exclusion | |
| shell: pwsh | |
| run: | | |
| $trackedBat = @(git ls-files "*.bat") | |
| if ($trackedBat.Count -gt 0) { | |
| throw "Tracked BAT files found: $($trackedBat -join ', ')" | |
| } |