Преглед изворни кода

Merge pull request #1724 from apiraino/add_zulip_links_to_mcp_fcp

T-compiler meeting agenda: add Zulip discussion links to MCPs and FCPs
Mark Rousskov пре 1 година
родитељ
комит
b53466e0c1
4 измењених фајлова са 57 додато и 5 уклоњено
  1. 20 1
      src/actions.rs
  2. 33 1
      src/github.rs
  3. 1 1
      templates/_issue.tt
  4. 3 2
      templates/prioritization_agenda.tt

+ 20 - 1
src/actions.rs

@@ -52,6 +52,7 @@ pub struct IssueDecorator {
     pub updated_at_hts: String,
 
     pub fcp_details: Option<FCPDetails>,
+    pub mcp_details: Option<MCPDetails>,
 }
 
 #[derive(Serialize, Deserialize, Debug)]
@@ -62,6 +63,11 @@ pub struct FCPDetails {
     pub initiating_comment_content: String,
 }
 
+#[derive(Serialize, Deserialize, Debug)]
+pub struct MCPDetails {
+    pub zulip_link: String,
+}
+
 lazy_static! {
     pub static ref TEMPLATES: Tera = {
         match Tera::new("templates/*") {
@@ -124,8 +130,21 @@ impl<'a> Action for Step<'a> {
                     let query = query.clone();
                     handles.push(tokio::task::spawn(async move {
                         let _permit = semaphore.acquire().await?;
+                        let mcps_groups = [
+                            "mcp_new_not_seconded",
+                            "mcp_old_not_seconded",
+                            "mcp_accepted",
+                            "in_pre_fcp",
+                            "in_fcp",
+                        ];
                         let issues = query
-                            .query(&repository, name == "proposed_fcp", &gh)
+                            .query(
+                                &repository,
+                                name == "proposed_fcp",
+                                mcps_groups.contains(&name.as_str())
+                                    && repository.full_name.contains("rust-lang/compiler-team"),
+                                &gh,
+                            )
                             .await?;
                         Ok((name, kind, issues))
                     }));

+ 33 - 1
src/github.rs

@@ -480,6 +480,18 @@ impl Issue {
         Ok(comment)
     }
 
+    // returns an array of one element
+    pub async fn get_first_comment(&self, client: &GithubClient) -> anyhow::Result<Vec<Comment>> {
+        let comment_url = format!(
+            "{}/issues/{}/comments?page=1&per_page=1",
+            self.repository().url(),
+            self.number,
+        );
+        Ok(client
+            .json::<Vec<Comment>>(client.get(&comment_url))
+            .await?)
+    }
+
     pub async fn edit_body(&self, client: &GithubClient, body: &str) -> anyhow::Result<()> {
         let edit_url = format!("{}/issues/{}", self.repository().url(), self.number);
         #[derive(serde::Serialize)]
@@ -1574,6 +1586,7 @@ impl<'q> IssuesQuery for Query<'q> {
         &'a self,
         repo: &'a Repository,
         include_fcp_details: bool,
+        include_mcp_details: bool,
         client: &'a GithubClient,
     ) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
         let issues = repo
@@ -1588,12 +1601,13 @@ impl<'q> IssuesQuery for Query<'q> {
         };
 
         let mut issues_decorator = Vec::new();
+        let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap();
+        let re_zulip_link = regex::Regex::new(r"\[stream\]:\s").unwrap();
         for issue in issues {
             let fcp_details = if include_fcp_details {
                 let repository_name = if let Some(repo) = issue.repository.get() {
                     repo.repository.clone()
                 } else {
-                    let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap();
                     let split = re.split(&issue.html_url).collect::<Vec<&str>>();
                     split[1].to_string()
                 };
@@ -1626,6 +1640,18 @@ impl<'q> IssuesQuery for Query<'q> {
             } else {
                 None
             };
+
+            let mcp_details = if include_mcp_details {
+                let first_comment = issue.get_first_comment(&client).await?;
+                let split = re_zulip_link
+                    .split(&first_comment[0].body)
+                    .collect::<Vec<&str>>();
+                let zulip_link = split.last().unwrap_or(&"#").to_string();
+                Some(crate::actions::MCPDetails { zulip_link })
+            } else {
+                None
+            };
+
             issues_decorator.push(crate::actions::IssueDecorator {
                 title: issue.title.clone(),
                 number: issue.number,
@@ -1645,6 +1671,7 @@ impl<'q> IssuesQuery for Query<'q> {
                     .join(", "),
                 updated_at_hts: crate::actions::to_human(issue.updated_at),
                 fcp_details,
+                mcp_details,
             });
         }
 
@@ -2112,6 +2139,7 @@ pub trait IssuesQuery {
         &'a self,
         repo: &'a Repository,
         include_fcp_details: bool,
+        include_mcp_details: bool,
         client: &'a GithubClient,
     ) -> anyhow::Result<Vec<crate::actions::IssueDecorator>>;
 }
@@ -2123,6 +2151,7 @@ impl IssuesQuery for LeastRecentlyReviewedPullRequests {
         &'a self,
         repo: &'a Repository,
         _include_fcp_details: bool,
+        _include_mcp_details: bool,
         client: &'a GithubClient,
     ) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
         use cynic::QueryBuilder;
@@ -2249,6 +2278,7 @@ impl IssuesQuery for LeastRecentlyReviewedPullRequests {
                         assignees,
                         updated_at_hts,
                         fcp_details: None,
+                        mcp_details: None,
                     }
                 },
             )
@@ -2336,6 +2366,7 @@ impl IssuesQuery for DesignMeetings {
         &'a self,
         _repo: &'a Repository,
         _include_fcp_details: bool,
+        _include_mcp_details: bool,
         client: &'a GithubClient,
     ) -> anyhow::Result<Vec<crate::actions::IssueDecorator>> {
         use github_graphql::project_items::ProjectV2ItemContent;
@@ -2350,6 +2381,7 @@ impl IssuesQuery for DesignMeetings {
                     assignees: String::new(),
                     number: issue.number.try_into().unwrap(),
                     fcp_details: None,
+                    mcp_details: None,
                     html_url: issue.url.0,
                     title: issue.title,
                     repo_name: String::new(),

+ 1 - 1
templates/_issue.tt

@@ -1 +1 @@
-{% macro render(issue, with_age="") %}"{{issue.title}}" [{{issue.repo_name}}#{{issue.number}}]({{issue.html_url}}){% if with_age %}(last review activity: {{issue.updated_at_hts}}){% endif %}{% endmacro %}
+{% macro render(issue, with_age="") %}"{{issue.title}}" [{{issue.repo_name}}#{{issue.number}}]({{issue.html_url}}){% if issue.mcp_details.zulip_link %} ([Zulip]({{issue.mcp_details.zulip_link}})){% endif %}{% if with_age %} (last review activity: {{issue.updated_at_hts}}){% endif %}{% endmacro %}

+ 3 - 2
templates/prioritization_agenda.tt

@@ -12,7 +12,7 @@ type: docs
 
 - (TIP) add here non-recurrent scheduled meetings, [check the schedule calendar](https://calendar.google.com/calendar/htmlembed?src=6u5rrtce6lrtv07pfi3damgjus%40group.calendar.google.com)
 - (TIP) mention upcoming Rust stable releases, [check the release calendar](https://calendar.google.com/calendar/htmlembed?src=l1b1gkqvfbgunjs18nemq4c580%40group.calendar.google.com)
-- Reminder: if you see a PR/issue that seems like there might be legal implications due to copyright/IP/etc, please let the Core team know (or at least message @_**pnkfelix** or @_**Wesley Wiser** so we can pass it along).
+- Reminder: if you see a PR/issue that seems like there might be legal implications due to copyright/IP/etc, please let us know (or at least message @_**davidtwco** or @_**Wesley Wiser** so we can pass it along).
 
 ### Other WG meetings ([calendar link](https://calendar.google.com/calendar/embed?src=6u5rrtce6lrtv07pfi3damgjus%40group.calendar.google.com))
 
@@ -68,6 +68,7 @@ don't know
 
 [T-compiler](https://github.com/rust-lang/rust/pulls?q=is%3Aopen+label%3AS-waiting-on-team+label%3AT-compiler)
 {{-issues::render(issues=prs_waiting_on_team_t_compiler, empty="No PRs waiting on `T-compiler` this time.")}}
+- Other issues [in progress or waiting on other teams](https://hackmd.io/XYr1BrOWSiqCrl8RCWXRaQ)
 
 ## Issues of Note
 
@@ -124,4 +125,4 @@ don't know
 - @*WG-X* checkin by @**person1**
 - @*WG-X* checkin by @**person2**
 
-Next meetings' agenda draft: `<hackmd link>`
+Next meetings' agenda draft: [hackmd link](#)