quick question is there…

2 minute read

quick question: is there a way to use the dep graph to determine the order in which tasks are done? e.g. i have custom deploy tasks for my apps. I have implicit deps between appA and appB. Assuming they are affected by a change, can I ensure that appA is deployed before appB is?

Responses:

I tried to do this just recently and it was only partially successful. in our nx.json I added dependencies like this "notification-service": { "tags": [], "implicitDependencies": ["documentation-viewer"] },

it seemed to work every time locally, deploying the documentation-viewer before deploying the notification-service. But it didn’t work quite right when I ran it in CI, never figured out why

not sure that helps? ¯_(ツ)_/¯

uh… where did my reply go? :slightly_smiling_face:

lemme try that again: I was hoping that as long as –parallel is false, that it would ‘work out of the box’, but sounds like from your example that it wont

thanks

I was probably just doing something wrong. In my scenario I only needed to enforce the order on the initial deploy of the documentation-viewer app. Once it’s been deployed for the first time order no longer matters for me. So I gave up on it pretty quick and just brute forced the initial deploy so it worked for us.

if you figure it out let me know

you can create a custom architect command in your angular.json (or workspace.json) using the run-commands builder documented here: https://nx.dev/angular/workspace/builders/run-commands-builder

yes i use that to deploy my serverless app. But i have two micro services that I deploy that way, and one needs to deploy before the other (since it uses imports)

e.g. create a deploy architect command that executes your deployment and then use nx affected --target=deploy in order to execute that deploy command

this really is only an issue for the first deploy… after that, they can deploy in parallel.. so I’m probably not too bothered about this

if you use nx run-many --project=projectA,projectB --target=deploy

this should as far as I know deploy the job in the order of their dependencies

I am like 87% sure :slightly_smiling_face:

test it with the lint target, appA is linted first, then appB if appB is dependent on appA

hehe 87% eh? :slightly_smiling_face: sounds good, I’ll play around a bit. Like I said, it’s probably not that important

once my stack is deployed, the microservices can (thankfully) be redeployed simultaneously

good luck!

Updated: