|
| 1 | +name: macOS Terminal E2E Test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger only |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-macos-terminal: |
| 11 | + runs-on: macos-14 |
| 12 | + timeout-minutes: 10 |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Setup .NET |
| 18 | + uses: actions/setup-dotnet@v4 |
| 19 | + with: |
| 20 | + dotnet-version: | |
| 21 | + 8.0.x |
| 22 | + 9.0.x |
| 23 | +
|
| 24 | + - name: Install PowerShell |
| 25 | + run: brew install powershell/tap/powershell |
| 26 | + |
| 27 | + - name: Build and setup module |
| 28 | + run: | |
| 29 | + dotnet build PowerShell.MCP -c Release --no-incremental |
| 30 | + dotnet publish PowerShell.MCP.Proxy -c Release -r osx-arm64 --self-contained |
| 31 | +
|
| 32 | + MODULE_PATH="$HOME/.local/share/powershell/Modules/PowerShell.MCP" |
| 33 | + mkdir -p "$MODULE_PATH/bin/osx-arm64" |
| 34 | + cp PowerShell.MCP/bin/Release/net8.0/PowerShell.MCP.dll "$MODULE_PATH/" |
| 35 | + cp PowerShell.MCP/bin/Release/net8.0/Ude.NetStandard.dll "$MODULE_PATH/" |
| 36 | + cp Staging/PowerShell.MCP.psd1 "$MODULE_PATH/" |
| 37 | + cp Staging/PowerShell.MCP.psm1 "$MODULE_PATH/" |
| 38 | + cp PowerShell.MCP.Proxy/bin/Release/net9.0/osx-arm64/publish/PowerShell.MCP.Proxy "$MODULE_PATH/bin/osx-arm64/" |
| 39 | + chmod +x "$MODULE_PATH/bin/osx-arm64/PowerShell.MCP.Proxy" |
| 40 | +
|
| 41 | + echo "Module files:" |
| 42 | + ls -laR "$MODULE_PATH/" |
| 43 | +
|
| 44 | + - name: Test Terminal.app launch and invoke_expression (Issue #38) |
| 45 | + shell: pwsh |
| 46 | + timeout-minutes: 5 |
| 47 | + run: | |
| 48 | + $ErrorActionPreference = "Stop" |
| 49 | +
|
| 50 | + $proxyPath = Get-MCPProxyPath |
| 51 | + Write-Host "Proxy path: $proxyPath" |
| 52 | +
|
| 53 | + # Start Proxy process |
| 54 | + $psi = [System.Diagnostics.ProcessStartInfo]::new() |
| 55 | + $psi.FileName = $proxyPath |
| 56 | + $psi.RedirectStandardInput = $true |
| 57 | + $psi.RedirectStandardOutput = $true |
| 58 | + $psi.RedirectStandardError = $true |
| 59 | + $psi.UseShellExecute = $false |
| 60 | + $psi.CreateNoWindow = $true |
| 61 | +
|
| 62 | + $process = [System.Diagnostics.Process]::Start($psi) |
| 63 | + Write-Host "Proxy started with PID: $($process.Id)" |
| 64 | +
|
| 65 | + function Send-JsonRpc { |
| 66 | + param([string]$Json, [int]$TimeoutMs = 30000) |
| 67 | + Write-Host "Sending: $($Json.Substring(0, [Math]::Min(120, $Json.Length)))..." |
| 68 | + $process.StandardInput.WriteLine($Json) |
| 69 | + $process.StandardInput.Flush() |
| 70 | + $task = $process.StandardOutput.ReadLineAsync() |
| 71 | + if ($task.Wait($TimeoutMs)) { |
| 72 | + return $task.Result |
| 73 | + } else { |
| 74 | + throw "Timeout waiting for response after ${TimeoutMs}ms" |
| 75 | + } |
| 76 | + } |
| 77 | +
|
| 78 | + try { |
| 79 | + # 1. Initialize |
| 80 | + Write-Host "`n=== Step 1: Initialize ===" -ForegroundColor Cyan |
| 81 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' |
| 82 | + Write-Host "OK: $($response.Substring(0, [Math]::Min(100, $response.Length)))..." |
| 83 | +
|
| 84 | + $process.StandardInput.WriteLine('{"jsonrpc":"2.0","method":"notifications/initialized"}') |
| 85 | + $process.StandardInput.Flush() |
| 86 | + Start-Sleep -Seconds 1 |
| 87 | +
|
| 88 | + # 2. Start console via Terminal.app |
| 89 | + Write-Host "`n=== Step 2: start_powershell_console (Terminal.app) ===" -ForegroundColor Cyan |
| 90 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"start_powershell_console","arguments":{"reason":"issue38 test","banner":"Issue #38 E2E Test"}}}' 60000 |
| 91 | + Write-Host "Response: $($response.Substring(0, [Math]::Min(200, $response.Length)))..." |
| 92 | +
|
| 93 | + if ($response -match '"error"') { |
| 94 | + Write-Host "ERROR in start_powershell_console response:" -ForegroundColor Red |
| 95 | + Write-Host $response |
| 96 | + throw "start_powershell_console failed" |
| 97 | + } |
| 98 | + Write-Host "Terminal.app console started" -ForegroundColor Green |
| 99 | +
|
| 100 | + # Take screenshot after console start |
| 101 | + screencapture -x /tmp/screenshot-after-start.png 2>$null |
| 102 | + Write-Host "Screenshot saved: /tmp/screenshot-after-start.png" |
| 103 | +
|
| 104 | + # 3. Quick command - should execute without manual Enter |
| 105 | + Write-Host "`n=== Step 3: invoke_expression (quick) ===" -ForegroundColor Cyan |
| 106 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":10,"method":"tools/call","params":{"name":"invoke_expression","arguments":{"pipeline":"Write-Host TEST-QUICK -ForegroundColor Green"}}}' 30000 |
| 107 | + Write-Host "Response: $($response.Substring(0, [Math]::Min(300, $response.Length)))..." |
| 108 | +
|
| 109 | + if ($response -match 'TEST-QUICK') { |
| 110 | + Write-Host "PASS: Quick command executed without manual Enter" -ForegroundColor Green |
| 111 | + } else { |
| 112 | + Write-Host "WARN: TEST-QUICK not in response (may be first-call redirect)" -ForegroundColor Yellow |
| 113 | + } |
| 114 | +
|
| 115 | + # 4. Delayed command - the main #38 scenario |
| 116 | + Write-Host "`n=== Step 4: invoke_expression after 5s delay ===" -ForegroundColor Cyan |
| 117 | + Start-Sleep -Seconds 5 |
| 118 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":20,"method":"tools/call","params":{"name":"invoke_expression","arguments":{"pipeline":"Get-Date -Format yyyy-MM-dd"}}}' 30000 |
| 119 | + Write-Host "Response: $($response.Substring(0, [Math]::Min(300, $response.Length)))..." |
| 120 | +
|
| 121 | + $today = Get-Date -Format "yyyy-MM-dd" |
| 122 | + if ($response -match $today) { |
| 123 | + Write-Host "PASS: Delayed command returned correct date ($today)" -ForegroundColor Green |
| 124 | + } else { |
| 125 | + Write-Host "FAIL: Expected date $today not found in response" -ForegroundColor Red |
| 126 | + throw "Issue #38 regression: delayed command did not execute automatically" |
| 127 | + } |
| 128 | +
|
| 129 | + # 5. Long-running command |
| 130 | + Write-Host "`n=== Step 5: Long-running command (3s sleep) ===" -ForegroundColor Cyan |
| 131 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":30,"method":"tools/call","params":{"name":"invoke_expression","arguments":{"pipeline":"Start-Sleep -Seconds 3; Write-Host LONG-DONE"}}}' 60000 |
| 132 | + Write-Host "Response: $($response.Substring(0, [Math]::Min(300, $response.Length)))..." |
| 133 | +
|
| 134 | + if ($response -match 'LONG-DONE') { |
| 135 | + Write-Host "PASS: Long-running command completed" -ForegroundColor Green |
| 136 | + } else { |
| 137 | + throw "Long-running command did not return expected output" |
| 138 | + } |
| 139 | +
|
| 140 | + # 6. Command after long-running |
| 141 | + Write-Host "`n=== Step 6: Command immediately after long-running ===" -ForegroundColor Cyan |
| 142 | + $response = Send-JsonRpc '{"jsonrpc":"2.0","id":40,"method":"tools/call","params":{"name":"invoke_expression","arguments":{"pipeline":"Write-Host AFTER-LONG"}}}' 30000 |
| 143 | + Write-Host "Response: $($response.Substring(0, [Math]::Min(300, $response.Length)))..." |
| 144 | +
|
| 145 | + if ($response -match 'AFTER-LONG') { |
| 146 | + Write-Host "PASS: Post-long command executed" -ForegroundColor Green |
| 147 | + } else { |
| 148 | + throw "Post-long command did not execute" |
| 149 | + } |
| 150 | +
|
| 151 | + # Take final screenshot |
| 152 | + screencapture -x /tmp/screenshot-final.png 2>$null |
| 153 | +
|
| 154 | + Write-Host "`n========================================" -ForegroundColor Green |
| 155 | + Write-Host "ALL TESTS PASSED - Issue #38 not reproduced" -ForegroundColor Green |
| 156 | + Write-Host "========================================" -ForegroundColor Green |
| 157 | +
|
| 158 | + } finally { |
| 159 | + if (-not $process.HasExited) { $process.Kill() } |
| 160 | + $process.Dispose() |
| 161 | + } |
| 162 | +
|
| 163 | + - name: Upload screenshots |
| 164 | + if: always() |
| 165 | + uses: actions/upload-artifact@v4 |
| 166 | + with: |
| 167 | + name: macos-terminal-screenshots |
| 168 | + path: /tmp/screenshot-*.png |
| 169 | + if-no-files-found: ignore |
0 commit comments