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

Make alumni field non-optional #1151

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 16 additions & 12 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ impl Team {
self.discord_roles.as_ref()
}

/// Exposed only for validation.
pub(crate) fn raw_people(&self) -> &TeamPeople {
&self.people
}

pub(crate) fn members<'a>(&'a self, data: &'a Data) -> Result<HashSet<&'a str>, Error> {
let mut members: HashSet<_> = self.people.members.iter().map(|s| s.as_str()).collect();

Expand Down Expand Up @@ -288,7 +293,7 @@ impl Team {
}

pub(crate) fn alumni(&self) -> &[String] {
&self.people.alumni
self.people.alumni.as_ref().map_or(&[], Vec::as_slice)
}

pub(crate) fn raw_lists(&self) -> &[TeamList] {
Expand Down Expand Up @@ -498,23 +503,22 @@ impl std::cmp::Ord for GitHubTeam<'_> {

#[derive(serde_derive::Deserialize, Debug)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
struct TeamPeople {
leads: Vec<String>,
members: Vec<String>,
#[serde(default)]
alumni: Vec<String>,
pub(crate) struct TeamPeople {
pub leads: Vec<String>,
pub members: Vec<String>,
pub alumni: Option<Vec<String>>,
#[serde(default)]
included_teams: Vec<String>,
pub included_teams: Vec<String>,
#[serde(default = "default_false")]
include_team_leads: bool,
pub include_team_leads: bool,
#[serde(default = "default_false")]
include_wg_leads: bool,
pub include_wg_leads: bool,
#[serde(default = "default_false")]
include_project_group_leads: bool,
pub include_project_group_leads: bool,
#[serde(default = "default_false")]
include_all_team_members: bool,
pub include_all_team_members: bool,
#[serde(default = "default_false")]
include_all_alumni: bool,
pub include_all_alumni: bool,
}

#[derive(serde::Deserialize, Debug)]
Expand Down
46 changes: 45 additions & 1 deletion src/validate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::data::Data;
use crate::github::GitHubApi;
use crate::schema::{Email, Permissions, Team, TeamKind, ZulipGroupMember};
use crate::schema::{Email, Permissions, Team, TeamKind, TeamPeople, ZulipGroupMember};
use crate::zulip::ZulipApi;
use anyhow::{bail, Error};
use log::{error, warn};
Expand Down Expand Up @@ -241,6 +241,50 @@ fn validate_alumni(data: &Data, errors: &mut Vec<String>) {
if !alumni_team.explicit_members().is_empty() {
errors.push("'alumni' team must not have explicit members; move them to the appropriate team's alumni entry".to_owned());
}

// Teams must contain an `alumni = […]` field (even if empty) so that there
// is an obvious place to move contributors within the same file when
// removing from `members`.
//
// Marker teams are exempt from this, as well as teams which comprise only
// members of other teams via `include-team-leads` or similar; they do not
// need `alumni = […]`. For these teams, the correct place to put alumni is
// in the same team they're being included from.
wrapper(data.teams(), errors, |team, _| {
// Exhaustive destructuring to ensure this code is touched if a new
// "include" settings is introduced.
let TeamPeople {
leads: _,
members,
alumni,
included_teams,
include_team_leads,
include_wg_leads,
include_project_group_leads,
include_all_team_members,
include_all_alumni,
} = team.raw_people();

if alumni.is_none() {
let exempt_team_kind = match team.kind() {
TeamKind::MarkerTeam => true,
TeamKind::Team | TeamKind::WorkingGroup | TeamKind::ProjectGroup => false,
};
let exempt_composition = members.is_empty() // intentionally not team.members(data).is_empty()
&& (*include_team_leads
|| *include_wg_leads
|| *include_project_group_leads
|| *include_all_team_members
|| *include_all_alumni
|| !included_teams.is_empty());
let exempt = exempt_team_kind || exempt_composition;
if !exempt {
let team_name = team.name();
bail!("team '{team_name}' needs an `alumni = []` entry");
}
}
Ok(())
});
}

fn validate_archived_teams(data: &Data, errors: &mut Vec<String>) {
Expand Down
1 change: 1 addition & 0 deletions teams/community-ctcft.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"technetos",
"yaahc",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/crate-maintainers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"ChrisDenton",
"Byron",
]
alumni = []

[permissions]
bors.libc.review = true
Expand Down
1 change: 1 addition & 0 deletions teams/docs-rs-reviewers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"Nemo157",
"syphar",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
1 change: 1 addition & 0 deletions teams/infra-bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"pietroalbini",
"Kobzol",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
1 change: 1 addition & 0 deletions teams/lang-advisors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"Mark-Simulacrum",
"wesleywiser",
]
alumni = []

# Granting these permissions because an advisor can use these to help when
# reviewing a proposed change.
Expand Down
1 change: 1 addition & 0 deletions teams/libs-contributors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"sunfishcode",
"yaahc",
]
alumni = []

[permissions]
bors.rust.review = true
Expand Down
1 change: 1 addition & 0 deletions teams/project-async-crashdump-debugging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ leads = [
members = [
"michaelwoerister",
]
alumni = []

[website]
name = "Async Crashdump Debugging Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-dyn-upcasting.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"crlf0710",
"nikomatsakis",
]
alumni = []

[website]
name = "Dyn Upcasting Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-edition-2021.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"m-ou-se",
"rylev"
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/project-edition-2024.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"ehuss",
"m-ou-se",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
1 change: 1 addition & 0 deletions teams/project-error-handling.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"mystor",
"senyosimpson",
]
alumni = []

[website]
name = "Error Handling Project Group"
Expand Down
1 change: 1 addition & 0 deletions teams/project-exploit-mitigations.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"cuviper",
"rcvalle",
]
alumni = []

[website]
name = "Exploit Mitigations Project Group"
Expand Down
1 change: 1 addition & 0 deletions teams/project-generic-associated-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"jackh726",
"nikomatsakis",
]
alumni = []

[website]
name = "Generic Associated Types Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-impl-trait.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"nikomatsakis",
"oli-obk",
]
alumni = []

[website]
name = "Impl Trait Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-keyword-generics.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"yoshuawuyts",
"lcnr",
]
alumni = []

[website]
name = "Keyword Generics Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-negative-impls.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"pnkfelix",
"spastorino",
]
alumni = []

[website]
name = "Negative Impls Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/project-stable-mir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"ouz-a",
"spastorino"
]
alumni = []

[website]
name = "Stable MIR Project Group"
Expand Down
1 change: 1 addition & 0 deletions teams/project-thir-unsafeck.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ subteam-of = "compiler"
[people]
leads = ["nikomatsakis"]
members = ["nikomatsakis"]
alumni = []

[website]
name = "THIR Unsafety Checker Project Group"
Expand Down
1 change: 1 addition & 0 deletions teams/project-trait-system-refactor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"spastorino",
"lcnr",
]
alumni = []

[website]
name = "Rustc Trait System Refactor Initiative"
Expand Down
1 change: 1 addition & 0 deletions teams/regex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ subteam-of = "libs"
[people]
leads = ["BurntSushi"]
members = ["BurntSushi"]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/rustdoc-contributors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ leads = []
members = [
"fmease"
]
alumni = []

[permissions]
bors.rust.review = true
Expand Down
1 change: 1 addition & 0 deletions teams/social-media.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ subteam-of = "leadership-council"
[people]
leads = ["m-ou-se"]
members = ["m-ou-se"]
alumni = []

[[lists]]
address = "[email protected]"
1 change: 1 addition & 0 deletions teams/testing-devex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"thomcc",
"weihanglo",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"ehuss",
"spastorino",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/twir-reviewers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"mariannegoldin",
"U007D"
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/web-presence.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "web-presence"
[people]
leads = []
members = []
alumni = []

[[lists]]
address = "[email protected]"
Expand Down
1 change: 1 addition & 0 deletions teams/wg-allocators.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"TimDiekmann",
"Wodann"
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/wg-bindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"emilio",
"fitzgen",
]
alumni = []

[website]
name = "Bindgen working group"
Expand Down
1 change: 1 addition & 0 deletions teams/wg-compiler-performance.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"lqd",
"nnethercote",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/wg-diagnostics.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"estebank",
"oli-obk",
]
alumni = []

[[github]]
orgs = ["rust-lang"]
Expand Down
1 change: 1 addition & 0 deletions teams/wg-embedded-core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"adamgreig",
"therealprof",
]
alumni = []

[website]
name = "Embedded core team"
Expand Down
1 change: 1 addition & 0 deletions teams/wg-embedded-cortex-a.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"raw-bin",
"andre-richter",
]
alumni = []

[website]
name = "Embedded Cortex-A team"
Expand Down
1 change: 1 addition & 0 deletions teams/wg-embedded-cortex-m.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"thalesfragoso",
"newAM",
]
alumni = []

[website]
name = "Embedded Cortex-M team"
Expand Down
4 changes: 2 additions & 2 deletions teams/wg-embedded-cortex-r.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ kind = "working-group"

[people]
leads = []
members = [
]
members = []
alumni = []

[website]
name = "Embedded Cortex-R team"
Expand Down
1 change: 1 addition & 0 deletions teams/wg-embedded-hal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"therealprof",
"MabezDev"
]
alumni = []

[website]
name = "Embedded HAL team"
Expand Down
Loading