fix(windows): route bash tool and shell hooks through Git Bash, fix ruff SIM117 lint - #32
Closed
truecallerabreham wants to merge 1 commit into
Closed
truecallerabreham wants to merge 1 commit into
truecallerabreham wants to merge 1 commit into
Conversation
On Windows, subprocess with shell=True defaults to cmd.exe (%COMSPEC%), where POSIX commands (pwd, ls, sh, cat, sleep) fail, causing all Windows test lanes to fail in CI. - Route BashTool and Hooks through Git Bash on Windows when present, falling back to default shell when unavailable. - In hooks._fire, quote Windows drive-letter executables when invoking bash. - In tests/test_core.py, combine nested with contexts to fix ruff SIM117, and normalize Git Bash's /tmp mount point in norm_dir. - In tests/test_hooks.py, use .as_posix() for path interpolation in shell command strings. - Synchronize README line count badges and prose with the current tree. All 178 tests passing across the full suite; ruff check clean; compileall clean.
Author
|
Verified full CI matrix (14/14 jobs) green on GitHub Actions:
Workflow run receipt: https://github.com/truecallerabreham/CoreCoder/actions/runs/35665113803 |
Owner
|
Thanks for the thorough diagnosis — it was right on all three counts. Main's CI has been red on I landed the fix as my own commit (8a44515) rather than merging this, per the project's habit of keeping external PRs as reference and landing reviewed work directly. What it does, with credit to your analysis:
CI should go green on the next run. Thanks again for the careful root-cause work. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause
Currently, upstream CI is red across all Windows lanes (
windows-latest, Python 3.10, 3.11, 3.12, 3.13) and thelintjob:SIM117intests/test_core.py: A nestedwithblock (with mock.patch(...): with pytest.raises(...):) failsruff check corecoder tests.BashToolandHooks: On Windows, Python'ssubprocess.run(command, shell=True)defaults tocmd.exe(%COMSPEC%), where POSIX commands (pwd,ls,sh,cat,sleep) are not recognized. Commitae0c9aaintroducednorm_diranticipatinggit-bash's/c/Users/...output format, butBashToolandHookswere executing incmd.exerather than Git Bash./tmpMount Point on Windows: In Git Bash, pytest'stmp_pathunderAppData/Local/Tempresolves to/tmp/pytest-of-..., causingnorm_dircomparisons to fail if the/tmpprefix is not expanded totempfile.gettempdir().Changes
corecoder/tools/bash.py: Added a cached_find_bash()helper locating Git Bash on Windows (C:\Program Files\Git\bin\bash.exe, relative togit, or inPATHoutside System32). If found,BashTool.executeruns[bash_exe, "-c", command]; otherwise it falls back toshell=True.corecoder/hooks.py: Routed shell hook commands through Git Bash on Windows when present, and automatically quoted drive-letter executables (sys.executable).tests/test_core.py: Combined the nestedwithstatements on line 717 to satisfySIM117, normalized/tmptotempfile.gettempdir()on Windows innorm_dir, and usedtarget.as_posix()in the parallel cd test.tests/test_hooks.py: Used.as_posix()when interpolating paths into shell commands (sh,cat).README.md&README_CN.md: Synchronized the engine LoC and physical/net line count badges with the current tree (1,324 engine LoC, 2,621 physical lines, 2,113 net), keepingtest_readme_line_counts_are_currentgreen.Local Verification
uv run ruff check corecoder tests-> All checks passedpython -m compileall -q corecoder tests-> 0 errorsuv run pytest tests/-> 178 passed in 28.24s (full suite green on Windows)