-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(turborepo): log reason why all packages were considered changed #8872
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a73d5ea
feat(turborepo): Log reason why all packages were considered changed
mehulkar 21202d7
fixes
mehulkar b4a2c4e
rm import
mehulkar 23ce90d
Merge branch 'main' into mk/log-why-all-changes
mehulkar 6ab0fcd
fixup
mehulkar 15fb4b5
Merge branch 'main' into mk/log-why-all-changes
mehulkar e23ff50
import
mehulkar a4f8dde
test
mehulkar 5683838
Update crates/turborepo-repository/src/change_mapper/package.rs
chris-olszewski 8d79542
bring back a debug
mehulkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,18 @@ pub enum LockfileChange { | |
WithContent(Vec<u8>), | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub enum AllPackageChangeReason { | ||
DefaultGlobalFileChanged, | ||
LockfileChangeDetectionFailed, | ||
LockfileChangedWithoutDetails, | ||
RootInternalDepChanged, | ||
NonPackageFileChanged, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub enum PackageChanges { | ||
All, | ||
All(AllPackageChangeReason), | ||
Some(HashSet<WorkspacePackage>), | ||
} | ||
|
||
|
@@ -62,39 +71,50 @@ impl<'a, PD: PackageChangeMapper> ChangeMapper<'a, PD> { | |
) -> Result<PackageChanges, ChangeMapError> { | ||
if Self::default_global_file_changed(&changed_files) { | ||
debug!("global file changed"); | ||
return Ok(PackageChanges::All); | ||
return Ok(PackageChanges::All( | ||
AllPackageChangeReason::DefaultGlobalFileChanged, | ||
)); | ||
} | ||
|
||
// get filtered files and add the packages that contain them | ||
let filtered_changed_files = self.filter_ignored_files(changed_files.iter())?; | ||
let PackageChanges::Some(mut changed_pkgs) = | ||
self.get_changed_packages(filtered_changed_files.into_iter()) | ||
else { | ||
return Ok(PackageChanges::All); | ||
}; | ||
Comment on lines
-70
to
-74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to pass through the reason to |
||
|
||
match lockfile_change { | ||
Some(LockfileChange::WithContent(content)) => { | ||
// if we run into issues, don't error, just assume all packages have changed | ||
let Ok(lockfile_changes) = self.get_changed_packages_from_lockfile(content) else { | ||
debug!("unable to determine lockfile changes, assuming all packages changed"); | ||
return Ok(PackageChanges::All); | ||
}; | ||
|
||
debug!( | ||
"found {} packages changed by lockfile", | ||
lockfile_changes.len() | ||
); | ||
changed_pkgs.extend(lockfile_changes); | ||
|
||
Ok(PackageChanges::Some(changed_pkgs)) | ||
} | ||
// We don't have the actual contents, so just invalidate everything | ||
Some(LockfileChange::Empty) => { | ||
debug!("no previous lockfile available, assuming all packages changed"); | ||
Ok(PackageChanges::All) | ||
|
||
match self.get_changed_packages(filtered_changed_files.into_iter()) { | ||
PackageChanges::All(reason) => Ok(PackageChanges::All(reason)), | ||
|
||
PackageChanges::Some(mut changed_pkgs) => { | ||
match lockfile_change { | ||
Some(LockfileChange::WithContent(content)) => { | ||
// if we run into issues, don't error, just assume all packages have changed | ||
let Ok(lockfile_changes) = self.get_changed_packages_from_lockfile(content) | ||
else { | ||
debug!( | ||
"unable to determine lockfile changes, assuming all packages \ | ||
changed" | ||
); | ||
return Ok(PackageChanges::All( | ||
AllPackageChangeReason::LockfileChangeDetectionFailed, | ||
)); | ||
}; | ||
debug!( | ||
"found {} packages changed by lockfile", | ||
lockfile_changes.len() | ||
); | ||
changed_pkgs.extend(lockfile_changes); | ||
|
||
Ok(PackageChanges::Some(changed_pkgs)) | ||
} | ||
|
||
// We don't have the actual contents, so just invalidate everything | ||
Some(LockfileChange::Empty) => { | ||
debug!("no previous lockfile available, assuming all packages changed"); | ||
Ok(PackageChanges::All( | ||
AllPackageChangeReason::LockfileChangedWithoutDetails, | ||
)) | ||
} | ||
None => Ok(PackageChanges::Some(changed_pkgs)), | ||
} | ||
} | ||
None => Ok(PackageChanges::Some(changed_pkgs)), | ||
} | ||
} | ||
|
||
|
@@ -120,18 +140,18 @@ impl<'a, PD: PackageChangeMapper> ChangeMapper<'a, PD> { | |
// Internal root dependency changed so global hash has changed | ||
PackageMapping::Package(pkg) if root_internal_deps.contains(&pkg) => { | ||
debug!( | ||
"root internal dependency \"{}\" changed due to: {file:?}", | ||
"{} changes root internal dependency: \"{}\"", | ||
file.to_string(), | ||
pkg.name | ||
); | ||
return PackageChanges::All; | ||
return PackageChanges::All(AllPackageChangeReason::RootInternalDepChanged); | ||
} | ||
PackageMapping::Package(pkg) => { | ||
debug!("package {pkg:?} changed due to {file:?}"); | ||
debug!("{} changes \"{}\"", file.to_string(), pkg.name); | ||
changed_packages.insert(pkg); | ||
} | ||
PackageMapping::All => { | ||
debug!("all packages changed due to {file:?}"); | ||
return PackageChanges::All; | ||
return PackageChanges::All(AllPackageChangeReason::NonPackageFileChanged); | ||
mehulkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
PackageMapping::None => {} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called this reason "NonPackageFileChanged" instead of "GlobalFileChanged", because the latter is a little bit confusing. E.g.
.github/actions/whatever.yml
is a global file and so isexamples/some-app/whatever.js
if neither path falls in the workspace config. It's not always clear that these are "global files" as far as turbo is concerned. I'm open to better name though.