Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor run-with-dependencies shell script & fold into cli.js #2121

Closed
3 tasks
yusefnapora opened this issue Aug 5, 2022 · 1 comment · May be fixed by #2130
Closed
3 tasks

refactor run-with-dependencies shell script & fold into cli.js #2121

yusefnapora opened this issue Aug 5, 2022 · 1 comment · May be fixed by #2130
Labels
kind/enhancement A net-new feature or improvement to an existing feature need/triage Needs initial labeling and prioritization

Comments

@yusefnapora
Copy link
Contributor

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 a run-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 as services start and services 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:

  • add new run-dev and run-test subcommands to the cli, to setup and run the dev server and ava, respectively.
    • These can either use execa + the command line tools, or use the Miniflare / Ava JS APIs.
  • give those new commands a --with-services flag, which causes them to be sandwiched between docker compose up and down calls (using execa)
    • this also causes the DATABASE_URL and other port-dependent config vars to be overridden and made available to the run-dev / run-test commands, so they can use the dynamic values instead of whatever is in .env
  • also add a --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!

@yusefnapora yusefnapora added kind/enhancement A net-new feature or improvement to an existing feature need/triage Needs initial labeling and prioritization labels Aug 5, 2022
@elizabeth-griffiths
Copy link
Member

Closing as this ticket is over 1 year old. If you still need support, please re-open this issue and provide more detail. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature need/triage Needs initial labeling and prioritization
Projects
None yet
2 participants