-
Notifications
You must be signed in to change notification settings - Fork 85
Add glacier
command to track ICEs
#526
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
Conversation
parser/src/command/glacier.rs
Outdated
match toks.next_token()? { | ||
Some(Token::Quote(s)) => { | ||
let source = s.to_owned(); | ||
let playground_url = Regex::new("https://play.rust-lang.org/.*").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using starts_with
? I don't like using a regex for this case, because you pull in the crate just for this piece and you could circumvent it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good suggestion! It didn't cross my mind, heh.
Status update: Currently waiting on XAMPPRocky/octocrab#12 to be merged to allow me to do this cleanly. |
@Elinvynia XAMPPRocky/octocrab#12 has been merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks promising overall :)
src/handlers/glacier.rs
Outdated
let number = event.issue().unwrap().number; | ||
let user = event.user(); | ||
|
||
let octocrab = octocrab::instance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As asked by @Mark-Simulacrum, we should not use the static instance here. Let's store it in Context
alongside the GithubClient
src/handlers/glacier.rs
Outdated
|
||
let octocrab = octocrab::instance(); | ||
|
||
let fork = octocrab.repos("rust-lang", "glacier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we @Mark-Simulacrum will create a fork for the bot, so to not pollute the main rust-lang/glacier
repository? In that case you just need to set the owner to "rustbot"
instead of "rust-lang"
src/handlers/glacier.rs
Outdated
}; | ||
|
||
fork.create_ref(&Reference::Branch(format!("triagebot-ice-{}", number)), master).await?; | ||
fork.create_file(format!("ices/{}.rs", number), format!("This PR was created by {} on issue {}.", user.login, number), body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is actually the commit message. You probably want to change that, to something like "Add ICE reproduction for issue #{}"?
src/handlers/glacier.rs
Outdated
|
||
fork.create_ref(&Reference::Branch(format!("triagebot-ice-{}", number)), master).await?; | ||
fork.create_file(format!("ices/{}.rs", number), format!("This PR was created by {} on issue {}.", user.login, number), body) | ||
.branch("triagebot-ice") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the branch you created earlier.
.branch("triagebot-ice") | |
.branch(format!("triagebot-ice-{}", number)) |
src/handlers/glacier.rs
Outdated
|
||
octocrab.pulls("rust-lang", "glacier") | ||
.create(format!("ICE - {}", number), format!("triagebot-ice-{}", number), "master") | ||
.body("This is a fake new catastrophic avalanche of ICE!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the body (description) of the PR. Let's change it to something like "Automatically created by @{} in issue #{}"
src/handlers/glacier.rs
Outdated
.await?; | ||
|
||
octocrab.pulls("rust-lang", "glacier") | ||
.create(format!("ICE - {}", number), format!("triagebot-ice-{}", number), "master") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we actually create a fork for rustbot, you'll need to set this to "rustbot:triagebot-ice-{}"
src/handlers/glacier.rs
Outdated
}; | ||
|
||
let url = cmd.source; | ||
let response = reqwest::get(&format!("{}{}", url.replace("github", "githubusercontent"), "/playground.rs")).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the reqwest::Client
inside of the GithubClient
using GithubClient::raw
parser/src/command/glacier.rs
Outdated
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Self::NoLink => write!(f, "no link provided"), | ||
Self::InvalidLink => write!(f, "invalid link"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's note here that it should be a link to a gist.
parser/src/command/glacier.rs
Outdated
impl fmt::Display for ParseError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Self::NoLink => write!(f, "no link provided"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should note the requirement for quotes around the link.
src/handlers/glacier.rs
Outdated
|
||
match event { | ||
Event::IssueComment(_) => (), | ||
_ => {return Ok(None);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to run on newly opened issues too, not just comments?
src/handlers/glacier.rs
Outdated
Command::Glacier(Ok(command)) => Ok(Some(command)), | ||
Command::Glacier(Err(err)) => { | ||
return Err(format!( | ||
"Parsing assign command in [comment]({}) failed: {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: glacier, not assign command.
src/handlers/glacier.rs
Outdated
let master = if let Object::Commit { sha, ..} = master { | ||
sha | ||
} else { | ||
panic!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the actual value of master here so that we can debug if it does occur.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I think this should be unreachable!()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless, we should note what we actually encountered.
panic!() | ||
}; | ||
|
||
fork.create_ref(&Reference::Branch(format!("triagebot-ice-{}", number)), master).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this fail if the branch already exists? Sometimes we have multiple distinct examples for a single ICE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honesly I am not sure what happens here, how should we proceed? Append a random string and hope for no conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to leave as is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see octocrab moved to a crates.io dependency before merging, and I've also asked @XAMPPRocky over zulip to see if we can use a subset of tokio's feature flags rather than full.
Other than that, this looks good!
Co-authored-by: XAMPPRocky <[email protected]>
This is building on the work done in #234, huge props to @hellow554 for the initial effort!
I have no idea how to run the bot, but the tests I added pass.