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

[feature] Ability to query for tasks that are affected by changed files. #1032

Closed
indietyp opened this issue Sep 3, 2023 · 11 comments
Closed
Labels
enhancement New feature or request

Comments

@indietyp
Copy link

indietyp commented Sep 3, 2023

Is your feature request related to a problem? Please describe.

I am currently looking for a replacement for turborepo run --dry-run which will tell one which tasks are to be executed with the changed files. I know that moon ci and moon query tasks exists. I thought that if I would do moon query tasks --affected I would get a list of tasks that will trigger with the affected files, but that doesn't seem to be the case, as filtering for affected files will only change so that tasks of projects that have been affected are display.

Describe the solution you'd like

A command to essentially get the same output of moon ci (maybe a --dry-run option or moon query command) that enables on to query which tasks are to be executed based on the affected files.

Describe alternatives you've considered

Try to implement this myself using a chain of commands, but because of globs that may not be as straight-forward.

@indietyp indietyp added the enhancement New feature or request label Sep 3, 2023
@milesj
Copy link
Collaborator

milesj commented Sep 3, 2023

@indietyp I haven't tried this yet but I think you can do this:

moon query touched-files | moon query tasks --affected

@indietyp
Copy link
Author

indietyp commented Sep 3, 2023

I tried exactly that, but that will only give me all tasks of projects that have affected files.

@milesj
Copy link
Collaborator

milesj commented Sep 3, 2023

I can patch it to also apply affected at the task level.

@milesj
Copy link
Collaborator

milesj commented Sep 4, 2023

@indietyp Can you try 1.13?

@shellscape
Copy link

shellscape commented Sep 12, 2023

@milesj (I think this might be tangentially related) I came to the repo tonight to report that moon run :deploy --affected was not running any tasks in workflows. Do we need to pipe in touched files like outlined in #1032 (comment)?

fwiw the latest commit is always squash merged. here's how we're checking out the branch in the workflow:

      - name: Checkout Branch
        uses: actions/checkout@v2
        with:
          ref: main
          fetch-depth: 10

e.g. should we be running moon query touched-files --defaultBranch | moon run :deploy -c 1 ?

@milesj
Copy link
Collaborator

milesj commented Sep 12, 2023

@shellscape You need to use the --remote flag when running in CI. moon run was designed for local development, but people started using it in CI, so it's kind of a mix of things.

@indietyp
Copy link
Author

Sorry for the delay! It seems like it is now partially doing what I'd expected.

What I mean is the following: moon query tasks --affected

I have the projects A and B; B depends on A. I change a file in A; I'd expect that I now also need to rerun build in B (or let it at least show up), but only the tasks in A will show up (although not properly filtered) because --affected still filters on the project level and after that on the task level.

See:

let projects = query_projects(workspace, &options).await?;

if options.affected && !project.is_affected(&options.touched_files) {

@milesj
Copy link
Collaborator

milesj commented Sep 25, 2023

@indietyp So transitive deps of tasks won't show up in the affected list, as --affected is simply the list of what has literally been affected based on files changed.

However, the task runner will appropriately run upstream and downstream dependencies of affected tasks. This is automatic with moon ci but you'll need to use moon run --dependents.

This logic happens in the task runner, because it requires the dependency graph, which the affected flow does not have access to.

@indietyp
Copy link
Author

A thanks! Then this solves my problem.

Maybe a note in the docs would help?

@milesj
Copy link
Collaborator

milesj commented Sep 25, 2023

Yeah I'll update the docs.

@milesj
Copy link
Collaborator

milesj commented Sep 28, 2023

Updated the docs.

@milesj milesj closed this as completed Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants