I have the following setup:
Now I'd like to set a githook that runs all my tests before I push. I have the following problem: I can't activate my virtual environment within the githook.
I tried to activate my anaconda env in the githook script but I can't get it to work. activate
as command is not available and calling the whole path ../Anaconda3/Scripts/activate.bat
does nothing.
I also tried to use python-githooks to configure the hook for me, but this doesn't seem to work in Windows (it can't read PWD
from the environment...)
I'm gratefull for any suggestions.
The solution was to create a .bat-File at the root of the git repository, with:
call C:\...\Anaconda3\Scripts\activate.bat
call activate fs_env
pytest
and to call this file within the pre-push file in .git/hooks with:
./runtests.bat