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

chore: remove fake root topological task nodes #5828

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cli/internal/core/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ func (e *Engine) Prepare(options *EngineBuildingOptions) error {

// hasTopoDeps will be true if the task depends on any tasks from dependency packages
// E.g. `dev: { dependsOn: [^dev] }`
hasTopoDeps := topoDeps.Len() > 0 && e.completeGraph.WorkspaceGraph.DownEdges(pkg).Len() > 0
nonRootDepPkgs := e.completeGraph.WorkspaceGraph.DownEdges(pkg).Filter(func(node interface{}) bool {
if packageName, ok := node.(string); ok {
return packageName != ROOT_NODE_NAME
}
return true
})
hasTopoDeps := topoDeps.Len() > 0 && nonRootDepPkgs.Len() > 0

// hasDeps will be true if the task depends on any tasks from its own package
// E.g. `build: { dependsOn: [dev] }`
Expand All @@ -380,10 +386,9 @@ func (e *Engine) Prepare(options *EngineBuildingOptions) error {
}

if hasTopoDeps {
depPkgs := e.completeGraph.WorkspaceGraph.DownEdges(pkg)
for _, from := range topoDeps.UnsafeListOfStrings() {
// add task dep from all the package deps within repo
for depPkg := range depPkgs {
for depPkg := range nonRootDepPkgs {
fromTaskID := util.GetTaskId(depPkg, from)
e.TaskGraph.Add(fromTaskID)
e.TaskGraph.Add(toTaskID)
Expand Down
11 changes: 2 additions & 9 deletions turborepo-tests/integration/tests/task-dependencies/complex.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ We can scope the run to specific packages
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] ___ROOT___#build1" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-b#build1" -> "[root] lib-b#build1" (esc)
\t\t"[root] app-b#build1" -> "[root] lib-c#build1" (esc)
\t\t"[root] lib-b#build1" -> "[root] lib-d#build1" (esc)
\t\t"[root] lib-c#build1" -> "[root] ___ROOT___#build1" (esc)
\t\t"[root] lib-d#build1" -> "[root] ___ROOT___#build1" (esc)
\t\t"[root] lib-c#build1" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-d#build1" -> "[root] ___ROOT___" (esc)
\t} (esc)
}

Expand All @@ -53,8 +52,6 @@ Complex dependency chain
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] ___ROOT___#build0" -> "[root] ___ROOT___#prepare" (esc)
\t\t"[root] ___ROOT___#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-a#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] app-a#test" -> "[root] app-a#prepare" (esc)
\t\t"[root] app-a#test" -> "[root] lib-a#build0" (esc)
Expand All @@ -72,15 +69,11 @@ Complex dependency chain
\t\t"[root] lib-b#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-b#test" -> "[root] lib-b#prepare" (esc)
\t\t"[root] lib-b#test" -> "[root] lib-d#build0" (esc)
\t\t"[root] lib-c#build0" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-c#build0" -> "[root] lib-c#prepare" (esc)
\t\t"[root] lib-c#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-c#test" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-c#test" -> "[root] lib-c#prepare" (esc)
\t\t"[root] lib-d#build0" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-d#build0" -> "[root] lib-d#prepare" (esc)
\t\t"[root] lib-d#prepare" -> "[root] ___ROOT___" (esc)
\t\t"[root] lib-d#test" -> "[root] ___ROOT___#build0" (esc)
\t\t"[root] lib-d#test" -> "[root] lib-d#prepare" (esc)
\t} (esc)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ Graph
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] //#build" -> "[root] ___ROOT___" (esc)
\t\t"[root] ___ROOT___#build" -> "[root] ___ROOT___" (esc)
\t\t"[root] my-app#build" -> "[root] util#build" (esc)
\t\t"[root] util#build" -> "[root] ___ROOT___#build" (esc)
\t\t"[root] util#build" -> "[root] ___ROOT___" (esc)
\t} (esc)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Can depend on root tasks
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] //#exists" -> "[root] ___ROOT___" (esc)
\t\t"[root] ___ROOT___#build2" -> "[root] //#exists" (esc)
\t\t"[root] workspace-a#build2" -> "[root] //#exists" (esc)
\t\t"[root] workspace-a#build2" -> "[root] workspace-b#build2" (esc)
\t\t"[root] workspace-b#build2" -> "[root] //#exists" (esc)
\t\t"[root] workspace-b#build2" -> "[root] ___ROOT___#build2" (esc)
\t} (esc)
}

Expand All @@ -50,9 +48,8 @@ Package tasks can depend on things
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] ___ROOT___#build4" -> "[root] ___ROOT___" (esc)
\t\t"[root] workspace-a#special" -> "[root] workspace-b#build4" (esc)
\t\t"[root] workspace-b#build4" -> "[root] ___ROOT___#build4" (esc)
\t\t"[root] workspace-b#build4" -> "[root] ___ROOT___" (esc)
\t} (esc)
}

Expand Down
Loading