From 9c88e4bc637e762a5b57ab16f2a93cba97d16af1 Mon Sep 17 00:00:00 2001 From: apiraino Date: Thu, 29 Feb 2024 10:38:02 +0100 Subject: [PATCH] Add webhook handler to update PR workload queues --- src/config.rs | 12 ++++ src/db.rs | 1 + src/github.rs | 13 ++++- src/handlers.rs | 2 + src/handlers/pr_tracking.rs | 111 ++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 src/handlers/pr_tracking.rs diff --git a/src/config.rs b/src/config.rs index 244c35ef..e1ecce2d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,6 +15,10 @@ lazy_static::lazy_static! { RwLock::new(HashMap::new()); } +// This struct maps each possible option of the triagebot.toml. +// See documentation of options at: https://forge.rust-lang.org/triagebot/pr-assignment.html#configuration +// When adding a new config option to the triagebot.toml, it must be also mapped here +// Will be used by the `issue_handlers!()` or `command_handlers!()` macros. #[derive(PartialEq, Eq, Debug, serde::Deserialize)] #[serde(rename_all = "kebab-case")] #[serde(deny_unknown_fields)] @@ -39,6 +43,7 @@ pub(crate) struct Config { // We want this validation to run even without the entry in the config file #[serde(default = "ValidateConfig::default")] pub(crate) validate_config: Option, + pub(crate) pr_tracking: Option, } #[derive(PartialEq, Eq, Debug, serde::Deserialize)] @@ -317,6 +322,12 @@ pub(crate) struct GitHubReleasesConfig { pub(crate) changelog_branch: String, } +#[derive(PartialEq, Eq, Debug, serde::Deserialize)] +pub(crate) struct ReviewPrefsConfig { + #[serde(default)] + _empty: (), +} + fn get_cached_config(repo: &str) -> Option, ConfigurationError>> { let cache = CONFIG_CACHE.read().unwrap(); cache.get(repo).and_then(|(config, fetch_time)| { @@ -463,6 +474,7 @@ mod tests { mentions: None, no_merges: None, validate_config: Some(ValidateConfig {}), + pr_tracking: None, } ); } diff --git a/src/db.rs b/src/db.rs index 6d5b5e8c..1da96372 100644 --- a/src/db.rs +++ b/src/db.rs @@ -332,6 +332,7 @@ CREATE table review_prefs ( assigned_prs INT[] NOT NULL DEFAULT array[]::INT[] );", " +CREATE EXTENSION intarray; CREATE UNIQUE INDEX review_prefs_user_id ON review_prefs(user_id); ", ]; diff --git a/src/github.rs b/src/github.rs index 3b8d7ae8..c078fe56 100644 --- a/src/github.rs +++ b/src/github.rs @@ -286,8 +286,11 @@ pub struct Issue { /// /// Example: `https://github.com/octocat/Hello-World/pull/1347` pub html_url: String, + // User performing an `action` pub user: User, pub labels: Vec