Mix Task Aliases and Umbrellas

Hey folks,

We’re using an umbrella application for the first time and running into some issues with mix task aliases. One of the applications has an ordinary phoenix / ecto situation with the following task alias "test": ["ecto.create --quiet", "ecto.load", "ecto.migrate", "test"]. Notably we’re using ecto.load as part of the setup process since we don’t have all migrations from the beginning of time.

We also have another application in the umbrella that’s using event sourcing, and is using a different ecto database, and we want to just do the normal "test": ["ecto.create --quiet", "ecto.migrate", "test"].

However when we run mix test from the root it ends up trying to run ecto.load in both applications. Is there somewhere that talks about the interaction between mix tasks, mix task aliases, and umbrella apps? Is there a way to have aliases only apply to their respective projects?

5 Likes

I don’t fully have my head around it, but I ran into a similar situation when we had one app that wanted its test alias to include yarn test. What I ended up as a partial workaround (but my team also liked the dependency isolation it brought) was to have my top level umbrella mix.exs to contain:

defp aliases do
  [
    test: "cmd mix test"
  ]
end

It launches a separate BEAM for the tests of each app. That might unravel your problem because it’s no longer trying to resolve the pre-tasks for all the apps in one VM.

3 Likes

@gregvaughn woah! Very neat workaround!

I was thinking here: most problems people have on umbrellas are related to the fact some tasks do not work as expected when executed for all apps sequentially but inside the same BEAM instance. I wonder if it shouldn’t be doing what you did by default. :confused:

@benwilson512 did you settle on a fix or work-around for this issue? (I’m facing the same issue and am uncertain how to best solve it)

As a side-question are you using a library for Event Sourcing?

My “workaround” was just removing the test aliases and running other stuff inside each directory as necessary.

I’m using Commanded for event sourcing.

1 Like

Okay, I see. Maybe I’ll end up going that route too.