diff --git a/crates/turborepo-lib/src/run/summary/mod.rs b/crates/turborepo-lib/src/run/summary/mod.rs index 6c006dd6f9d35..69952e3d9b46a 100644 --- a/crates/turborepo-lib/src/run/summary/mod.rs +++ b/crates/turborepo-lib/src/run/summary/mod.rs @@ -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(); + task.shared.dependents.sort(); + } } 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, 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/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/with-pkg-deps/packages/another/package.json b/turborepo-tests/integration/fixtures/with-pkg-deps/packages/another/package.json new file mode 100644 index 0000000000000..eb2aac6a1f946 --- /dev/null +++ b/turborepo-tests/integration/fixtures/with-pkg-deps/packages/another/package.json @@ -0,0 +1,6 @@ +{ + "name": "another", + "scripts": { + "build": "echo building-another" + } +} 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..4216c8201cbcd --- /dev/null +++ b/turborepo-tests/integration/fixtures/with-pkg-deps/turbo.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": { + "dependsOn": [ + "^build" + ] + } + } +} diff --git a/turborepo-tests/integration/tests/run-summary/sorting-deps.t b/turborepo-tests/integration/tests/run-summary/sorting-deps.t new file mode 100644 index 0000000000000..82ac01c673d83 --- /dev/null +++ b/turborepo-tests/integration/tests/run-summary/sorting-deps.t @@ -0,0 +1,11 @@ + $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh "with-pkg-deps" + $ 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" + ]