Skip to content

Commit 26af07e

Browse files
committed
Add cross-platform GitHub Actions tests for Windows, Linux, and macOS
1 parent cd2bf42 commit 26af07e

2 files changed

Lines changed: 160 additions & 110 deletions

File tree

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Cross-Platform Test
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- 'PowerShell.MCP/**'
9+
- 'PowerShell.MCP.Proxy/**'
10+
- 'Staging/**'
11+
12+
jobs:
13+
test:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: windows-latest
19+
rid: win-x64
20+
exe: PowerShell.MCP.Proxy.exe
21+
- os: ubuntu-latest
22+
rid: linux-x64
23+
exe: PowerShell.MCP.Proxy
24+
- os: macos-14
25+
rid: osx-arm64
26+
exe: PowerShell.MCP.Proxy
27+
28+
runs-on: ${{ matrix.os }}
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup .NET
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: '9.0.x'
37+
38+
- name: Install PowerShell (macOS)
39+
if: runner.os == 'macOS'
40+
run: |
41+
brew install powershell/tap/powershell
42+
43+
- name: Install PowerShell (Linux)
44+
if: runner.os == 'Linux'
45+
run: |
46+
# Install PowerShell on Ubuntu
47+
sudo apt-get update
48+
sudo apt-get install -y wget apt-transport-https software-properties-common
49+
source /etc/os-release
50+
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
51+
sudo dpkg -i packages-microsoft-prod.deb
52+
rm packages-microsoft-prod.deb
53+
sudo apt-get update
54+
sudo apt-get install -y powershell
55+
56+
- name: Verify PowerShell
57+
shell: pwsh
58+
run: |
59+
Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)"
60+
Write-Host "OS: $($PSVersionTable.OS)"
61+
62+
- name: Build PowerShell.MCP module
63+
run: |
64+
dotnet build PowerShell.MCP -c Release --no-incremental
65+
66+
- name: Build Proxy
67+
run: |
68+
dotnet publish PowerShell.MCP.Proxy -c Release -r ${{ matrix.rid }} --self-contained
69+
70+
- name: Setup module directory (Windows)
71+
if: runner.os == 'Windows'
72+
shell: pwsh
73+
run: |
74+
$modulePath = "$env:USERPROFILE\Documents\PowerShell\Modules\PowerShell.MCP"
75+
New-Item -Path "$modulePath\bin\${{ matrix.rid }}" -ItemType Directory -Force | Out-Null
76+
77+
Copy-Item "PowerShell.MCP\bin\Release\net9.0\PowerShell.MCP.dll" -Destination $modulePath
78+
Copy-Item "PowerShell.MCP\bin\Release\net9.0\Ude.NetStandard.dll" -Destination $modulePath
79+
Copy-Item "Staging\PowerShell.MCP.psd1" -Destination $modulePath
80+
Copy-Item "Staging\PowerShell.MCP.psm1" -Destination $modulePath
81+
Copy-Item "PowerShell.MCP.Proxy\bin\Release\net9.0\${{ matrix.rid }}\publish\${{ matrix.exe }}" -Destination "$modulePath\bin\${{ matrix.rid }}"
82+
83+
Write-Host "Module files:"
84+
Get-ChildItem $modulePath -Recurse | Select-Object FullName
85+
86+
- name: Setup module directory (Linux/macOS)
87+
if: runner.os != 'Windows'
88+
run: |
89+
MODULE_PATH="$HOME/.local/share/powershell/Modules/PowerShell.MCP"
90+
mkdir -p "$MODULE_PATH/bin/${{ matrix.rid }}"
91+
92+
cp PowerShell.MCP/bin/Release/net9.0/PowerShell.MCP.dll "$MODULE_PATH/"
93+
cp PowerShell.MCP/bin/Release/net9.0/Ude.NetStandard.dll "$MODULE_PATH/"
94+
cp Staging/PowerShell.MCP.psd1 "$MODULE_PATH/"
95+
cp Staging/PowerShell.MCP.psm1 "$MODULE_PATH/"
96+
cp "PowerShell.MCP.Proxy/bin/Release/net9.0/${{ matrix.rid }}/publish/${{ matrix.exe }}" "$MODULE_PATH/bin/${{ matrix.rid }}/"
97+
chmod +x "$MODULE_PATH/bin/${{ matrix.rid }}/${{ matrix.exe }}"
98+
99+
echo "Module files:"
100+
ls -laR "$MODULE_PATH/"
101+
102+
- name: Test module import
103+
shell: pwsh
104+
run: |
105+
$ErrorActionPreference = "Stop"
106+
107+
Write-Host "=== Importing module ===" -ForegroundColor Cyan
108+
Import-Module PowerShell.MCP -Verbose
109+
110+
Write-Host "`n=== Module info ===" -ForegroundColor Cyan
111+
Get-Module PowerShell.MCP | Format-List Name, Version, ModuleBase
112+
113+
Write-Host "`n=== Get-MCPProxyPath ===" -ForegroundColor Cyan
114+
$proxyPath = Get-MCPProxyPath
115+
Write-Host "Proxy path: $proxyPath"
116+
if (-not (Test-Path $proxyPath)) { throw "Proxy not found at $proxyPath" }
117+
118+
Write-Host "`n=== Get-MCPProxyPath -Escape ===" -ForegroundColor Cyan
119+
$escapedPath = Get-MCPProxyPath -Escape
120+
Write-Host "Escaped path: $escapedPath"
121+
122+
Write-Host "`n=== PSReadLine status ===" -ForegroundColor Cyan
123+
$psrl = Get-Module PSReadLine
124+
if ($IsWindows) {
125+
if ($psrl) {
126+
Write-Host "PSReadLine is loaded (expected on Windows)" -ForegroundColor Green
127+
} else {
128+
Write-Host "PSReadLine is NOT loaded (unexpected on Windows)" -ForegroundColor Yellow
129+
}
130+
} else {
131+
if ($psrl) {
132+
Write-Host "PSReadLine is loaded (unexpected on Linux/macOS)" -ForegroundColor Yellow
133+
} else {
134+
Write-Host "PSReadLine is NOT loaded (expected on Linux/macOS)" -ForegroundColor Green
135+
}
136+
}
137+
138+
Write-Host "`n=== All tests passed ===" -ForegroundColor Green
139+
140+
- name: Test Proxy startup
141+
shell: pwsh
142+
run: |
143+
$ErrorActionPreference = "Stop"
144+
145+
Write-Host "=== Testing Proxy ===" -ForegroundColor Cyan
146+
$proxyPath = Get-MCPProxyPath
147+
148+
Write-Host "Starting Proxy..."
149+
$process = Start-Process -FilePath $proxyPath -PassThru
150+
151+
Start-Sleep -Seconds 2
152+
153+
if ($process.HasExited) {
154+
Write-Host "Proxy exited with code: $($process.ExitCode)" -ForegroundColor Red
155+
throw "Proxy exited unexpectedly"
156+
} else {
157+
Write-Host "Proxy is running (PID: $($process.Id))" -ForegroundColor Green
158+
Stop-Process -Id $process.Id -Force
159+
Write-Host "Proxy stopped successfully" -ForegroundColor Green
160+
}

.github/workflows/macos-test.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)