Skip to content

Commit

Permalink
td/utils: Don't use lazy static for schedule_type sets
Browse files Browse the repository at this point in the history
Summary:
This hashmap is just a match statement. Might as well do it inline and avoid
the dependency.

Differential Revision: D59885606

fbshipit-source-id: cf9a97fdaa06362bffbb55bf574dd6f21559a113
  • Loading branch information
Aniket Mathur authored and facebook-github-bot committed Jul 18, 2024
1 parent dd24184 commit 88db9bf
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions td_util/src/schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,13 @@
//! 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<ScheduleType> = HashSet::from([
ScheduleType::Diff,
ScheduleType::Landcastle,
ScheduleType::Master,
ScheduleType::Postcommit,
ScheduleType::Relbranch,
]);
static ref TRUNK_SCHEDULE_TYPES: HashSet<ScheduleType> = HashSet::from([
ScheduleType::Continuous,
ScheduleType::ContinuousStable,
ScheduleType::Testwarden,
ScheduleType::Greenwarden,
ScheduleType::Disabled,
]);
}

#[derive(
ValueEnum,
Serialize,
Expand Down Expand Up @@ -71,11 +52,25 @@ impl ScheduleType {
/// 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(&self) -> bool {
CHANGESET_SCHEDULE_TYPES.contains(self)
match self {
ScheduleType::Diff
| ScheduleType::Landcastle
| ScheduleType::Master
| ScheduleType::Postcommit
| ScheduleType::Relbranch => true,
_ => false,
}
}

pub fn is_trunk_schedule_type(&self) -> bool {
TRUNK_SCHEDULE_TYPES.contains(self)
match self {
ScheduleType::Continuous
| ScheduleType::ContinuousStable
| ScheduleType::Testwarden
| ScheduleType::Greenwarden
| ScheduleType::Disabled => true,
_ => false,
}
}

/// For checking a ScheduleType that an orchestrator is running with against a ScheduleType target is configured with
Expand Down

0 comments on commit 88db9bf

Please sign in to comment.