-
Notifications
You must be signed in to change notification settings - Fork 67
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
Human friendly incantations + Auto Closing/Postponing RFCs + More labels #197
Human friendly incantations + Auto Closing/Postponing RFCs + More labels #197
Conversation
Hmm... The error arises from failing to compile |
Update: I updated the lockfile & bumped the nightly version to 2018-04-19; this seems to have fixed things. |
These changes look fantastic to me! I only have one concern: right now, once an RFC is in FCP, adding a concern doesn't take it back out of FCP. That'd be nice to improve in general, and it becomes even more important if the bot is going to automatically close RFCs. |
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.
src/github/nag.rs
Outdated
@@ -143,6 +158,26 @@ fn update_proposal_review_status(proposal_id: i32) -> DashResult<()> { | |||
Ok(()) | |||
} | |||
|
|||
fn remove_issue_label(issue: &Issue, label: &str) { |
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 think these might be a bit clearer if they were methods on Issue, rather than free fns
src/github/nag.rs
Outdated
GH.add_label(&issue.repository, issue.number, label) | ||
} | ||
|
||
fn close_pull_request(issue: &Issue) { |
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 fn signature makes me sad that PRs are represented as Issues internally. At a minimum can you make a TODO or open an issue to make this type-safe and only apply to PRs but not issues? If GH.close_pr
will correctly work on an issue even though it hits the pulls
endpoint, can we call all of this close_issue
and continue assuming issues and PRs are roughly the same?
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.
It is good that you flagged this; I did some tests with curl on a dummy repo, https://github.com/Centril/test-gh-api, and closed both a PR and an issue with the issues
endpoint. I also noticed a bug (s/status/state).
.first::<GitHubUser>(conn) { | ||
Ok(i) => i, | ||
Err(why) => { | ||
error!("Unable to retrieve proposal initiator for proposal id {}: {:?}", |
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 need to double check the schema, but I'm pretty sure the database ensures this never happens and so this can probably be safely written as an expect.
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.
For now, to be on the safe side I'll keep the match. I'll change later if you are sure. :)
src/github/nag.rs
Outdated
if is_rfc_repo(&issue) { | ||
match disp { | ||
FcpDisposition::Merge => { | ||
// TODO: This one will require a lot of work to |
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.
Can you start an issue for this? I'm not even sure what the "right" strategy is going to be and it will require some discussion.
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.
Done :) #198
src/github/nag.rs
Outdated
|
||
// Execute FFCP actions: | ||
if is_rfc_repo(&issue) { | ||
match disp { |
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.
Can you make this match statement into a method on FcpDisposition
?
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 extracted the logic starting from the comment into a free function execute_ffcp_actions
to reduce rightward drift. It didn't really feel like belonging to FcpDisposition
given that it depends on an event :)
src/github/nag.rs
Outdated
@@ -16,6 +16,21 @@ use github::models::CommentFromJson; | |||
use teams::TEAMS; | |||
use super::GH; | |||
|
|||
const LABEL_FFCP: &'static str = "finished-final-comment-period"; |
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.
Can you make these into (an enum|a set of enums) that have as_str()
?
}, | ||
} | ||
|
||
fn is_rfc_repo(issue: &Issue) -> bool { |
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.
Can you make this a part of teams.toml
(maybe rename to rfcbot.toml
and move current fields under a top-level teams key)? It would be very nice to not regress progress towards #92.
src/github/nag.rs
Outdated
@@ -898,6 +1003,14 @@ impl<'a> RfcBotComment<'a> { | |||
} | |||
} | |||
|
|||
fn couldnt_add_label<'b>(msg: &mut String, author: &'b GitHubUser, label: &str) { | |||
msg.push_str("\n\n*psst @"); |
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'd be ok with this being a call to format!
-- in hindsight I think it was a big mistake to be concerned about allocation performance here.
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.
Hmm... can we fix this later as a more general refactoring of message formats and potential templating?
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.
sgtm
match disposition { | ||
FcpDisposition::Merge => {} | ||
FcpDisposition::Close => { | ||
msg.push_str("\n\nBy the power vested in me by Rust, I hereby close this RFC."); |
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.
Note that this won't be an accurate comment to post until rfcbot is given more permissions on the rust-lang
org. Can we make this conditional on whether actually closing the issue succeeded? That might require a slight change to order of operations.
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.
Then you have to close the issue first which looks a bit weird imo. The current ordering feels natural as how a human would do it :) We should just give the bot these permissions imo.
if proposal.fcp_start.is_some() { | ||
// Update DB: FCP is not started anymore. | ||
proposal.fcp_start = None; | ||
match diesel::update(fcp_proposal.find(proposal.id)) |
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.
Do you think the bot should comment when it's doing this? Could be confusing to do this without any visible status update?
cc @aturon
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.
My thinking is that:
let _ = issue.add_label(Label::PFCP);
issue.remove_label(Label::FCP);
serves as visible status update that the bot reacted to the concern :)
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.
Yeah I think that suffices, given that the concern registration is already a comment.
Hi @Centril! If I'm reading correctly, the only thing remaining is to configure the RFCs repo string via a configuration file. If that's the case, let's get this in and create a follow-up issue or add a comment on the issue I linked before? |
@anp that works for me :) Sorry about not following up on this sooner. One thing I'm a bit unsure about as to making this work for all repos is whether there is one instance of the rfcbot program running for rust-lang/rust and rust-lang/rfcs or if there are separate instances for each. If there is just one instance, then you need to be able to configure close / postpone behavior separately for each repo. For now I propose: [fcp_behaviour."rust-lang/rfcs"]
close = true
postpone = true
[teams]
# other stuff.... |
Thank you so much! |
This PR aims to fix:
finished-final-comment-period
+ labels for disposition)In addition, the PR improves the FCP-completed comment and also auto-closes FCP-completed RFCs with a disposition to
close
/postponed
and applies those labels when doing so.I haven't had time to test this on any repository, so please double check this logic =)
I also haven't added the new labels to the rfcs or rust repos. I'll do that before / if we merge this PR.
In total, these labels are added:
The
postponed
label already exists for the rfcs repo.