defenseunicorns / maru-runner

The Unicorn Task Runner
Apache License 2.0
10 stars 1 forks source link

Run background tasks #131

Open TristanHoladay opened 4 months ago

TristanHoladay commented 4 months ago

Is your feature request related to a problem? Please describe

I'd like to run a task / cmd in the background, allowing the next task / cmd to run, making use of what's been started by the first task / cmd.

My use case is in uds-engine we are embedding the ui in a Go backend. For e2e testing running in CI, we want to start the backend and then execute the npm script that runs our playwright tests, which will run against that Go server.

The task: Screenshot from 2024-07-16 06-41-19

The current issue is that even when using the & at the end of our server cmd Maru does not move on to the next cmd in the sequence. Screenshot from 2024-07-16 06-40-46

At the moment, the only way to do this is to split the task into 2 separate tasks and call them from two different terminals.

Describe the solution you'd like

Describe alternatives you've considered

Potentially #80 could solve this issue as well, allowing us to call both tasks, to start the backend and run the tests, from a single point in our CI workflow.

e.g.

- name: Run server and then e2e tests
        run: uds run test:e2e-backend test:e2e-frontend

Another workaround (that we're currently doing) is to remove the server startup from a task and run it directly in a github actions step because github actions handles the background cmd and moves on to the next step

  # Run e2e backend first to start air server in the background
      - name: Run e2e backend setup
        run: |
            uds run setup:slim-cluster --no-progress
            go install github.com/air-verse/air@latest
            air -c .air.toml &

      - name: Run e2e frontend tests
        run: uds run test:e2e --no-progress

Additional context

Add any other context or screenshots about the feature request here.

zachariahmiller commented 1 month ago

This would pair nicely with something like a defer for cleanup. i've run into this and come up with super janky solutions numerous times already