ci(windows): scp tests/ into VM and run PowerShell test suite
This commit is contained in:
parent
df063dcd61
commit
1423c7c11c
2 changed files with 52 additions and 0 deletions
|
|
@ -27,6 +27,9 @@ jobs:
|
||||||
windows-test:
|
windows-test:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install sshpass
|
- name: Install sshpass
|
||||||
run: |
|
run: |
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
|
|
@ -72,6 +75,25 @@ jobs:
|
||||||
echo "$out"
|
echo "$out"
|
||||||
echo "$out" | grep -q "^CLEAN" || { echo "marker from previous run survived — revert is broken"; exit 1; }
|
echo "$out" | grep -q "^CLEAN" || { echo "marker from previous run survived — revert is broken"; exit 1; }
|
||||||
|
|
||||||
|
- name: Copy tests into VM
|
||||||
|
env:
|
||||||
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
||||||
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
||||||
|
"if not exist C:\\ci mkdir C:\\ci"
|
||||||
|
sshpass -e scp -o StrictHostKeyChecking=no \
|
||||||
|
-P "$WIN_PORT" -r tests \
|
||||||
|
"$WIN_USER@$WIN_HOST:C:/ci/"
|
||||||
|
|
||||||
|
- name: Run PowerShell tests on Windows
|
||||||
|
env:
|
||||||
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
||||||
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
||||||
|
"powershell -NoProfile -ExecutionPolicy Bypass -File C:\\ci\\tests\\run-tests.ps1"
|
||||||
|
|
||||||
- name: Drop marker file (would persist without revert)
|
- name: Drop marker file (would persist without revert)
|
||||||
env:
|
env:
|
||||||
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
||||||
|
|
|
||||||
30
tests/run-tests.ps1
Normal file
30
tests/run-tests.ps1
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$script:failed = 0
|
||||||
|
|
||||||
|
function Assert-True($cond, $msg) {
|
||||||
|
if ($cond) { Write-Host "PASS: $msg" }
|
||||||
|
else { Write-Host "FAIL: $msg"; $script:failed++ }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "=== environment ==="
|
||||||
|
Write-Host "host=$env:COMPUTERNAME user=$env:USERNAME"
|
||||||
|
Write-Host "ps=$($PSVersionTable.PSVersion)"
|
||||||
|
|
||||||
|
Write-Host "=== tests ==="
|
||||||
|
Assert-True ($PSVersionTable.PSVersion.Major -ge 5) "PowerShell major >= 5"
|
||||||
|
Assert-True ((Get-CimInstance Win32_OperatingSystem).Caption -match 'Windows') "OS reports as Windows"
|
||||||
|
Assert-True ((2 + 2) -eq 4) "arithmetic sanity"
|
||||||
|
Assert-True ($env:USERNAME -eq 'edr') "running as edr"
|
||||||
|
|
||||||
|
$tmp = Join-Path $env:TEMP "ci-write-test.txt"
|
||||||
|
"hello $(Get-Date -Format o)" | Out-File -Encoding ascii $tmp
|
||||||
|
Assert-True (Test-Path $tmp) "wrote file under TEMP"
|
||||||
|
Assert-True ((Get-Content $tmp) -match 'hello') "read file content back"
|
||||||
|
Remove-Item $tmp -Force
|
||||||
|
|
||||||
|
if ($failed -gt 0) {
|
||||||
|
Write-Host "$failed test(s) failed"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Write-Host "all tests passed"
|
||||||
|
exit 0
|
||||||
Loading…
Add table
Reference in a new issue