Debug: unittest-windows (manual) #7
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: "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' -RedirectStandardOutput $outFile -RedirectStandardError $errFile -WindowStyle Hidden -PassThru | |
| $pidFile = Join-Path $env:RUNNER_TEMP 'redis.pid' | |
| $proc.Id | Out-File -FilePath $pidFile -Encoding ascii | |
| Write-Host "Started redis-server (pid=$($proc.Id)), pid written to $pidFile, 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: | | |
| $outFile = Join-Path $env:RUNNER_TEMP 'redis.stdout.log' | |
| $errFile = Join-Path $env:RUNNER_TEMP 'redis.stderr.log' | |
| $pidFile = Join-Path $env:RUNNER_TEMP 'redis.pid' | |
| if (Test-Path $pidFile) { | |
| $redisPid = (Get-Content $pidFile -ErrorAction SilentlyContinue).Trim() | |
| Write-Host "Redis pid (from file): $redisPid" | |
| try { Get-Process -Id $redisPid -ErrorAction SilentlyContinue | Format-Table -AutoSize } catch {} | |
| } else { | |
| Write-Host "Redis pid file not found: $pidFile" | |
| } | |
| Write-Host "Netstat (port 6379):" | |
| netstat -ano | Select-String ":6379" || Write-Host "no netstat output" | |
| if (Get-Command redis-cli -ErrorAction SilentlyContinue) { | |
| try { $out = & redis-cli ping 2>&1; Write-Host "redis-cli ping -> $out" } catch { Write-Host "redis-cli ping failed: $_" } | |
| } else { | |
| Write-Host "redis-cli not found" | |
| } | |
| if (Test-Path $outFile) { Write-Host "--- redis stdout (tail) ---"; Get-Content $outFile -ErrorAction SilentlyContinue | Select-Object -Last 200 } else { Write-Host "redis stdout log not found: $outFile" } | |
| if (Test-Path $errFile) { Write-Host "--- redis stderr (tail) ---"; Get-Content $errFile -ErrorAction SilentlyContinue | Select-Object -Last 200 } else { Write-Host "redis stderr log not found: $errFile" } | |
| - name: Run tests | |
| shell: pwsh | |
| run: | | |
| uv run --no-dev pytest -x --maxfail=1 -q |