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

[bug] moon.yml dependsOn does not work as expected #1785

Open
sharpepd opened this issue Jan 8, 2025 · 1 comment
Open

[bug] moon.yml dependsOn does not work as expected #1785

sharpepd opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sharpepd
Copy link

sharpepd commented Jan 8, 2025

In the docs https://moonrepo.dev/docs/config/project#dependson it says "The most common use case for this is building those projects before building this one". I am unsure what that really means and the behaviour I am seeing does not fit with what I would expect.

If I have two projects app1 & app2 and app1 is dependent on app2, then I am expecting ALL tasks of app2 to be completed before app1 tasks are attempted.

But this is not what I am observing.

Steps to reproduce

I setup a simple moon set-up:

workspace.yml

projects:
  - 'apps/*'

apps/app1/moon.yml

dependsOn:
  - app2
tasks:
  build:
    script: 'echo "Building app1"'
  deploy:
    script: 'echo "Deploying app1"'
    deps: 
    - build

apps/app2/moon.yml

tasks:
  build:
    script: 'echo "Building app2"'
  deploy:
    script: 'echo "Deploying app2"'
    deps: 
    - build

When I run moon run :deploy --summary

I get the running order (summary only shown)

pass SyncWorkspace (1ms)
skip SetupToolchain(system) (skipped, 2ms)
pass SyncProject(system, app2) (1ms)
pass SyncProject(system, app1) (2ms)
pass RunTask(app2:build) (837ms)
pass RunTask(app1:build) (834ms)
pass RunTask(app1:deploy) (814ms)
pass RunTask(app2:deploy) (839ms)

Expected behavior

For the above example I am expecting:

[... skip to RunTasks]
pass RunTask(app2:build) (846ms)
pass RunTask(app2:deploy) (869ms)
pass RunTask(app1:build) (832ms)
pass RunTask(app1:deploy) (878ms)

Screenshots

N/A

Environment

Issue observed in Moon 1.31.0 (also earlier versions)
I am operating on windows 10

Additional context

It can be I am just misunderstanding what it means, in which case the documentation could be improved to clarify, or there is an issue here!

@sharpepd sharpepd added the bug Something isn't working label Jan 8, 2025
@milesj
Copy link
Collaborator

milesj commented Jan 8, 2025

It doesn't happen automatically, you need to use the ^: target in task dependencies. Running everything by default is a bad idea.

https://moonrepo.dev/docs/concepts/target#dependencies-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants