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

Triagebot learns how to comment on GitHub #1690

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

apiraino
Copy link
Contributor

@apiraino apiraino commented Apr 18, 2023

In this first version the triagebot learns how to post a comment on GitHub to assign priority to an issue that is marked as regression. The command is sent by the Zulip Rust lang chat instance. The syntax is:

@triagebot prio #issue <P-label>

example @triagebot prio #123456 <P-high

The posted comment on GitHub will look like:

WG-prioritization assigning priority ([Zulip discussion](<zulip-topic-link>)).
@rustbot label -I-prioritize +P-high

The zulip-topic-link part of the message is retrieved by querying the Zulip API by the message ID the webhook should send the triagebot.

I'd like the code to allow for any kind of comment to be created (but that will require a bit of refinement). Another interesting usecase: easier beta backport accept/decline during T-compiler weekly triage meeting (mentioned a while ago on Zulip) - though this is a bit more trickier because ideally I'd like to backlink a specific message from a Zulip topic.

To really test this webhook I'll need a Zulip test instance (either local or hosted one on their free tier)

Cargo.toml Outdated
@@ -44,6 +44,7 @@ rand = "0.8.5"
ignore = "0.4.18"
postgres-types = { version = "0.2.4", features = ["derive"] }
cron = { version = "0.12.0" }
urlencoding = "2.1.2"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new dependency. not happy about that but I think I need to urlencode the Zulip message URL

src/zulip.rs Outdated
ty: CommentType,
) -> anyhow::Result<String> {
// retrieve the original Zulip message to build the complete URL
let zulip_msg = get_zulip_msg(ctx, message.id).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I get again the full message froim Zulip to rebuild the full message URL to backlink to Zulip che discussion about the assigned priority to the issue

Comment on lines +216 to +220
#[derive(PartialEq)]
enum CommentType {
AssignIssuePriority,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we can send multiple message type to github ...

Comment on lines +284 to +314
comment = format!(
"WG-prioritization assigning priority ([Zulip discussion]({}))
\n\n@rustbot label -I-prioritize +{}",
zulip_msg_link, p_label
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body of the comment that will be created on github. unsure how those newlines behave

src/zulip.rs Outdated
Comment on lines 266 to 274
let zulip_stream = "245100-t-compiler/wg-prioritization/alerts";
let mut zulip_msg_link = format!(
"https://rust-lang.zulipchat.com/#narrow/stream/{}/topic/{}/near/{}",
zulip_stream, zulip_msg.message.subject, message.id
);
// Encode url and replace "%" with "."
// (apparently Zulip does that to public URLs)
urlencoding::encode(&zulip_msg_link);
zulip_msg_link = zulip_msg_link.replace("%", ".");
Copy link
Contributor Author

@apiraino apiraino Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final Zulip link should look something like this:

https://rust-lang.zulipchat.com/#narrow/stream/245100-t-compiler.2Fwg-prioritization.2Falerts/topic/.23107094.20.60rustdoc.20--version.20--verbose.60.20no.20longer.20displays.20co.E2.80.A6/near/350696000

Where the only dynamic parts are the Zulip topic and the ID of the message

@apiraino apiraino force-pushed the triagebot-assign-prio branch from e50aef6 to 51013c9 Compare April 24, 2023 16:09
In this first version triagebot learns how to post a comment on GitHub
to assign priority to an issue marked as regression.

The code should allow for any kind of comment to be created.
@apiraino apiraino force-pushed the triagebot-assign-prio branch from 51013c9 to 22b1128 Compare April 24, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant