[feature] Add pre/post commands to custom jobs
Tangentially related to running multiple commands (see #165) there is another issue that is tricky to work around: needing setup and/or teardown actions before running a test.
I have a project using Rust and Maturin to build a Python module, which can then be tested with Pytest. Just running pytest with some env vars set is okay to run tests but there are two issues:
- before running tests at all, some initial setup of a venv needs to be done. This setup should NOT be run every time the watch triggers a test run update, only once.
- the only thing the watch accomplishes is catching changes to the test, with the build step involved (in my case
maturin developalso needs to be triggered if the Rust code changes.
The second of these can be handled with two work-arounds (either putting it in a script to run before pytest every time (slow but simple) or running it in a watch on the side in addition to bacon (faster but more complex)), but the first one basically means bacon can't be launched directly, it needs to be launched from a wrapper that does the setup for it.
I would imagine it is possible to have bacon handle both of these cases as well many more by introducing one or two new features:
- A pre/post (setup/teardown) command could be configured in addition to
envkeys that would be executed once before (or after) the test watch loop is entered. - A during (background) command could be launched out of sight that is expected to stay running while the bacon test interface is active, then killed off when it is done.