Add Windows backend test preflight and runner#7666
Conversation
Greptile SummaryThis PR adds a PowerShell equivalent of the existing
Confidence Score: 3/5Safe to merge for documentation and tooling; the PowerShell script is read-only but will block Windows contributors running Python 3.12 or 3.13 with a hard exit-1 that the bash counterpart does not impose. The preflight script only affects local developer workflow, not CI or production. The Python version gate diverges from the bash counterpart, producing a hard exit-1 for Python 3.12/3.13 users on Windows where the bash user would see no failure at all. backend/test-preflight.ps1 — specifically the Python version check block around line 107 and the test.sh flag-stripping regex around line 219. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([Start test-preflight.ps1]) --> B{-Python param provided?}
B -- Yes --> C[Use provided path]
B -- No --> D{python in PATH?}
D -- Yes --> E[Use python]
D -- No --> F{py in PATH?}
F -- Yes --> G[Use py -3]
F -- No --> H[Write-Bad: python not found]
C & E & G --> I{python --version matches 3.11.x?}
I -- Yes --> J[Write-Ok]
I -- No --> K[Write-Bad: expects 3.11]
J & K --> L{pytest installed?}
L -- Yes --> M[Write-Ok]
L -- No --> N[Write-Bad]
M & N --> O{black available?}
O -- found --> P[Write-Ok]
O -- missing --> Q[Write-Warn]
P & Q --> R[Check backend package imports]
R --> S[Check env vars]
S --> T{redis-cli in PATH?}
T -- Yes --> U{redis-cli ping succeeds?}
U -- Yes --> V[Write-Ok]
U -- No --> W[Write-Warn]
T -- No --> X[Write-Warn]
V & W & X --> Y[Count unit test files in tests/unit/]
Y --> Z[Parse test.sh references and verify paths]
Z --> AA{FailCount > 0?}
AA -- Yes --> AB([exit 1])
AA -- No --> AC{WarnCount > 0?}
AC -- Yes --> AD([exit 0 with warnings])
AC -- No --> AE([exit 0 all clear])
Reviews (1): Last reviewed commit: "Avoid Redis password argv in Windows pre..." | Re-trigger Greptile |
| if ($pythonVersion -match "Python 3\.11\.") { | ||
| Write-Ok $pythonVersion | ||
| } else { | ||
| Write-Bad "$pythonVersion detected; backend expects Python 3.11" | ||
| } |
There was a problem hiding this comment.
Version mismatch exits with hard failure, blocking non-3.11 Windows contributors
The bash counterpart (test-preflight.sh) reports whatever Python version is present as "ok" without any version gate. This script uses Write-Bad for any Python that isn't 3.11.x, which causes exit code 1 and the message "Fix failures above before running test.sh" for a developer running Python 3.12 or 3.13 — even if their environment is otherwise fully functional. Using Write-Warn here would match the bash behavior (advisory rather than blocking) and avoid unnecessarily gating Windows contributors on an exact minor version.
| if ($pythonVersion -match "Python 3\.11\.") { | |
| Write-Ok $pythonVersion | |
| } else { | |
| Write-Bad "$pythonVersion detected; backend expects Python 3.11" | |
| } | |
| if ($pythonVersion -match "Python 3\.11\.") { | |
| Write-Ok $pythonVersion | |
| } else { | |
| Write-Warn "$pythonVersion detected; backend expects Python 3.11" | |
| } |
There was a problem hiding this comment.
Addressed in 3d942f839: the Python version mismatch now uses Write-Warn instead of Write-Bad, so non-3.11 Windows users are not blocked by the preflight. Re-ran on this Windows machine with Python 3.10.6: 10 passed, 10 warnings, 0 failed, exit code 0.
| } else { | ||
| Write-Bad "No unit test files found in tests/unit/" | ||
| } | ||
|
|
||
| $missingTests = @() | ||
| if (Test-Path "test.sh") { |
There was a problem hiding this comment.
test.sh flag-stripping regex may silently drop test references if flags change
The pattern \s+-v\s*$ strips only a trailing -v. Lines in test.sh that carry additional pytest flags (e.g., --tb=short, -x) won't be stripped correctly, leaving the flag text as part of the resolved path, which will then fail Test-Path and be reported as a missing file. The bash counterpart uses sed 's/ -v//' (not anchored) which has the same narrow assumption. Both are fine today, but worth noting if test.sh flags ever change.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Addressed in 3d942f839: the test.sh validation now tokenizes each pytest line and only keeps tokens matching tests/*, so future pytest flags are ignored instead of being resolved as paths. Re-ran the Windows preflight: 10 passed, 10 warnings, 0 failed, exit code 0.
5f845fc to
69ea4d7
Compare
|
I rebased and force-pushed this branch onto the current |
69ea4d7 to
d22cb2a
Compare
|
Closing this in favor of #7799 for the Windows backend preflight path. After rechecking both branches, #7799 is the cleaner canonical PR for the preflight helper: it is rebased onto the current This older PR also carries the broader |
|
Hey @tianmind-studio 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Summary
test.ps1runner that mirrors the unit-test list fromtest.sh-PythonoverrideReview follow-up
test.shvalidation now extractstests/*tokens instead of depending on a narrow trailing-flag regexVerification
powershell -NoProfile -ExecutionPolicy Bypass -File .\backend\test-preflight.ps1 -Python 'E:\维修前备份-2026-05-23\omi-dev-tools-venv\Scripts\python.exe'