rye icon indicating copy to clipboard operation
rye copied to clipboard

Support for pre-/post-hooks in Rye custom scripts

Open SamoylovMD opened this issue 7 months ago • 0 comments

tool.rye.scripts looks promising as it helps to automate some parts of my development process. However, I found it lacking pre-or post- hooks for commands. For example, I want to run a test suite in my project, which depends on a local service which I run via Docker, and after the test suite succeeds or fails, I want to stop local services and clean up everything, keeping my development environment clean. The catch is to perform post-hook in a separate shell/process to have a robust way to clean up regardless of how badly the main script failed.

This functionality could look like this:

[tool.rye.scripts]
pre_itest = { chain = [ "my_server:build", "my_server:run" ]
my_server:build = "docker build ..."
my_server:run = "docker run my_server"
itest = "pytest -s intg"
post_itest = "docker stop my_server"

so the whole process would be called by a single command rye run itest.

The similar functionality is present in PDM.

SamoylovMD avatar Jul 19 '24 15:07 SamoylovMD