这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(turbo): sort dependents and dependencies during normalization #7018

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

Merged
merged 8 commits into from
Jan 24, 2024
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
6 changes: 6 additions & 0 deletions crates/turborepo-lib/src/run/summary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions crates/turborepo-lib/src/run/summary/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,10 @@ impl From<SharedTaskSummary<TaskId<'static>>> for SharedTaskSummary<String> {
dependencies: dependencies
.into_iter()
.map(|task_id| task_id.task().to_string())
.sorted()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This from implementation is used by the into() call here: https://github.com/vercel/turbo/blob/1dd2e93e84e08872f67943804a6600f0e91a124a/crates/turborepo-lib/src/run/summary/task.rs#L211

it only runs for SinglePackageTaskSummary. Since we have moved the sorting to the normalize() step, we shouldn't need it here.

.collect(),
dependents: dependents
.into_iter()
.map(|task_id| task_id.task().to_string())
.sorted()
.collect(),
resolved_task_definition,
framework,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.turbo
.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "my-app",
"scripts": {
"build": "echo building"
},
"dependencies": {
"another": "*",
"util": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "monorepo",
"workspaces": [
"apps/**",
"packages/**"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "another",
"scripts": {
"build": "echo building-another"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "util",
"scripts": {
"build": "echo building-util"
}
}
10 changes: 10 additions & 0 deletions turborepo-tests/integration/fixtures/with-pkg-deps/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": [
"^build"
]
}
}
}
11 changes: 11 additions & 0 deletions turborepo-tests/integration/tests/run-summary/sorting-deps.t
Original file line number Diff line number Diff line change
@@ -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"
]