Skip to content

Commit

Permalink
Allow non-diff/land builds to be run with build directives
Browse files Browse the repository at this point in the history
Summary:
**Context**
When we make changes to apple rules in buck2, we might want to run all app store builds using a build directive including the ones that are not run on diff/land at the castle config.

**Proposal**
Skipping the exact check for fbobjc Tdproject.

Differential Revision: D58425026

fbshipit-source-id: d8c353a02d5dcacfc59ed6cef5d1bc9832129fb3
  • Loading branch information
Abishek Sethuraman authored and facebook-github-bot committed Jun 11, 2024
1 parent 0c2a6e3 commit 14dc601
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions td_util/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ pub fn app_specific_build_directives_matches_name(
app_specific_build_directives: &Option<Vec<String>>,
name: &String,
exactly: bool,
project: TdProject,
) -> bool {
app_specific_build_directives
.as_ref()
.map_or(false, |app_specific_build_directives| {
app_specific_build_directives.iter().any(|directive| {
if exactly {
if exactly && project != TdProject::Fbobjc {
name == directive
} else {
name.starts_with(directive) || name.ends_with(directive)
Expand Down Expand Up @@ -94,12 +95,14 @@ mod tests {
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1".to_string(),
true
true,
TdProject::Fbandroid
));
assert!(!app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive4".to_string(),
true
true,
TdProject::Fbandroid
));
}
#[test]
Expand All @@ -108,7 +111,8 @@ mod tests {
assert!(!app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1".to_string(),
true
true,
TdProject::Fbandroid
));
}

Expand All @@ -122,30 +126,48 @@ mod tests {
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&"directive1234".to_string(),
false
false,
TdProject::Fbandroid
));
}

#[test]
fn test_app_specific_build_directives_matches_suffix() {
let app_specific_build_directives = Some(vec![
let fbobjc_app_specific_build_directives = Some(vec![
"-iphoneos-release-buck2".to_string(),
"-iphoneos-production-buck2".to_string(),
]);
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&fbobjc_app_specific_build_directives,
&"barcelona-distribution-iphoneos-release-buck2".to_string(),
false
true,
TdProject::Fbobjc
));
assert!(app_specific_build_directives_matches_name(
&app_specific_build_directives,
&fbobjc_app_specific_build_directives,
&"igios-distribution-iphoneos-production-buck2".to_string(),
false
true,
TdProject::Fbobjc
));
assert!(!app_specific_build_directives_matches_name(
&app_specific_build_directives,
&fbobjc_app_specific_build_directives,
&"igios-iphonesimulator-local-buck2".to_string(),
false
true,
TdProject::Fbobjc
));
let fbandroid_app_specific_build_directives =
Some(vec!["fb4a-debug".to_string(), "fb4a-release".to_string()]);
assert!(app_specific_build_directives_matches_name(
&fbandroid_app_specific_build_directives,
&"automation-fb4a-debug".to_string(),
false,
TdProject::Fbandroid
));
assert!(app_specific_build_directives_matches_name(
&fbandroid_app_specific_build_directives,
&"automation-fb4a-release".to_string(),
false,
TdProject::Fbandroid
));
}
}

0 comments on commit 14dc601

Please sign in to comment.