diff --git a/crates/node/platform/tests/project_aliases_test.rs b/crates/node/platform/tests/project_aliases_test.rs index 48b53048d5b..f661bcacd7a 100644 --- a/crates/node/platform/tests/project_aliases_test.rs +++ b/crates/node/platform/tests/project_aliases_test.rs @@ -30,18 +30,12 @@ async fn loads_node_aliases_name_scopes() { assert_eq!( graph.aliases(), FxHashMap::from_iter([ - ( - "project-graph-aliases-explicit", - &Id::raw("explicit") - ), + ("project-graph-aliases-explicit", &Id::raw("explicit")), ( "project-graph-aliases-explicit-and-implicit", &Id::raw("explicitAndImplicit") ), - ( - "project-graph-aliases-implicit", - &Id::raw("implicit") - ), + ("project-graph-aliases-implicit", &Id::raw("implicit")), ("project-graph-aliases-node", &Id::raw("node")), ("pkg-bar", &Id::raw("nodeNameOnly")), ("@scope/pkg-foo", &Id::raw("nodeNameScope")) diff --git a/nextgen/file-group/src/file_group.rs b/nextgen/file-group/src/file_group.rs index bf17f97919b..3a75ff1ea86 100644 --- a/nextgen/file-group/src/file_group.rs +++ b/nextgen/file-group/src/file_group.rs @@ -173,6 +173,8 @@ impl FileGroup { } } + list.sort(); + Ok(list) } } diff --git a/nextgen/project-expander/tests/tasks_expander_test.rs b/nextgen/project-expander/tests/tasks_expander_test.rs index a37b9415f2c..153d9e0565e 100644 --- a/nextgen/project-expander/tests/tasks_expander_test.rs +++ b/nextgen/project-expander/tests/tasks_expander_test.rs @@ -114,9 +114,9 @@ mod tasks_expander { [ "a", "./config.yml", + "./dir/subdir/nested.json", "./docs.md", "./other/file.json", - "./dir/subdir/nested.json", "b" ] ); @@ -139,9 +139,9 @@ mod tasks_expander { [ "a", "./project/source/config.yml", + "./project/source/dir/subdir/nested.json", "./project/source/docs.md", "./project/source/other/file.json", - "./project/source/dir/subdir/nested.json", "b" ] ); @@ -960,6 +960,7 @@ mod tasks_expander { )] fn errors_overlapping_file() { env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS"); + env::remove_var("MOON_TEST"); let sandbox = create_sandbox("file-group"); let project = create_project(sandbox.path()); @@ -978,6 +979,8 @@ mod tasks_expander { TasksExpander::new(&context) .expand_outputs(&mut task, &mut boundaries) .unwrap(); + + env::set_var("MOON_TEST", "true"); } #[test] @@ -986,6 +989,7 @@ mod tasks_expander { )] fn errors_overlapping_glob() { env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS"); + env::remove_var("MOON_TEST"); let sandbox = create_sandbox("file-group"); let project = create_project(sandbox.path()); @@ -1005,6 +1009,8 @@ mod tasks_expander { TasksExpander::new(&context) .expand_outputs(&mut task, &mut boundaries) .unwrap(); + + env::set_var("MOON_TEST", "true"); } #[test] @@ -1013,6 +1019,7 @@ mod tasks_expander { )] fn errors_overlapping_glob_matching_file() { env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS"); + env::remove_var("MOON_TEST"); let sandbox = create_sandbox("file-group"); let project = create_project(sandbox.path()); @@ -1032,6 +1039,8 @@ mod tasks_expander { TasksExpander::new(&context) .expand_outputs(&mut task, &mut boundaries) .unwrap(); + + env::set_var("MOON_TEST", "true"); } } } diff --git a/nextgen/project-expander/tests/token_expander_test.rs b/nextgen/project-expander/tests/token_expander_test.rs index 5bfdb3b478c..655460ce9bc 100644 --- a/nextgen/project-expander/tests/token_expander_test.rs +++ b/nextgen/project-expander/tests/token_expander_test.rs @@ -83,6 +83,7 @@ mod token_expander { mod vars { use super::*; + #[test] fn replaces_variables() { let sandbox = create_empty_sandbox(); @@ -329,8 +330,8 @@ mod token_expander { expander.expand_inputs(&task).unwrap(), ( vec![ + WorkspaceRelativePathBuf::from("project/source/dir/subdir"), WorkspaceRelativePathBuf::from("project/source/other"), - WorkspaceRelativePathBuf::from("project/source/dir/subdir") ], vec![] ) @@ -353,9 +354,9 @@ mod token_expander { ( vec![ WorkspaceRelativePathBuf::from("project/source/config.yml"), + WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"), WorkspaceRelativePathBuf::from("project/source/docs.md"), WorkspaceRelativePathBuf::from("project/source/other/file.json"), - WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"), ], vec![] ) @@ -561,8 +562,8 @@ mod token_expander { expander.expand_outputs(&task).unwrap(), ( vec![ + WorkspaceRelativePathBuf::from("project/source/dir/subdir"), WorkspaceRelativePathBuf::from("project/source/other"), - WorkspaceRelativePathBuf::from("project/source/dir/subdir") ], vec![] ) @@ -585,9 +586,9 @@ mod token_expander { ( vec![ WorkspaceRelativePathBuf::from("project/source/config.yml"), + WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"), WorkspaceRelativePathBuf::from("project/source/docs.md"), WorkspaceRelativePathBuf::from("project/source/other/file.json"), - WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"), ], vec![] ) diff --git a/nextgen/project-graph/src/project_graph.rs b/nextgen/project-graph/src/project_graph.rs index 5d1b67e39ec..9256e6332be 100644 --- a/nextgen/project-graph/src/project_graph.rs +++ b/nextgen/project-graph/src/project_graph.rs @@ -319,6 +319,9 @@ impl ProjectGraph { } } + // Sort so that the order is deterministic + project_ids.sort(); + Ok(project_ids) }) } diff --git a/nextgen/project-graph/src/projects_locator.rs b/nextgen/project-graph/src/projects_locator.rs index 78757d7e126..f0d96723d11 100644 --- a/nextgen/project-graph/src/projects_locator.rs +++ b/nextgen/project-graph/src/projects_locator.rs @@ -51,7 +51,10 @@ where } // Glob for all other projects - for project_root in glob::walk(workspace_root, &globs)? { + let mut potential_projects = glob::walk(workspace_root, &globs)?; + potential_projects.sort(); + + for project_root in potential_projects { if project_root.is_dir() { let project_source = to_virtual_string(project_root.strip_prefix(workspace_root).unwrap())?; diff --git a/nextgen/project-graph/tests/project_graph_test.rs b/nextgen/project-graph/tests/project_graph_test.rs index 05408b6b39b..1836f26fffb 100644 --- a/nextgen/project-graph/tests/project_graph_test.rs +++ b/nextgen/project-graph/tests/project_graph_test.rs @@ -736,8 +736,8 @@ mod project_graph { assert_eq!( task.deps, [ - Target::parse("tag-three:test").unwrap(), Target::parse("tag-one:test").unwrap(), + Target::parse("tag-three:test").unwrap(), ] ); } diff --git a/nextgen/project-graph/tests/snapshots/project_graph_test__project_graph__aliases__loads_aliases.snap b/nextgen/project-graph/tests/snapshots/project_graph_test__project_graph__aliases__loads_aliases.snap index fd8766eb465..3128ab517e1 100644 --- a/nextgen/project-graph/tests/snapshots/project_graph_test__project_graph__aliases__loads_aliases.snap +++ b/nextgen/project-graph/tests/snapshots/project_graph_test__project_graph__aliases__loads_aliases.snap @@ -3,22 +3,22 @@ source: nextgen/project-graph/tests/project_graph_test.rs expression: graph.to_dot() --- digraph { - 0 [ label="alias-one" style=filled, shape=oval, fillcolor=gray, fontcolor=black] + 0 [ label="tasks" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 1 [ label="alias-three" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 2 [ label="dupes-task-deps" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 3 [ label="alias-two" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 4 [ label="dupes-depends-on" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 5 [ label="explicit-and-implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black] - 6 [ label="implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black] - 7 [ label="explicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black] - 8 [ label="tasks" style=filled, shape=oval, fillcolor=gray, fontcolor=black] + 6 [ label="alias-one" style=filled, shape=oval, fillcolor=gray, fontcolor=black] + 7 [ label="implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black] + 8 [ label="explicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black] 4 -> 3 [ label="development" arrowhead=box, arrowtail=box] 4 -> 3 [ label="build" arrowhead=box, arrowtail=box] 5 -> 3 [ label="development" arrowhead=box, arrowtail=box] 5 -> 1 [ label="build" arrowhead=box, arrowtail=box] - 6 -> 0 [ label="peer" arrowhead=box, arrowtail=box] - 6 -> 1 [ label="build" arrowhead=box, arrowtail=box] - 7 -> 3 [ label="production" arrowhead=box, arrowtail=box] - 7 -> 0 [ label="development" arrowhead=box, arrowtail=box] + 7 -> 6 [ label="peer" arrowhead=box, arrowtail=box] + 7 -> 1 [ label="build" arrowhead=box, arrowtail=box] + 8 -> 3 [ label="production" arrowhead=box, arrowtail=box] + 8 -> 6 [ label="development" arrowhead=box, arrowtail=box] }