Skip to content

Commit

Permalink
Merge pull request #1724 from apiraino/add_zulip_links_to_mcp_fcp
Browse files Browse the repository at this point in the history
T-compiler meeting agenda: add Zulip discussion links to MCPs and FCPs
  • Loading branch information
Mark-Simulacrum committed Sep 29, 2023
2 parents 2ab128e + ef295fe commit b53466e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
21 changes: 20 additions & 1 deletion src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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/*") {
Expand Down Expand Up @@ -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))
}));
Expand Down
34 changes: 33 additions & 1 deletion src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand All @@ -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()
};
Expand Down Expand Up @@ -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,
Expand All @@ -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,
});
}

Expand Down Expand Up @@ -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>>;
}
Expand All @@ -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;
Expand Down Expand Up @@ -2249,6 +2278,7 @@ impl IssuesQuery for LeastRecentlyReviewedPullRequests {
assignees,
updated_at_hts,
fcp_details: None,
mcp_details: None,
}
},
)
Expand Down Expand Up @@ -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;
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion templates/_issue.tt
Original file line number Diff line number Diff line change
@@ -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 %}
5 changes: 3 additions & 2 deletions templates/prioritization_agenda.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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](#)

0 comments on commit b53466e

Please sign in to comment.