diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca4e6e398e..d5493186f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed an issue where token expansion would clobber variable replacement when multiple variables are used. +- Fixed internal tasks being displayed in `moon query` results. ## 1.27.4 diff --git a/crates/action-graph/src/action_graph_builder.rs b/crates/action-graph/src/action_graph_builder.rs index f9305953a19..ee47193058d 100644 --- a/crates/action-graph/src/action_graph_builder.rs +++ b/crates/action-graph/src/action_graph_builder.rs @@ -321,6 +321,7 @@ impl<'app> ActionGraphBuilder<'app> { } for project in projects_to_build { + // Include internal tasks! for dep_task in project.tasks.values() { // Don't skip internal tasks, since they are a dependency of the parent // task, and must still run! They just can't be ran manually. diff --git a/crates/app/src/commands/docker/file.rs b/crates/app/src/commands/docker/file.rs index f1cc26ab09a..fa1ad79c4fd 100644 --- a/crates/app/src/commands/docker/file.rs +++ b/crates/app/src/commands/docker/file.rs @@ -87,7 +87,7 @@ pub async fn file(session: CliSession, args: DockerFileArgs) -> AppResult { } else if args.defaults { project.config.docker.file.build_task.as_ref() } else { - let mut ids = project.tasks.keys().collect::>(); + let mut ids = project.get_task_ids()?; ids.sort(); let starting_cursor = project @@ -120,7 +120,7 @@ pub async fn file(session: CliSession, args: DockerFileArgs) -> AppResult { } else if args.defaults { project.config.docker.file.start_task.as_ref() } else { - let mut ids = project.tasks.keys().collect::>(); + let mut ids = project.get_task_ids()?; ids.sort(); let starting_cursor = project diff --git a/crates/app/src/commands/graph/action.rs b/crates/app/src/commands/graph/action.rs index 77291e4e45d..32926e0a75c 100644 --- a/crates/app/src/commands/graph/action.rs +++ b/crates/app/src/commands/graph/action.rs @@ -42,7 +42,7 @@ pub async fn action_graph(session: CliSession, args: ActionGraphArgs) -> AppResu // Show all targets and actions } else { for project in project_graph.get_all()? { - for task in project.tasks.values() { + for task in project.get_tasks()? { action_graph_builder.run_task(&project, task, &requirements)?; } } diff --git a/crates/app/src/commands/project.rs b/crates/app/src/commands/project.rs index 758a1a7556c..049e07222f3 100644 --- a/crates/app/src/commands/project.rs +++ b/crates/app/src/commands/project.rs @@ -128,17 +128,13 @@ pub async fn project(session: CliSession, args: ProjectArgs) -> AppResult { } } - if !project.tasks.is_empty() { - console.print_entry_header("Tasks")?; - - for name in project.tasks.keys() { - let task = project.tasks.get(name).unwrap(); + let tasks = project.get_tasks()?; - if task.is_internal() { - continue; - } + if !tasks.is_empty() { + console.print_entry_header("Tasks")?; - console.print_entry(name, "")?; + for task in tasks { + console.print_entry(&task.id, "")?; console.write_line(format!( " {} {}", diff --git a/crates/app/src/commands/query.rs b/crates/app/src/commands/query.rs index 00757a212ed..0f81de04c88 100644 --- a/crates/app/src/commands/query.rs +++ b/crates/app/src/commands/query.rs @@ -302,11 +302,11 @@ pub async fn tasks(session: CliSession, args: QueryTasksArgs) -> AppResult { for project in projects { let filtered_tasks = project - .tasks - .iter() - .filter_map(|(task_id, task)| { + .get_tasks()? + .into_iter() + .filter_map(|task| { if !args.affected || task.is_affected(&touched_files).is_ok_and(|v| v) { - Some((task_id.to_owned(), task.to_owned())) + Some((task.id.to_owned(), task.to_owned())) } else { None } diff --git a/crates/app/src/queries/projects.rs b/crates/app/src/queries/projects.rs index 88edf29291a..c8de8c46bf2 100644 --- a/crates/app/src/queries/projects.rs +++ b/crates/app/src/queries/projects.rs @@ -167,7 +167,10 @@ fn load_with_regex( } if let Some(regex) = &tasks_regex { - let has_task = project.tasks.keys().any(|task_id| regex.is_match(task_id)); + let has_task = project + .get_task_ids()? + .iter() + .any(|task_id| regex.is_match(&task_id)); if !has_task { continue; diff --git a/crates/cli/tests/query_test.rs b/crates/cli/tests/query_test.rs index 2348359d126..b4c6f4b7f5b 100644 --- a/crates/cli/tests/query_test.rs +++ b/crates/cli/tests/query_test.rs @@ -714,7 +714,7 @@ mod tasks { projects.sort(); - assert_eq!(tasks, string_vec!["internal", "lint", "test"]); + assert_eq!(tasks, string_vec!["lint", "test"]); assert_eq!(projects, string_vec!["metadata", "platforms", "tasks"]); } } diff --git a/crates/cli/tests/snapshots/query_test__tasks__returns_all_by_default.snap b/crates/cli/tests/snapshots/query_test__tasks__returns_all_by_default.snap index 20a0292de12..bfe451df733 100644 --- a/crates/cli/tests/snapshots/query_test__tasks__returns_all_by_default.snap +++ b/crates/cli/tests/snapshots/query_test__tasks__returns_all_by_default.snap @@ -9,6 +9,5 @@ platforms :node | node :system | noop tasks - :internal | build :lint | eslint :test | jest diff --git a/crates/project-expander/src/tasks_expander.rs b/crates/project-expander/src/tasks_expander.rs index 1574e644495..a96401a3908 100644 --- a/crates/project-expander/src/tasks_expander.rs +++ b/crates/project-expander/src/tasks_expander.rs @@ -97,6 +97,7 @@ impl<'graph, 'query> TasksExpander<'graph, 'query> { dep: &TaskDependencyConfig, skip_if_missing: bool| -> miette::Result<()> { + // Allow internal tasks! let Some(dep_task) = dep_project.tasks.get(&dep.target.task_id) else { if skip_if_missing { return Ok(()); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 4ed0494cc83..a53894c97bc 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -89,12 +89,25 @@ impl Project { Ok(task) } - /// Return all tasks within the project. + /// Return a list of all visible task IDs. + pub fn get_task_ids(&self) -> miette::Result> { + Ok(self + .get_tasks()? + .iter() + .map(|task| &task.id) + .collect::>()) + } + + /// Return all visible tasks within the project. Does not include internal tasks! pub fn get_tasks(&self) -> miette::Result> { let mut tasks = vec![]; for task_id in self.tasks.keys() { - tasks.push(self.get_task(task_id)?); + let task = self.get_task(task_id)?; + + if !task.is_internal() { + tasks.push(task); + } } Ok(tasks)