Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Marker teams setup #135

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub static BASE_URL: &str = "https://team-api.infra.rust-lang.org/v1";
pub enum TeamKind {
Team,
WorkingGroup,
MarkerTeam,
#[serde(other)]
Unknown,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
8 changes: 7 additions & 1 deletion src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ pub(crate) struct Team {
name: String,
#[serde(default = "default_false")]
wg: bool,
#[serde(default = "default_false")]
marker_team: bool,
subteam_of: Option<String>,
people: TeamPeople,
#[serde(default)]
Expand All @@ -129,6 +131,10 @@ impl Team {
self.wg
}

pub(crate) fn is_marker_team(&self) -> bool {
self.marker_team
}

pub(crate) fn subteam_of(&self) -> Option<&str> {
self.subteam_of.as_ref().map(|s| s.as_str())
}
Expand Down Expand Up @@ -160,7 +166,7 @@ impl Team {
}
if self.people.include_all_team_members {
for team in data.teams() {
if team.is_wg() || team.name == self.name {
if team.is_wg() || team.is_marker_team() || team.name == self.name {
continue;
}
for member in team.members(data)? {
Expand Down
2 changes: 2 additions & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl<'a> Generator<'a> {
name: team.name().into(),
kind: if team.is_wg() {
v1::TeamKind::WorkingGroup
} else if team.is_marker_team() {
v1::TeamKind::MarkerTeam
} else {
v1::TeamKind::Team
},
Expand Down
14 changes: 14 additions & 0 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[
validate_rfcbot_exclude_members,
validate_team_names,
validate_github_teams,
validate_marker_team,
];

static GITHUB_CHECKS: &[fn(&Data, &GitHubApi, &mut Vec<String>)] = &[validate_github_usernames];
Expand Down Expand Up @@ -432,6 +433,19 @@ fn validate_github_usernames(data: &Data, github: &GitHubApi, errors: &mut Vec<S
}
}

/// Ensure teams are not working group and marker team at the same time
fn validate_marker_team(data: &Data, errors: &mut Vec<String>) {
wrapper(data.teams(), errors, |team, _| {
if team.is_wg() && team.is_marker_team() {
bail!(
"`{}` is a working group and marker team at the same time",
team.name()
);
}
Ok(())
});
}

fn wrapper<T, I, F>(iter: I, errors: &mut Vec<String>, mut func: F)
where
I: Iterator<Item = T>,
Expand Down