Skip to content

Commit

Permalink
Track the reason why an immediate change was detected
Browse files Browse the repository at this point in the history
Summary: Add an `ImpactReason` enum indicating the path we took in `immediate_target_changes` to mark a target as affected, then propagate that reason through rdeps in `recursive_target_changes`. Carry the reason all the way through to BTD's output so that we can inspect it in Skycastle. Also summarize the number of affected targets with each reason in the BTD_SUCCESS event.

Reviewed By: ndmitchell

Differential Revision: D54436861

fbshipit-source-id: 800607b2796cd94f4f6965c0555e143cb468c9a2
  • Loading branch information
rjbailey authored and facebook-github-bot committed Mar 5, 2024
1 parent ff437c5 commit 2bc3dd5
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 72 deletions.
1 change: 1 addition & 0 deletions btd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ derive_more = "0.99.3"
fbinit = { workspace = true }
glob = "0.3.0"
itertools = "0.10.5"
parse-display = "0.8.2"
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.66"
tempfile = "3.1.0"
Expand Down
15 changes: 8 additions & 7 deletions btd/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::buck::types::Package;
use crate::buck::types::TargetLabel;
use crate::buck::types::TargetPattern;
use crate::changes::Changes;
use crate::diff::ImpactReason;

#[derive(Debug, Error, Serialize)]
pub enum ValidationError {
Expand Down Expand Up @@ -141,15 +142,15 @@ pub fn check_errors(base: &Targets, diff: &Targets, changes: &Changes) -> Vec<Va
pub fn check_dangling(
base: &Targets,
diff: &Targets,
immediate_changes: &[&BuckTarget],
immediate_changes: &[(&BuckTarget, ImpactReason)],
universe: &[TargetPattern],
) -> Vec<ValidationError> {
let exists_after = diff.targets_by_label_key();
let base_targets_map = base.targets_by_label_key();

let mut errors = Vec::new();
// Lets check if dangling edges were introduced.
for target in immediate_changes.iter() {
for (target, _) in immediate_changes.iter() {
for dep in target.deps.iter() {
let key = dep.key();
// Only check newly introduced dangling dependencies that are
Expand Down Expand Up @@ -357,7 +358,7 @@ mod tests {
target_entry("aaa", &[]),
target_entry("bbb", &["aaa", "ccc"])
]),
&[&modified_target],
&[(&modified_target, ImpactReason::Inputs)],
&[TargetPattern::new("foo//...")],
)
.len(),
Expand All @@ -376,7 +377,7 @@ mod tests {
target_entry("bbb", &["aaa"]),
target_entry("ccc", &["ddd"])
]),
&[&modified_target],
&[(&modified_target, ImpactReason::Inputs)],
&[TargetPattern::new("foo//...")],
)
.len(),
Expand All @@ -395,7 +396,7 @@ mod tests {
target_entry("aaa", &["ccc"]),
target_entry("bbb", &["aaa"])
]),
&[&modified_target],
&[(&modified_target, ImpactReason::Inputs)],
&[TargetPattern::new("foo//...")],
)
.len(),
Expand All @@ -413,7 +414,7 @@ mod tests {
target_entry("aaa", &["ccc"]),
target_entry("bbb", &["aaa"])
]),
&[&modified_target],
&[(&modified_target, ImpactReason::Inputs)],
&[TargetPattern::new("foo//...")],
)
.len(),
Expand All @@ -431,7 +432,7 @@ mod tests {
target_entry("aaa", &[]),
target_entry("bbb", &["aaa"])
]),
&[&modified_target],
&[(&modified_target, ImpactReason::Inputs)],
&[TargetPattern::new("foo//...")],
)
.len(),
Expand Down
Loading

0 comments on commit 2bc3dd5

Please sign in to comment.