Skip to content

Debug: unittest-windows (manual) #4

Debug: unittest-windows (manual)

Debug: unittest-windows (manual) #4

name: "Debug: unittest-windows (manual)"
on:
workflow_dispatch: {}
jobs:
unittest-windows-debug:
runs-on: windows-latest
env:
REDIS_HOST: "${{ secrets.REDIS_HOST }}"
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Cache of Ruff PyTest and MyPY (Windows)
uses: actions/cache@v4
with:
path: |
.ruff_cache
.pytest_cache
.mypy_cache
key: mypy-pytest-ruff
- name: Install the project
env:
SETUPTOOLS_SCM_PRETEND_VERSION: "0"
run: uv sync --all-extras --no-dev --group test --group typed
- name: Lint check with ruff
uses: astral-sh/ruff-action@v3
- name: Static check with mypy
run: uv run --no-dev mypy
- name: "Install & start Redis on Windows (Chocolatey) - debug"
shell: pwsh
run: |
if ($env:REDIS_HOST) {
Write-Host "Using external REDIS_HOST=$env:REDIS_HOST"
exit 0
}
choco install -y redis
# Try to find redis-server executable
$exe = $null
try { $exe = (Get-Command redis-server -ErrorAction SilentlyContinue).Source } catch {}
if (-not $exe) {
$cand = Get-ChildItem 'C:\ProgramData\chocolatey\lib' -Recurse -Filter 'redis-server.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
if ($cand) { $exe = $cand.FullName }
}
Write-Host "redis-server executable: $exe"
if (-not $exe) { Write-Error "redis-server not found; cannot start"; exit 1 }
# Start redis, bind both IPv4 and IPv6 addresses to reduce localhost mismatch
$outFile = Join-Path $env:RUNNER_TEMP 'redis.stdout.log'
$errFile = Join-Path $env:RUNNER_TEMP 'redis.stderr.log'
Write-Host "Redirecting redis stdout to: $outFile"
Write-Host "Redirecting redis stderr to: $errFile"
$proc = Start-Process -FilePath $exe -ArgumentList '--port 6379 --bind 127.0.0.1 ::1' -RedirectStandardOutput $outFile -RedirectStandardError $errFile -WindowStyle Hidden -PassThru
Write-Host "Started redis-server (pid=$($proc.Id)), waiting for it to accept connections..."
$ok = $false
for ($i=0; $i -lt 30; $i++) {
Start-Sleep -Seconds 1
Write-Host "check attempt $i"
try {
$out = & redis-cli ping 2>$null
if ($out -match 'PONG') { $ok = $true; break }
} catch { }
try {
$tnc = Test-NetConnection -ComputerName 127.0.0.1 -Port 6379 -WarningAction SilentlyContinue
if ($tnc -and $tnc.TcpTestSucceeded) { $ok = $true; break }
} catch {}
}
if (-not $ok) {
Write-Host "=== Redis failed to become reachable; dumping diagnostics ==="
Get-Process -Id $proc.Id -ErrorAction SilentlyContinue | Format-Table -AutoSize
Get-Process -Name redis* -ErrorAction SilentlyContinue | Format-Table -AutoSize
netstat -ano | Select-String ":6379"
if (Test-Path $outFile) { Write-Host "--- redis stdout ---"; Get-Content $outFile -ErrorAction SilentlyContinue | Select-Object -Last 200 }
if (Test-Path $errFile) { Write-Host "--- redis stderr ---"; Get-Content $errFile -ErrorAction SilentlyContinue | Select-Object -Last 200 }
Write-Error "redis did not start or accept connections"
}
Write-Host "redis is up"
- name: "Diagnostics: print redis status (quick)"
shell: pwsh
run: |
Get-Process -Name redis* -ErrorAction SilentlyContinue | Format-Table -AutoSize
netstat -ano | Select-String ":6379"
if (Get-Command redis-cli -ErrorAction SilentlyContinue) { & redis-cli ping } else { Write-Host "redis-cli not found" }
- name: Run tests
shell: pwsh
run: |
uv run --no-dev pytest -x --maxfail=1 -q