From 4d2ccb9d34bd0420215f33998bd05a5904fa878e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 16:27:36 -0700 Subject: [PATCH 1/6] Add action. --- crates/cli/src/app.rs | 4 +- crates/cli/src/commands/graph/action.rs | 75 +++++++++++++++++++++++++ crates/cli/src/commands/graph/dep.rs | 69 +++-------------------- crates/cli/src/commands/graph/mod.rs | 1 + crates/cli/src/commands/graph/utils.rs | 2 +- 5 files changed, 88 insertions(+), 63 deletions(-) create mode 100644 crates/cli/src/commands/graph/action.rs diff --git a/crates/cli/src/app.rs b/crates/cli/src/app.rs index b38baaecf09..f7f42b5b1d2 100644 --- a/crates/cli/src/app.rs +++ b/crates/cli/src/app.rs @@ -7,7 +7,7 @@ use crate::commands::clean::CleanArgs; use crate::commands::completions::CompletionsArgs; use crate::commands::docker::DockerScaffoldArgs; use crate::commands::generate::GenerateArgs; -use crate::commands::graph::dep::DepGraphArgs; +use crate::commands::graph::action::ActionGraphArgs; use crate::commands::graph::project::ProjectGraphArgs; use crate::commands::init::InitArgs; use crate::commands::migrate::FromPackageJsonArgs; @@ -184,7 +184,7 @@ pub enum Commands { about = "Display an interactive dependency graph of all tasks and actions.", alias = "dg" )] - DepGraph(DepGraphArgs), + DepGraph(ActionGraphArgs), // moon project #[command( diff --git a/crates/cli/src/commands/graph/action.rs b/crates/cli/src/commands/graph/action.rs new file mode 100644 index 00000000000..7fe2778b092 --- /dev/null +++ b/crates/cli/src/commands/graph/action.rs @@ -0,0 +1,75 @@ +use crate::commands::graph::utils::{action_graph_repr, respond_to_request, setup_server}; +use clap::Args; +use miette::IntoDiagnostic; +use moon::{build_dep_graph, generate_project_graph}; +use moon_target::TargetLocator; +use moon_workspace::Workspace; +use starbase::{system, SystemResult}; + +#[derive(Args, Clone, Debug)] +pub struct ActionGraphArgs { + #[arg(help = "Target to *only* graph")] + target: Option, + + #[arg(long, help = "Print the graph in DOT format")] + dot: bool, + + #[arg(long, help = "Print the graph in JSON format")] + json: bool, +} + +pub async fn internal_action_graph( + args: &ActionGraphArgs, + workspace: &mut Workspace, +) -> SystemResult { + let project_graph = generate_project_graph(workspace).await?; + let mut action_graph_builder = build_dep_graph(&project_graph); + + // Focus a target and its dependencies/dependents + if let Some(locator) = args.target.clone() { + for target in action_graph_builder.run_targets_by_locator(&[locator], None)? { + action_graph_builder.run_dependents_for_target(&target)?; + } + + // Show all targets and actions + } else { + for project in project_graph.get_all_unexpanded() { + for task in project.tasks.values() { + action_graph_builder.run_target(&task.target, None)?; + } + } + } + + let action_graph = action_graph_builder.build(); + + if args.dot { + println!("{}", action_graph.to_dot()); + + return Ok(()); + } + + let graph_info = action_graph_repr(&action_graph).await; + + if args.json { + println!("{}", serde_json::to_string(&graph_info).into_diagnostic()?); + + return Ok(()); + } + + let (server, mut tera) = setup_server().await?; + let url = format!("http://{}", server.server_addr()); + let _ = open::that(&url); + + println!("Started server on {url}"); + + for req in server.incoming_requests() { + respond_to_request(req, &mut tera, &graph_info, "Action graph".to_owned())?; + } + + Ok(()) +} + +#[system] +pub async fn action_graph(args: ArgsRef, workspace: ResourceMut) { + internal_action_graph(args, workspace).await?; +} diff --git a/crates/cli/src/commands/graph/dep.rs b/crates/cli/src/commands/graph/dep.rs index 7d1921c0bbd..c1cccba5336 100644 --- a/crates/cli/src/commands/graph/dep.rs +++ b/crates/cli/src/commands/graph/dep.rs @@ -1,66 +1,15 @@ -use crate::commands::graph::utils::{dep_graph_repr, respond_to_request, setup_server}; -use clap::Args; -use miette::IntoDiagnostic; -use moon::{build_dep_graph, generate_project_graph}; -use moon_target::TargetLocator; +use super::action::*; +use moon_common::color; use moon_workspace::Workspace; use starbase::system; - -#[derive(Args, Clone, Debug)] -pub struct DepGraphArgs { - #[arg(help = "Target to *only* graph")] - target: Option, - - #[arg(long, help = "Print the graph in DOT format")] - dot: bool, - - #[arg(long, help = "Print the graph in JSON format")] - json: bool, -} +use tracing::warn; #[system] -pub async fn dep_graph(args: ArgsRef, workspace: ResourceMut) { - let project_graph = generate_project_graph(workspace).await?; - let mut dep_builder = build_dep_graph(&project_graph); - - // Focus a target and its dependencies/dependents - if let Some(locator) = args.target.clone() { - for target in dep_builder.run_targets_by_locator(&[locator], None)? { - dep_builder.run_dependents_for_target(&target)?; - } - - // Show all targets and actions - } else { - for project in project_graph.get_all_unexpanded() { - for task in project.tasks.values() { - dep_builder.run_target(&task.target, None)?; - } - } - } - - let dep_graph = dep_builder.build(); - - if args.dot { - println!("{}", dep_graph.to_dot()); - - return Ok(()); - } - - let graph_info = dep_graph_repr(&dep_graph).await; - - if args.json { - println!("{}", serde_json::to_string(&graph_info).into_diagnostic()?); - - return Ok(()); - } - - let (server, mut tera) = setup_server().await?; - let url = format!("http://{}", server.server_addr()); - let _ = open::that(&url); - - println!("Started server on {url}"); +pub async fn dep_graph(args: ArgsRef, workspace: ResourceMut) { + warn!( + "This command is deprecated. Use {} instead.", + color::shell("moon action-graph") + ); - for req in server.incoming_requests() { - respond_to_request(req, &mut tera, &graph_info, "Dependency graph".to_owned())?; - } + internal_action_graph(args, workspace).await?; } diff --git a/crates/cli/src/commands/graph/mod.rs b/crates/cli/src/commands/graph/mod.rs index c10e3a5284b..b441f32da5e 100644 --- a/crates/cli/src/commands/graph/mod.rs +++ b/crates/cli/src/commands/graph/mod.rs @@ -1,3 +1,4 @@ +pub mod action; pub mod dep; mod dto; pub mod project; diff --git a/crates/cli/src/commands/graph/utils.rs b/crates/cli/src/commands/graph/utils.rs index ea1eaf715af..ae858905abd 100644 --- a/crates/cli/src/commands/graph/utils.rs +++ b/crates/cli/src/commands/graph/utils.rs @@ -84,7 +84,7 @@ pub async fn project_graph_repr(project_graph: &ProjectGraph) -> GraphInfoDto { } /// Get a serialized representation of the dependency graph. -pub async fn dep_graph_repr(dep_graph: &DepGraph) -> GraphInfoDto { +pub async fn action_graph_repr(dep_graph: &DepGraph) -> GraphInfoDto { let labeled_graph = dep_graph.labeled_graph(); extract_nodes_and_edges_from_graph(&labeled_graph, false) } From e6b57ff004f19ec6d197c2b81f6f6741e98345dc Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 16:29:29 -0700 Subject: [PATCH 2/6] Update app. --- crates/cli/src/app.rs | 8 ++++++++ crates/cli/src/lib.rs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/app.rs b/crates/cli/src/app.rs index f7f42b5b1d2..f0d80517944 100644 --- a/crates/cli/src/app.rs +++ b/crates/cli/src/app.rs @@ -178,6 +178,14 @@ pub enum Commands { // PROJECTS + // moon action-graph [target] + #[command( + alias = "ag", + name = "action-graph", + about = "Display an interactive dependency graph of all tasks and actions." + )] + ActionGraph(ActionGraphArgs), + // moon dep-graph [target] #[command( name = "dep-graph", diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index dc23eb7d190..87bc399194b 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -15,7 +15,7 @@ use crate::commands::clean::clean; use crate::commands::completions; use crate::commands::docker; use crate::commands::generate::generate; -use crate::commands::graph::{dep::dep_graph, project::project_graph}; +use crate::commands::graph::{action::action_graph, dep::dep_graph, project::project_graph}; use crate::commands::init::init; use crate::commands::migrate; use crate::commands::node; @@ -138,6 +138,7 @@ pub async fn run_cli() -> AppResult { app.startup(systems::load_workspace); match cli.command { + Commands::ActionGraph(args) => app.execute_with_args(action_graph, args), Commands::Bin(args) => app.execute_with_args(bin, args), Commands::Ci(args) => { app.execute(systems::check_for_new_version); From 940e6310948c6a22dd65b11a9ae33174901a84ee Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 16:52:41 -0700 Subject: [PATCH 3/6] Update tests. --- crates/cli/src/app.rs | 3 +- crates/cli/tests/action_graph_test.rs | 164 ++++++++++++++++++ crates/cli/tests/dep_graph_test.rs | 158 ----------------- ...h__aliases__can_focus_using_an_alias.snap} | 2 +- ...iases__resolves_aliases_in_task_deps.snap} | 2 +- ...est__action_graph__focused_by_target.snap} | 2 +- ...action_graph__focused_by_task_in_cwd.snap} | 2 +- ...__includes_dependencies_when_focused.snap} | 2 +- ...ph__includes_dependents_when_focused.snap} | 2 +- ...aph_test__action_graph__outputs_json.snap} | 2 +- 10 files changed, 173 insertions(+), 166 deletions(-) create mode 100644 crates/cli/tests/action_graph_test.rs delete mode 100644 crates/cli/tests/dep_graph_test.rs rename crates/cli/tests/snapshots/{dep_graph_test__aliases__can_focus_using_an_alias.snap => action_graph_test__action_graph__aliases__can_focus_using_an_alias.snap} (96%) rename crates/cli/tests/snapshots/{dep_graph_test__aliases__resolves_aliases_in_task_deps.snap => action_graph_test__action_graph__aliases__resolves_aliases_in_task_deps.snap} (97%) rename crates/cli/tests/snapshots/{dep_graph_test__focused_by_task_in_cwd.snap => action_graph_test__action_graph__focused_by_target.snap} (93%) rename crates/cli/tests/snapshots/{dep_graph_test__focused_by_target.snap => action_graph_test__action_graph__focused_by_task_in_cwd.snap} (93%) rename crates/cli/tests/snapshots/{dep_graph_test__includes_dependencies_when_focused.snap => action_graph_test__action_graph__includes_dependencies_when_focused.snap} (95%) rename crates/cli/tests/snapshots/{dep_graph_test__includes_dependents_when_focused.snap => action_graph_test__action_graph__includes_dependents_when_focused.snap} (97%) rename crates/cli/tests/snapshots/{dep_graph_test__outputs_json.snap => action_graph_test__action_graph__outputs_json.snap} (90%) diff --git a/crates/cli/src/app.rs b/crates/cli/src/app.rs index f0d80517944..2eed58de202 100644 --- a/crates/cli/src/app.rs +++ b/crates/cli/src/app.rs @@ -190,7 +190,8 @@ pub enum Commands { #[command( name = "dep-graph", about = "Display an interactive dependency graph of all tasks and actions.", - alias = "dg" + alias = "dg", + hide = true )] DepGraph(ActionGraphArgs), diff --git a/crates/cli/tests/action_graph_test.rs b/crates/cli/tests/action_graph_test.rs new file mode 100644 index 00000000000..897032ae97d --- /dev/null +++ b/crates/cli/tests/action_graph_test.rs @@ -0,0 +1,164 @@ +use moon_test_utils::{ + assert_snapshot, create_sandbox_with_config, get_project_graph_aliases_fixture_configs, + get_tasks_fixture_configs, +}; + +mod action_graph { + use super::*; + + #[test] + fn all_by_default() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--dot"); + }); + + let dot = assert.output(); + + // Snapshot is not deterministic + assert_eq!(dot.split('\n').count(), 568); + } + + #[test] + fn focused_by_target() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("ag").arg("--dot").arg("basic:lint"); + }); + + assert_snapshot!(assert.output()); + } + + #[test] + fn focused_by_task_in_cwd() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--dot").arg("lint"); + cmd.current_dir(sandbox.path().join("basic")); + }); + + assert_snapshot!(assert.output()); + } + + #[test] + fn includes_dependencies_when_focused() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--dot").arg("chain:e"); + }); + + assert_snapshot!(assert.output()); + } + + #[test] + fn includes_dependents_when_focused() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--dot").arg("basic:build"); + }); + + assert_snapshot!(assert.output()); + } + + #[test] + fn outputs_json() { + let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "tasks", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--json").arg("basic:lint"); + }); + + assert_snapshot!(assert.output()); + } + + mod aliases { + use super::*; + + #[test] + fn can_focus_using_an_alias() { + let (workspace_config, toolchain_config, tasks_config) = + get_project_graph_aliases_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "project-graph/aliases", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph") + .arg("--dot") + .arg("@scope/pkg-foo:test"); + }); + + assert_snapshot!(assert.output()); + } + + #[test] + fn resolves_aliases_in_task_deps() { + let (workspace_config, toolchain_config, tasks_config) = + get_project_graph_aliases_fixture_configs(); + + let sandbox = create_sandbox_with_config( + "project-graph/aliases", + Some(workspace_config), + Some(toolchain_config), + Some(tasks_config), + ); + + let assert = sandbox.run_moon(|cmd| { + cmd.arg("action-graph").arg("--dot").arg("node:aliasDeps"); + }); + + assert_snapshot!(assert.output()); + } + } +} diff --git a/crates/cli/tests/dep_graph_test.rs b/crates/cli/tests/dep_graph_test.rs deleted file mode 100644 index b4cc902b775..00000000000 --- a/crates/cli/tests/dep_graph_test.rs +++ /dev/null @@ -1,158 +0,0 @@ -use moon_test_utils::{ - assert_snapshot, create_sandbox_with_config, get_project_graph_aliases_fixture_configs, - get_tasks_fixture_configs, -}; - -#[test] -fn all_by_default() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot"); - }); - - let dot = assert.output(); - - // Snapshot is not deterministic - assert_eq!(dot.split('\n').count(), 568); -} - -#[test] -fn focused_by_target() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("basic:lint"); - }); - - assert_snapshot!(assert.output()); -} - -#[test] -fn focused_by_task_in_cwd() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("lint"); - cmd.current_dir(sandbox.path().join("basic")); - }); - - assert_snapshot!(assert.output()); -} - -#[test] -fn includes_dependencies_when_focused() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("chain:e"); - }); - - assert_snapshot!(assert.output()); -} - -#[test] -fn includes_dependents_when_focused() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("basic:build"); - }); - - assert_snapshot!(assert.output()); -} - -#[test] -fn outputs_json() { - let (workspace_config, toolchain_config, tasks_config) = get_tasks_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "tasks", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--json").arg("basic:lint"); - }); - - assert_snapshot!(assert.output()); -} - -mod aliases { - use super::*; - - #[test] - fn can_focus_using_an_alias() { - let (workspace_config, toolchain_config, tasks_config) = - get_project_graph_aliases_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "project-graph/aliases", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("@scope/pkg-foo:test"); - }); - - assert_snapshot!(assert.output()); - } - - #[test] - fn resolves_aliases_in_task_deps() { - let (workspace_config, toolchain_config, tasks_config) = - get_project_graph_aliases_fixture_configs(); - - let sandbox = create_sandbox_with_config( - "project-graph/aliases", - Some(workspace_config), - Some(toolchain_config), - Some(tasks_config), - ); - - let assert = sandbox.run_moon(|cmd| { - cmd.arg("dep-graph").arg("--dot").arg("node:aliasDeps"); - }); - - assert_snapshot!(assert.output()); - } -} diff --git a/crates/cli/tests/snapshots/dep_graph_test__aliases__can_focus_using_an_alias.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__can_focus_using_an_alias.snap similarity index 96% rename from crates/cli/tests/snapshots/dep_graph_test__aliases__can_focus_using_an_alias.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__can_focus_using_an_alias.snap index f44262d50d1..ca6462de586 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__aliases__can_focus_using_an_alias.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__can_focus_using_an_alias.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__aliases__resolves_aliases_in_task_deps.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__resolves_aliases_in_task_deps.snap similarity index 97% rename from crates/cli/tests/snapshots/dep_graph_test__aliases__resolves_aliases_in_task_deps.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__resolves_aliases_in_task_deps.snap index d186394e820..48d5317a03a 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__aliases__resolves_aliases_in_task_deps.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__aliases__resolves_aliases_in_task_deps.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__focused_by_task_in_cwd.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_target.snap similarity index 93% rename from crates/cli/tests/snapshots/dep_graph_test__focused_by_task_in_cwd.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_target.snap index 97327f0d549..83966a2ce42 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__focused_by_task_in_cwd.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_target.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__focused_by_target.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_task_in_cwd.snap similarity index 93% rename from crates/cli/tests/snapshots/dep_graph_test__focused_by_target.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_task_in_cwd.snap index 97327f0d549..83966a2ce42 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__focused_by_target.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__focused_by_task_in_cwd.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__includes_dependencies_when_focused.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependencies_when_focused.snap similarity index 95% rename from crates/cli/tests/snapshots/dep_graph_test__includes_dependencies_when_focused.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependencies_when_focused.snap index 3dd11d10b8c..98dcdfe1ac2 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__includes_dependencies_when_focused.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependencies_when_focused.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__includes_dependents_when_focused.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependents_when_focused.snap similarity index 97% rename from crates/cli/tests/snapshots/dep_graph_test__includes_dependents_when_focused.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependents_when_focused.snap index e0cf39256be..12f095418da 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__includes_dependents_when_focused.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__includes_dependents_when_focused.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- digraph { diff --git a/crates/cli/tests/snapshots/dep_graph_test__outputs_json.snap b/crates/cli/tests/snapshots/action_graph_test__action_graph__outputs_json.snap similarity index 90% rename from crates/cli/tests/snapshots/dep_graph_test__outputs_json.snap rename to crates/cli/tests/snapshots/action_graph_test__action_graph__outputs_json.snap index 5758c460cc9..534f5387238 100644 --- a/crates/cli/tests/snapshots/dep_graph_test__outputs_json.snap +++ b/crates/cli/tests/snapshots/action_graph_test__action_graph__outputs_json.snap @@ -1,5 +1,5 @@ --- -source: crates/cli/tests/dep_graph_test.rs +source: crates/cli/tests/action_graph_test.rs expression: assert.output() --- {"nodes":[{"id":2,"label":"InstallNodeDeps(18.0.0)"},{"id":4,"label":"RunTarget(basic:lint)"},{"id":1,"label":"SetupNodeTool(18.0.0)"},{"id":3,"label":"SyncNodeProject(basic)"}],"edges":[{"id":"2 -> 1","label":"","source":2,"target":1},{"id":"3 -> 1","label":"","source":3,"target":1},{"id":"4 -> 2","label":"","source":4,"target":2},{"id":"4 -> 3","label":"","source":4,"target":3}]} From 92746a5be0efece2b2bbe44ddd2e8126f2310511 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 16:56:30 -0700 Subject: [PATCH 4/6] Update docs. --- website/blog/2022-12-19_v0.21.mdx | 2 +- .../commands/{dep-graph.mdx => action-graph.mdx} | 14 +++++++------- website/docusaurus.config.js | 4 ++++ website/sidebars.js | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) rename website/docs/commands/{dep-graph.mdx => action-graph.mdx} (72%) diff --git a/website/blog/2022-12-19_v0.21.mdx b/website/blog/2022-12-19_v0.21.mdx index d44c09c073a..0351aded720 100644 --- a/website/blog/2022-12-19_v0.21.mdx +++ b/website/blog/2022-12-19_v0.21.mdx @@ -84,7 +84,7 @@ tasks: Thanks to the amazing contribution from [Diptesh Choudhuri](https://github.com/IgnisDa), we now have interactive project and dependency graphs when running the [`moon project-graph`](../docs/commands/project-graph) and -[`moon dep-graph`](../docs/commands/dep-graph) commands respectively. +[`moon dep-graph`](../docs/commands/action-graph) commands respectively. This is only the first iteration of these graphs. Expect more advanced features in the future, like filtering, node/edge inspection, exporting, and more! diff --git a/website/docs/commands/dep-graph.mdx b/website/docs/commands/action-graph.mdx similarity index 72% rename from website/docs/commands/dep-graph.mdx rename to website/docs/commands/action-graph.mdx index 7ed5439c1eb..2ba12c64f57 100644 --- a/website/docs/commands/dep-graph.mdx +++ b/website/docs/commands/action-graph.mdx @@ -1,21 +1,21 @@ --- -title: dep-graph +title: action-graph --- -The `moon dep-graph [target]` (or `moon dg`) command will generate and serve a visual dependency -graph of all actions, targets, and tasks within the workspace, and can also output the graph in -[Graphviz DOT format](https://graphviz.org/doc/info/lang.html). +The `moon action-graph [target]` (or `moon ag`) command will generate and serve a visual dependency +graph of all actions and tasks within the workspace, known as the +[action graph](../how-it-works/action-graph). ```shell # Run the visualizer locally -$ moon dep-graph +$ moon action-graph # Export to DOT format -$ moon dep-graph --dot > graph.dot +$ moon action-graph --dot > graph.dot ``` > A target can be passed to focus the graph, including dependencies _and_ dependents. For example, -> `moon dep-graph app:build`. +> `moon action-graph app:build`. ### Arguments diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index aa683167fb3..da26a1e6919 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -227,6 +227,10 @@ const config = { from: '/docs/guides/git-hooks', to: '/docs/guides/vcs-hooks', }, + { + from: '/docs/commands/dep-graph', + to: '/docs/commands/action-graph', + }, ], }, ], diff --git a/website/sidebars.js b/website/sidebars.js index d9cfca902b6..389845a1d4a 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -97,12 +97,12 @@ const sidebars = { label: 'Commands', items: [ 'commands/overview', + 'commands/action-graph', 'commands/bin', 'commands/ci', 'commands/check', 'commands/clean', 'commands/completions', - 'commands/dep-graph', { type: 'category', label: 'docker', From c7e5fd1e6c2206e1e6bd290a49bea4cff426b30b Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 17:01:44 -0700 Subject: [PATCH 5/6] Polish. --- .github/workflows/benchmark.yml | 10 +++++----- website/docusaurus.config.js | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7dee6594a53..0b0f66c4f3f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest # strategy: # matrix: - # bench: [dep_graph_benchmark, emitter_benchmark, pipeline_benchmark] + # bench: [emitter_benchmark, pipeline_benchmark] # fail-fast: false steps: - run: echo ${{ github.event.pull_request.head.sha }} @@ -37,8 +37,8 @@ jobs: - name: Run benchmarks # args: --workspace --bench ${{ matrix.bench }} -- --save-baseline base-sha run: - cargo bench --workspace --bench dep_graph_benchmark --bench emitter_benchmark --bench - pipeline_benchmark --bench tar_benchmark -- --save-baseline head-sha + cargo bench --workspace --bench emitter_benchmark --bench pipeline_benchmark --bench + tar_benchmark -- --save-baseline head-sha # Run on base branch to get a baseline - name: Checkout base branch @@ -49,8 +49,8 @@ jobs: - name: Run benchmarks # args: --workspace --bench ${{ matrix.bench }} -- --save-baseline base-sha run: - cargo bench --workspace --bench dep_graph_benchmark --bench emitter_benchmark --bench - pipeline_benchmark --bench tar_benchmark -- --save-baseline base-sha + cargo bench --workspace --bench emitter_benchmark --bench pipeline_benchmark --bench + tar_benchmark -- --save-baseline base-sha # Compare diffs - name: Install critcmp diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index da26a1e6919..e33332855d9 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -215,6 +215,10 @@ const config = { from: '/docs/how-it-works/dep-graph', to: '/docs/how-it-works/action-graph', }, + { + from: '/docs/commands/dep-graph', + to: '/docs/commands/action-graph', + }, { from: '/docs/config/global-project', to: '/docs/config/tasks', @@ -227,10 +231,6 @@ const config = { from: '/docs/guides/git-hooks', to: '/docs/guides/vcs-hooks', }, - { - from: '/docs/commands/dep-graph', - to: '/docs/commands/action-graph', - }, ], }, ], From 3edc6a13ec4c28c5d997abca0431f861e22ea91e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 6 Oct 2023 17:07:05 -0700 Subject: [PATCH 6/6] Polish. --- website/docs/commands/action-graph.mdx | 7 ++++--- website/sidebars.js | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/website/docs/commands/action-graph.mdx b/website/docs/commands/action-graph.mdx index 2ba12c64f57..bc4e517d171 100644 --- a/website/docs/commands/action-graph.mdx +++ b/website/docs/commands/action-graph.mdx @@ -2,9 +2,10 @@ title: action-graph --- -The `moon action-graph [target]` (or `moon ag`) command will generate and serve a visual dependency -graph of all actions and tasks within the workspace, known as the -[action graph](../how-it-works/action-graph). +The `moon action-graph [target]` (or `moon ag`) command will generate and serve a visual graph of +all actions and tasks within the workspace, known as the +[action graph](../how-it-works/action-graph). In other tools, this is sometimes referred to as a +dependency graph or task graph. ```shell # Run the visualizer locally diff --git a/website/sidebars.js b/website/sidebars.js index 389845a1d4a..346a5822d06 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -21,8 +21,10 @@ const sidebars = { 'mental-model', 'languages', 'project-graph', + 'action-graph', 'dep-graph', 'dependency-graph', + 'task-graph', ], }, },