refactor run-with-dependencies shell script & fold into cli.js #2121
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
need/triage
Needs initial labeling and prioritization
As part of the epic journey that was #2065, I ended up adding a shell script called
run-with-dependencies.sh
to bring the docker compose environment up and down, and arun-test.sh
script to kick off the test suite. I used shell scripts because they were easy to get going with as I was trying to figure out if testcontainers was the cause of a show-stopping issue, and we merged them in to avoid that PR branch going stale. This issue is to track replacing them with a JS solution for better maintainability and consistency.The
run-with-dependencies
script is essentially doing the same thing asservices start
andservices stop
, except that it will run an arbitrary command in between, and export some config variables to point to the right service ports. I really like the "with dependencies" pattern, since it ensures that things always get cleaned up even if things exit abnormally. But I think it may make more sense as a flag, e.g.--with-services
, or something.So, my tentative plan is:
run-dev
andrun-test
subcommands to the cli, to setup and run the dev server and ava, respectively.execa
+ the command line tools, or use the Miniflare / Ava JS APIs.--with-services
flag, which causes them to be sandwiched between docker composeup
anddown
calls (usingexeca
)DATABASE_URL
and other port-dependent config vars to be overridden and made available to therun-dev
/run-test
commands, so they can use the dynamic values instead of whatever is in.env
--persist
flag, to enable persistent data volumes.This seems like a pretty flexible solution - you can run dev and test either with or without an automatic environment, so if you have a custom set of volumes for debugging or something, you can set that up manually and run
cli.js run-dev
without the--with-services
flag. But the npm scripts would include the flag, so by default everything is nicely automatic and isolated.Anyone with ideas for improvement or a better plan for hooking this up should please chime in!
The text was updated successfully, but these errors were encountered: