Skip to content

Commit

Permalink
btd: Invalidate the graph if the buck deployment changes
Browse files Browse the repository at this point in the history
Reviewed By: ndmitchell

Differential Revision: D55647381

fbshipit-source-id: 8eb09ba19ca5492fa36615307df474eafa92fd38
  • Loading branch information
Aniket Mathur authored and facebook-github-bot committed Apr 3, 2024
1 parent 50b5cf4 commit bc03bda
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions btd/src/buck/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

//! Configuration that we hardcode, because parsing it is too expensive.
use crate::buck::types::CellPath;

/// Certain bzl files should be excluded from transitive impact tracing.
/// This list should *only* be extended if we are certain that changes to the file
/// will have its impact traced through other means, e.g., attribute changes.
Expand All @@ -18,3 +20,22 @@ pub fn should_exclude_bzl_file_from_transitive_impact_tracing(path: &str) -> boo
.iter()
.any(|prefix| path.starts_with(*prefix))
}

pub fn is_buck_deployment(path: &CellPath) -> bool {
path.as_str().starts_with("fbsource//tools/buck2-versions/")
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_is_buck_deployment() {
assert!(is_buck_deployment(&CellPath::new(
"fbsource//tools/buck2-versions/previous"
)));
assert!(is_buck_deployment(&CellPath::new(
"fbsource//tools/buck2-versions/stable"
)));
}
}
7 changes: 6 additions & 1 deletion btd/src/rerun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::collections::HashSet;
use std::path::Path;

use crate::buck::cells::CellInfo;
use crate::buck::config::is_buck_deployment;
use crate::buck::package_resolver::PackageResolver;
use crate::buck::targets::Targets;
use crate::buck::types::CellName;
Expand Down Expand Up @@ -43,14 +44,18 @@ fn is_buckconfig(path: &CellPath) -> bool {
|| str.contains("/buckconfigs/")
}

fn invalidates_graph(path: &CellPath) -> bool {
is_buckconfig(path) || is_buck_deployment(path)
}

/// Compute the targets we should rerun, or None if we should do everything.
pub fn rerun(
cells: &CellInfo,
base: &Targets,
changes: &Changes,
) -> Option<HashMap<Package, PackageStatus>> {
// if there are any .buckconfig changes, we should give up
if changes.cell_paths().any(is_buckconfig) {
if changes.cell_paths().any(invalidates_graph) {
return None;
}

Expand Down

0 comments on commit bc03bda

Please sign in to comment.