|
| 1 | +name: "Debug: unittest-windows (manual)" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + |
| 6 | +jobs: |
| 7 | + unittest-windows-debug: |
| 8 | + runs-on: windows-latest |
| 9 | + env: |
| 10 | + REDIS_HOST: "${{ secrets.REDIS_HOST }}" |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v5 |
| 13 | + |
| 14 | + - name: Install uv |
| 15 | + uses: astral-sh/setup-uv@v6 |
| 16 | + with: |
| 17 | + enable-cache: true |
| 18 | + |
| 19 | + - name: Cache of Ruff PyTest and MyPY (Windows) |
| 20 | + uses: actions/cache@v4 |
| 21 | + with: |
| 22 | + path: | |
| 23 | + .ruff_cache |
| 24 | + .pytest_cache |
| 25 | + .mypy_cache |
| 26 | + key: mypy-pytest-ruff |
| 27 | + |
| 28 | + - name: Install the project |
| 29 | + env: |
| 30 | + SETUPTOOLS_SCM_PRETEND_VERSION: "0" |
| 31 | + run: uv sync --all-extras --no-dev --group test --group typed |
| 32 | + |
| 33 | + - name: Lint check with ruff |
| 34 | + uses: astral-sh/ruff-action@v3 |
| 35 | + |
| 36 | + - name: Static check with mypy |
| 37 | + run: uv run --no-dev mypy |
| 38 | + |
| 39 | + - name: "Install & start Redis on Windows (Chocolatey) - debug" |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + if ($env:REDIS_HOST) { |
| 43 | + Write-Host "Using external REDIS_HOST=$env:REDIS_HOST" |
| 44 | + exit 0 |
| 45 | + } |
| 46 | + choco install -y redis |
| 47 | + # Try to find redis-server executable |
| 48 | + $exe = $null |
| 49 | + try { $exe = (Get-Command redis-server -ErrorAction SilentlyContinue).Source } catch {} |
| 50 | + if (-not $exe) { |
| 51 | + $cand = Get-ChildItem 'C:\ProgramData\chocolatey\lib' -Recurse -Filter 'redis-server.exe' -ErrorAction SilentlyContinue | Select-Object -First 1 |
| 52 | + if ($cand) { $exe = $cand.FullName } |
| 53 | + } |
| 54 | + Write-Host "redis-server executable: $exe" |
| 55 | + if (-not $exe) { Write-Error "redis-server not found; cannot start"; exit 1 } |
| 56 | + # Start redis, bind both IPv4 and IPv6 addresses to reduce localhost mismatch |
| 57 | + Start-Process -FilePath $exe -ArgumentList '--port 6379 --bind 127.0.0.1 ::1' -NoNewWindow |
| 58 | + Write-Host "Started redis-server, waiting for it to accept connections..." |
| 59 | + $ok = $false |
| 60 | + for ($i=0; $i -lt 30; $i++) { |
| 61 | + Start-Sleep -Seconds 1 |
| 62 | + Write-Host "check attempt $i" |
| 63 | + try { |
| 64 | + $out = & redis-cli ping 2>$null |
| 65 | + if ($out -match 'PONG') { $ok = $true; break } |
| 66 | + } catch { } |
| 67 | + try { |
| 68 | + $tnc = Test-NetConnection -ComputerName 127.0.0.1 -Port 6379 -WarningAction SilentlyContinue |
| 69 | + if ($tnc -and $tnc.TcpTestSucceeded) { $ok = $true; break } |
| 70 | + } catch {} |
| 71 | + } |
| 72 | + if (-not $ok) { |
| 73 | + Write-Host "=== Redis failed to become reachable; dumping diagnostics ===" |
| 74 | + Get-Process -Name redis* -ErrorAction SilentlyContinue | Format-Table -AutoSize |
| 75 | + netstat -ano | Select-String ":6379" |
| 76 | + if (Test-Path "$env:USERPROFILE\redis.out") { Get-Content "$env:USERPROFILE\redis.out" -ErrorAction SilentlyContinue | Select-Object -Last 200 } |
| 77 | + if (Test-Path "$env:USERPROFILE\redis.err") { Get-Content "$env:USERPROFILE\redis.err" -ErrorAction SilentlyContinue | Select-Object -Last 200 } |
| 78 | + Write-Error "redis did not start or accept connections" |
| 79 | + } |
| 80 | + Write-Host "redis is up" |
| 81 | +
|
| 82 | + - name: "Diagnostics: print redis status (quick)" |
| 83 | + shell: pwsh |
| 84 | + run: | |
| 85 | + Get-Process -Name redis* -ErrorAction SilentlyContinue | Format-Table -AutoSize |
| 86 | + netstat -ano | Select-String ":6379" |
| 87 | + if (Get-Command redis-cli -ErrorAction SilentlyContinue) { & redis-cli ping } else { Write-Host "redis-cli not found" } |
| 88 | +
|
| 89 | + - name: Run tests |
| 90 | + shell: pwsh |
| 91 | + run: | |
| 92 | + uv run --no-dev pytest -x --maxfail=1 -q |
0 commit comments