Skip to content

Fix mgrep watch for Windows and add CI hooks tests#27

Open
ry2009 wants to merge 4 commits intomainfrom
fix/windows-mgrep-watch-clean
Open

Fix mgrep watch for Windows and add CI hooks tests#27
ry2009 wants to merge 4 commits intomainfrom
fix/windows-mgrep-watch-clean

Conversation

@ry2009
Copy link

@ry2009 ry2009 commented Nov 24, 2025

  • Fix Windows crash by using CREATE_NEW_PROCESS_GROUP instead of os.setsid.
    • Store logs/pids in %TEMP% (overridable via MGREP_TMP) so Windows paths work.
    • Add Windows/POSIX unit tests and a windows-latest CI job to verify the hooks.

Note

Make mgrep watch/kill hooks Windows-compatible with temp-dir handling, add Python unit tests and a Windows/Ubuntu CI job, and adjust postbuild for Windows.

  • Hooks (Python):
    • plugins/mgrep/hooks/mgrep_watch.py:
      • Use TMP_DIR from MGREP_TMP/system temp; write logs/PIDs there.
      • Resolve mgrep via shutil.which.
      • Windows: spawn with CREATE_NEW_PROCESS_GROUP; POSIX: use os.setsid.
      • Extract launch_watch helper.
    • plugins/mgrep/hooks/mgrep_watch_kill.py:
      • Read PID from temp dir; delete after kill.
      • Windows: use SIGTERM; POSIX: use SIGKILL.
      • Extract kill_watch helper.
  • Config:
    • plugins/mgrep/hooks/hook.json: invoke with python instead of python3.
    • package.json: make postbuild chmod no-op on Windows.
  • CI:
    • .github/workflows/ci.yml: add hooks-tests matrix (Ubuntu/Windows), run Python unit tests, and a Windows smoke import check.

Written by Cursor Bugbot for commit 77fa3e1. This will update automatically on new commits. Configure here.

ry2009 and others added 2 commits November 24, 2025 13:18
- Change python3 to python in hook.json (python3 doesn't exist on Windows)
- Use shutil.which() to find mgrep executable (Windows subprocess doesn't find .cmd files by base name)
- Make postbuild script cross-platform (chmod doesn't exist on Windows)
- Update tests to mock shutil.which

Tested manually on Windows 10:
- Hook launches mgrep watch successfully with CREATE_NEW_PROCESS_GROUP
- PID file created in %TEMP%
- Kill hook terminates process and cleans up PID file
- All 5 unit tests pass
@ry2009
Copy link
Author

ry2009 commented Nov 25, 2025

the tests can go they were place holders but fully tested on my windows 10/11 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant