moon icon indicating copy to clipboard operation
moon copied to clipboard

[bug] Moon CI skips dependent tasks

Open ghost opened this issue 2 months ago • 15 comments

Describe the bug

We've been consistently seeing typecheck tasks not run on all affected projects. This has led to many of bugs slipping into main.

I was able to reproduce this in this repo. We have 5 moon projects, 4 apps and 1 lib.

I changed a contract in the lib project and made the appropriate changes in 3 of the app projects (app2, app3, app3) (commit here) During moon ci, app4:typecheck did not run (even though it would have failed) As seen in the moon ci report here

Steps to reproduce

  1. Change the contract in lib1
  2. Modify 3 of the 4 apps to satisfy the new contract
  3. delete moon cache and run moon ci

Expected behavior

moon app4:typecheck should have run

Screenshots

Environment


Additional context

I believe there's a few places where moon ci skips tasks if it's "processed" it before (for example: https://github.com/moonrepo/moon/blob/master/crates/affected/src/affected_tracker.rs#L387 and https://github.com/moonrepo/moon/blob/master/crates/action-graph/src/action_graph_builder.rs#L848) . But this is causing issues when we need to process a project's dependents but moon first sees it as dependency of another affected project.

ghost avatar Oct 28 '25 15:10 ghost

Can we get some attention on this please @milesj

ghost avatar Oct 31 '25 14:10 ghost

I have a potential fix. Probably this weekend.

milesj avatar Oct 31 '25 15:10 milesj

Try v1.41.6

milesj avatar Nov 01 '25 22:11 milesj

Thank you for the quick turnaround, was able to validate in moon-test that the fix worked!

ghost avatar Nov 05 '25 17:11 ghost

Hi @milesj, after using the latest run, we're noticing that moon ci is now running unnecessary tasks and our build time has skyrocketed. It looks like dependents of dependents of touched projects are getting run. I've updated the moon-test repo to reflect this issue.

Steps to reproduce:

  1. Change contract in lib1
  2. Run moon ci

Expected behavior: app5:typecheck shouldn't run since it's not dependent on lib1.

ghost avatar Nov 07 '25 19:11 ghost

@sosena-bekele moon ci right now runs dependencies and dependents of affected tasks, using deep tree searching. https://moonrepo.dev/docs/guides/ci#how-it-works

This will change in v2, by EOY, but for now, I would suggest downgrading or switching to moon run instead.

milesj avatar Nov 08 '25 04:11 milesj

I'm running into similar issue, with both moon run --affected and moon ci.

For my usecase, I only want to only run tasks that were changed or had their dependencies changed.

I found out that getting list of tasks from moon query tasks --affected --downstream deep --upstream none --id "^deploy$" and then passing them to moon run works.

eplightning avatar Nov 08 '25 04:11 eplightning

Give v1.41.7 a try.

milesj avatar Nov 09 '25 23:11 milesj

Thank you! moon ci --upstream none --downstream deep ":image" does exactly what I wanted for CI runs.

Similar flags would be nice for moon run as well but for now I can workaround those with a script.

eplightning avatar Nov 10 '25 16:11 eplightning

@milesj I tested with v.1.41.7 but the behavior is the same. App5 tasks are running even though Lib1 is the only touched project and app5 not not depend on lib1 (it depends on lib2 which depends on lib1)

here's the CI report from my test https://github.com/sosena-bekele/moon-test/blob/main/report_deep_dependency.json

ghost avatar Nov 11 '25 18:11 ghost

You can control the depth with the new options --upstream and --downstream.

milesj avatar Nov 11 '25 18:11 milesj

That also doesn't work.

ghost avatar Nov 11 '25 18:11 ghost

moon-affected-output.md I have attached the behavior I'm seeing when running moon query tasks. --downstream direct doesn't work as expected

ghost avatar Nov 11 '25 19:11 ghost

Any update?

ghost avatar Nov 17 '25 19:11 ghost

This probably won't be fixed by EOY unless someone wants to investigate themselves.

You should inspect the logs for moon_affected lines to see what's actually triggering it all.

milesj avatar Nov 17 '25 20:11 milesj