From e81d37db31c086c4553e6310f40c4fb6020374a0 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 16 Jan 2024 16:38:47 -0600 Subject: [PATCH 1/7] fix(turbo): sort dependents and dependencies during normalization --- crates/turborepo-lib/src/run/summary/mod.rs | 10 ++++++++-- crates/turborepo-lib/src/run/summary/task.rs | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index 6c006dd6f9d35..aa8ab2386776e 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -347,13 +347,13 @@ struct SinglePackageRunSummary<'a> { impl<'a> From<&'a RunSummary<'a>> for SinglePackageRunSummary<'a> { fn from(run_summary: &'a RunSummary<'a>) -> Self { - let mut tasks = run_summary + let ks = run_summary .tasks .iter() .cloned() .map(SinglePackageTaskSummary::from) .collect::>(); - tasks.sort_by(|t1, t2| t1.task_id.cmp(&t2.task_id)); + SinglePackageRunSummary { id: run_summary.id, version: &run_summary.version, @@ -768,6 +768,12 @@ impl<'a> RunSummary<'a> { } self.tasks.sort_by(|a, b| a.task_id.cmp(&b.task_id)); + + // Sort dependencies + for task in &mut self.tasks { + task.shared.dependencies.sort_by(|d1, d2| d1.cmp(&d2)); + task.shared.dependents.sort_by(|d1, d2| d1.cmp(&d2)); + } } fn get_path(&self) -> AbsoluteSystemPathBuf { diff --git a/crates/turborepo-lib/src/run/summary/task.rs b/crates/turborepo-lib/src/run/summary/task.rs index 73b07625ef338..68f72afcfe8e5 100644 --- a/crates/turborepo-lib/src/run/summary/task.rs +++ b/crates/turborepo-lib/src/run/summary/task.rs @@ -251,12 +251,10 @@ impl From>> for SharedTaskSummary { dependencies: dependencies .into_iter() .map(|task_id| task_id.task().to_string()) - .sorted() .collect(), dependents: dependents .into_iter() .map(|task_id| task_id.task().to_string()) - .sorted() .collect(), resolved_task_definition, framework, From 19ab03e733e8ac9841cf8c8723e657caafb3d6c8 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 16 Jan 2024 16:40:25 -0600 Subject: [PATCH 2/7] oops --- crates/turborepo-lib/src/run/summary/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index aa8ab2386776e..caf599ae95806 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -347,7 +347,7 @@ struct SinglePackageRunSummary<'a> { impl<'a> From<&'a RunSummary<'a>> for SinglePackageRunSummary<'a> { fn from(run_summary: &'a RunSummary<'a>) -> Self { - let ks = run_summary + let tasks = run_summary .tasks .iter() .cloned() From 1848f9b5fd4513dfa16677e7ec340c68e5e0f5de Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Wed, 17 Jan 2024 13:35:00 -0600 Subject: [PATCH 3/7] Update crates/turborepo-lib/src/run/summary/mod.rs Co-authored-by: Chris Olszewski --- crates/turborepo-lib/src/run/summary/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index caf599ae95806..7edda71545830 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -771,8 +771,8 @@ impl<'a> RunSummary<'a> { // Sort dependencies for task in &mut self.tasks { - task.shared.dependencies.sort_by(|d1, d2| d1.cmp(&d2)); - task.shared.dependents.sort_by(|d1, d2| d1.cmp(&d2)); + task.shared.dependencies.sort(); + task.shared.dependents.sort(); } } From 0df187ade13beefea3023acaf27e39e2d6cfe66d Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Fri, 19 Jan 2024 15:39:18 -0600 Subject: [PATCH 4/7] bring back task sorting when converting to single package summary --- crates/turborepo-lib/src/run/summary/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index 7edda71545830..69952e3d9b46a 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -347,13 +347,13 @@ struct SinglePackageRunSummary<'a> { impl<'a> From<&'a RunSummary<'a>> for SinglePackageRunSummary<'a> { fn from(run_summary: &'a RunSummary<'a>) -> Self { - let tasks = run_summary + let mut tasks = run_summary .tasks .iter() .cloned() .map(SinglePackageTaskSummary::from) .collect::>(); - + tasks.sort_by(|t1, t2| t1.task_id.cmp(&t2.task_id)); SinglePackageRunSummary { id: run_summary.id, version: &run_summary.version, From 159695bee9c19ddb6c63357ac01cf36ad642b31c Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Fri, 19 Jan 2024 17:01:56 -0600 Subject: [PATCH 5/7] test --- .../fixtures/task_dependencies/topological/README.md | 1 + .../topological/apps/my-app/package.json | 1 + .../topological/packages/another/package.json | 6 ++++++ .../topological/packages/util/package.json | 2 +- .../integration/tests/run-summary/sorting.t | 11 +++++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 turborepo-tests/integration/fixtures/task_dependencies/topological/README.md create mode 100644 turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json create mode 100644 turborepo-tests/integration/tests/run-summary/sorting.t diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/README.md b/turborepo-tests/integration/fixtures/task_dependencies/topological/README.md new file mode 100644 index 0000000000000..7af988706a519 --- /dev/null +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/README.md @@ -0,0 +1 @@ +My Monorepo diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json b/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json index 162bcddf217ef..6ceceb5d922a2 100644 --- a/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json @@ -4,6 +4,7 @@ "build": "echo building" }, "dependencies": { + "another": "*", "util": "*" } } diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json new file mode 100644 index 0000000000000..eb2aac6a1f946 --- /dev/null +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json @@ -0,0 +1,6 @@ +{ + "name": "another", + "scripts": { + "build": "echo building-another" + } +} diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json index 7309726a1df4e..3d6638374a14c 100644 --- a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "util", "scripts": { - "build": "echo building" + "build": "echo building-util" } } diff --git a/turborepo-tests/integration/tests/run-summary/sorting.t b/turborepo-tests/integration/tests/run-summary/sorting.t new file mode 100644 index 0000000000000..0fe204c9021ad --- /dev/null +++ b/turborepo-tests/integration/tests/run-summary/sorting.t @@ -0,0 +1,11 @@ + $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "task_dependencies/topological" + $ source "$TESTDIR/../_helpers/run-summary-utils.sh" + + $ rm -rf .turbo/runs + $ git commit --quiet -am "new sha" --allow-empty && ${TURBO} run build --summarize > /dev/null 2>&1 + $ SUMMARY=$(/bin/ls .turbo/runs/*.json | head -n1) + $ getSummaryTaskId $SUMMARY "my-app#build" | jq .dependencies + [ + "another#build", + "util#build" + ] From c257a837c5ab3fcc42f0f2a5c27b3bfe63e90be7 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 23 Jan 2024 15:16:18 -0600 Subject: [PATCH 6/7] just use another fixture --- .../topological/apps/my-app/package.json | 1 - .../topological/packages/util/package.json | 2 +- .../integration/fixtures/with_pkg_deps/.gitignore | 3 +++ .../topological => with_pkg_deps}/README.md | 0 .../fixtures/with_pkg_deps/apps/my-app/package.json | 10 ++++++++++ .../integration/fixtures/with_pkg_deps/package.json | 7 +++++++ .../packages/another/package.json | 0 .../fixtures/with_pkg_deps/packages/util/package.json | 6 ++++++ .../integration/fixtures/with_pkg_deps/turbo.json | 11 +++++++++++ .../tests/run-summary/{sorting.t => sorting-deps.t} | 2 +- 10 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore rename turborepo-tests/integration/fixtures/{task_dependencies/topological => with_pkg_deps}/README.md (100%) create mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json create mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/package.json rename turborepo-tests/integration/fixtures/{task_dependencies/topological => with_pkg_deps}/packages/another/package.json (100%) create mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json create mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json rename turborepo-tests/integration/tests/run-summary/{sorting.t => sorting-deps.t} (78%) diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json b/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json index 6ceceb5d922a2..162bcddf217ef 100644 --- a/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/apps/my-app/package.json @@ -4,7 +4,6 @@ "build": "echo building" }, "dependencies": { - "another": "*", "util": "*" } } diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json index 3d6638374a14c..7309726a1df4e 100644 --- a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json +++ b/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "util", "scripts": { - "build": "echo building-util" + "build": "echo building" } } diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore b/turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore new file mode 100644 index 0000000000000..77af9fc60321d --- /dev/null +++ b/turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.turbo +.npmrc diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/README.md b/turborepo-tests/integration/fixtures/with_pkg_deps/README.md similarity index 100% rename from turborepo-tests/integration/fixtures/task_dependencies/topological/README.md rename to turborepo-tests/integration/fixtures/with_pkg_deps/README.md diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json b/turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json new file mode 100644 index 0000000000000..6ceceb5d922a2 --- /dev/null +++ b/turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json @@ -0,0 +1,10 @@ +{ + "name": "my-app", + "scripts": { + "build": "echo building" + }, + "dependencies": { + "another": "*", + "util": "*" + } +} diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/package.json b/turborepo-tests/integration/fixtures/with_pkg_deps/package.json new file mode 100644 index 0000000000000..85175c18a49b0 --- /dev/null +++ b/turborepo-tests/integration/fixtures/with_pkg_deps/package.json @@ -0,0 +1,7 @@ +{ + "name": "monorepo", + "workspaces": [ + "apps/**", + "packages/**" + ] +} diff --git a/turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json b/turborepo-tests/integration/fixtures/with_pkg_deps/packages/another/package.json similarity index 100% rename from turborepo-tests/integration/fixtures/task_dependencies/topological/packages/another/package.json rename to turborepo-tests/integration/fixtures/with_pkg_deps/packages/another/package.json diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json b/turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json new file mode 100644 index 0000000000000..3d6638374a14c --- /dev/null +++ b/turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json @@ -0,0 +1,6 @@ +{ + "name": "util", + "scripts": { + "build": "echo building-util" + } +} diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json b/turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json new file mode 100644 index 0000000000000..35f359404228c --- /dev/null +++ b/turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": { + "dependsOn": ["^build"] + }, + "//#build": { + "dependsOn": [] + } + } +} diff --git a/turborepo-tests/integration/tests/run-summary/sorting.t b/turborepo-tests/integration/tests/run-summary/sorting-deps.t similarity index 78% rename from turborepo-tests/integration/tests/run-summary/sorting.t rename to turborepo-tests/integration/tests/run-summary/sorting-deps.t index 0fe204c9021ad..f5d7f7b4974cc 100644 --- a/turborepo-tests/integration/tests/run-summary/sorting.t +++ b/turborepo-tests/integration/tests/run-summary/sorting-deps.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "task_dependencies/topological" + $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "with_pkg_deps" $ source "$TESTDIR/../_helpers/run-summary-utils.sh" $ rm -rf .turbo/runs From b1fcc29c80d88407392ff942a23f18519c400c14 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 23 Jan 2024 15:18:11 -0600 Subject: [PATCH 7/7] simple --- .../fixtures/{with_pkg_deps => with-pkg-deps}/.gitignore | 0 .../apps/my-app/package.json | 0 .../fixtures/{with_pkg_deps => with-pkg-deps}/package.json | 0 .../packages/another/package.json | 0 .../packages/util/package.json | 0 .../fixtures/{with_pkg_deps => with-pkg-deps}/turbo.json | 7 +++---- .../integration/fixtures/with_pkg_deps/README.md | 1 - .../integration/tests/run-summary/sorting-deps.t | 2 +- 8 files changed, 4 insertions(+), 6 deletions(-) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/.gitignore (100%) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/apps/my-app/package.json (100%) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/package.json (100%) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/packages/another/package.json (100%) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/packages/util/package.json (100%) rename turborepo-tests/integration/fixtures/{with_pkg_deps => with-pkg-deps}/turbo.json (54%) delete mode 100644 turborepo-tests/integration/fixtures/with_pkg_deps/README.md diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore b/turborepo-tests/integration/fixtures/with-pkg-deps/.gitignore similarity index 100% rename from turborepo-tests/integration/fixtures/with_pkg_deps/.gitignore rename to turborepo-tests/integration/fixtures/with-pkg-deps/.gitignore diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json b/turborepo-tests/integration/fixtures/with-pkg-deps/apps/my-app/package.json similarity index 100% rename from turborepo-tests/integration/fixtures/with_pkg_deps/apps/my-app/package.json rename to turborepo-tests/integration/fixtures/with-pkg-deps/apps/my-app/package.json diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/package.json b/turborepo-tests/integration/fixtures/with-pkg-deps/package.json similarity index 100% rename from turborepo-tests/integration/fixtures/with_pkg_deps/package.json rename to turborepo-tests/integration/fixtures/with-pkg-deps/package.json diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/packages/another/package.json b/turborepo-tests/integration/fixtures/with-pkg-deps/packages/another/package.json similarity index 100% rename from turborepo-tests/integration/fixtures/with_pkg_deps/packages/another/package.json rename to turborepo-tests/integration/fixtures/with-pkg-deps/packages/another/package.json diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json b/turborepo-tests/integration/fixtures/with-pkg-deps/packages/util/package.json similarity index 100% rename from turborepo-tests/integration/fixtures/with_pkg_deps/packages/util/package.json rename to turborepo-tests/integration/fixtures/with-pkg-deps/packages/util/package.json diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json b/turborepo-tests/integration/fixtures/with-pkg-deps/turbo.json similarity index 54% rename from turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json rename to turborepo-tests/integration/fixtures/with-pkg-deps/turbo.json index 35f359404228c..4216c8201cbcd 100644 --- a/turborepo-tests/integration/fixtures/with_pkg_deps/turbo.json +++ b/turborepo-tests/integration/fixtures/with-pkg-deps/turbo.json @@ -2,10 +2,9 @@ "$schema": "https://turbo.build/schema.json", "pipeline": { "build": { - "dependsOn": ["^build"] - }, - "//#build": { - "dependsOn": [] + "dependsOn": [ + "^build" + ] } } } diff --git a/turborepo-tests/integration/fixtures/with_pkg_deps/README.md b/turborepo-tests/integration/fixtures/with_pkg_deps/README.md deleted file mode 100644 index 7af988706a519..0000000000000 --- a/turborepo-tests/integration/fixtures/with_pkg_deps/README.md +++ /dev/null @@ -1 +0,0 @@ -My Monorepo diff --git a/turborepo-tests/integration/tests/run-summary/sorting-deps.t b/turborepo-tests/integration/tests/run-summary/sorting-deps.t index f5d7f7b4974cc..82ac01c673d83 100644 --- a/turborepo-tests/integration/tests/run-summary/sorting-deps.t +++ b/turborepo-tests/integration/tests/run-summary/sorting-deps.t @@ -1,4 +1,4 @@ - $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "with_pkg_deps" + $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "with-pkg-deps" $ source "$TESTDIR/../_helpers/run-summary-utils.sh" $ rm -rf .turbo/runs