Skip to content

Commit

Permalink
Move the is_changeset_schedule_type function to td_util for reuse
Browse files Browse the repository at this point in the history
Summary: So we can reuse it in `ranker` in next diff

Reviewed By: bayarmunkh

Differential Revision: D53050703

fbshipit-source-id: 08d6b7f76933d2121a5f0c5508af6066423737fc
  • Loading branch information
pcerl017 authored and facebook-github-bot committed Jan 24, 2024
1 parent 114d14a commit d941944
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions td_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ argfile = "0.1.5"
clap = {version = "4.1.4"}
derive_more = "0.99.3"
equivalent = "1.0.0"
lazy_static = "1.4.0"
static_interner.version = "0.1"
# @oss-disable: static_interner.path = "../../buck2/shed/static_interner"
static_interner.default-features = false
Expand Down
13 changes: 13 additions & 0 deletions td_util/src/schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
//! The schedule types available.
use std::cmp::Eq;
use std::collections::HashSet;
use std::hash::Hash;

use clap::ValueEnum;
use lazy_static::lazy_static;
use parse_display::Display;
use serde::Deserialize;
use serde::Serialize;

lazy_static! {
static ref CHANGESET_SCHEDULE_TYPES: HashSet<&'static str> =
HashSet::from(["diff", "landcastle", "master", "postcommit", "relbranch"]);
}

#[derive(
ValueEnum,
Serialize,
Expand Down Expand Up @@ -44,3 +51,9 @@ pub enum ScheduleType {
#[serde(rename = "landcastle")]
Landcastle, // Should this be just "land"?
}

/// Mobile build TDs use schedule_type to decide whether we need to run build for changeset (e.g. diff and landcastle)
/// See UTD implementation: <https://fburl.com/code/wfps6pag>
pub fn is_changeset_schedule_type(schedule_type: ScheduleType) -> bool {
CHANGESET_SCHEDULE_TYPES.contains(schedule_type.to_string().as_str())
}

0 comments on commit d941944

Please sign in to comment.