-
Notifications
You must be signed in to change notification settings - Fork 97
Fix backport label handler #2245
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
base: master
Are you sure you want to change the base?
Conversation
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'm not sure if I understand the change, to be honest 😅 Is it about beta nomination not being triggered when the PR is already stable nominated, and vice versa?
I would expect that if we receive IssuesAction::Labeled { label: FOO }, then pr.labels will already contain FOO. Have you checked whether that's the case or not? 🤔
265da83 to
502c371
Compare
The fix here basically is:
makes sense? |
|
Ah, makes sense, thanks! I think that in the latest commit you just changed the code so that it will simply ignore all labels? |
26e7bca to
fb54275
Compare
|
ah yes you're right, I thought we didn't need it but ofc we do. Thanks for the review! |
src/handlers/backport.rs
Outdated
| if let IssuesAction::Labeled { label } = &event.action | ||
| && BACKPORT_ACCEPTED_LABELS.contains(&label.name.as_str()) | ||
| { | ||
| if contains_any(&pr_labels, &BACKPORT_ACCEPTED_LABELS) { |
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 will have the same bug as before, right? If the PR is already beta-accepted, it will stop the handler here once stable-accepted is added.
You'll need to separate the labels on the axis of beta/stable, rather than nominated/accepted.
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 ... you're right but the solution is more complex that separating on another axis. I'm afraid I'll need to map all possible cases (4 labels = 16 cases) and then see if I can reduce to a couple of ifs.
In any case, I want to keep it simple: if this does not work, I have another patch to add "negated labels" when sending zulip notification, that would solve the issue from another point of view.
I'll be back on this.
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't just remove this:
if contains_any(&pr_labels, &BACKPORT_LABELS) {
log::debug!("PR #{} already has a backport label", pr.number);
return Ok(None);
}? Seems like the bug is just caused by this.
Btw, I tested that once you receive the Labeled { label: "foo" } event, then pr.labels() already contains foo.
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.
sorry, I am confused by your comment: isn't that chunk of code removed in this patch? Or did you mean to just remove that code without adding anything else?
In the latter case, I think that not checking labels would open up to confusion when adding regression labels (which was the point of this patch).
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 meant remove without adding anything else. Say that we remove the original check - what will be the problematic situations that could be caused in that case? Adding -nominated once there is already -accepted? Or something else? I don't know what is a "regression label", it wasn't mentioned in this PR so far 😅
66063d5 to
6516a34
Compare
|
ok @Kobzol I've reworked this patch and tried to simplify as much as possible to keep the scope small and clear (I have edited title and commit desc to reflect this). Now hopefully the logic should be clearer: with this patch I want to avoid that a backport accepted PR be nominated again. If a -nominated label is added, the handler will revert that. As you suggested I am now checking on the naminated/accepted "axis" instead of the beta/stable. Note: this won't block creating the Zulip backport poll but it can only be handled in the Let me know if now sounds better. Thanks. |
src/handlers/backport.rs
Outdated
| return Ok(None); | ||
|
|
||
| // If a "-nominated" label is added to an already "-accepted" PR, remove the label added by github | ||
| if let IssuesAction::Labeled { label } = &event.action |
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.
Just to make sure that it is intended, this logic means that if the PR was e.g. beta accepted previously, it then cannot be also stable nominated.
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.
OK @Kobzol I give up in trying to make this check "smart", I thought I will just hardcode the only two cases I was actually interested in preventing.
wdty?
6516a34 to
b344381
Compare
b344381 to
6be41b9
Compare
src/handlers/backport.rs
Outdated
| let _ = &event | ||
| .issue | ||
| .remove_labels(&ctx.github, label_to_remove) | ||
| .await | ||
| .context("failed to remove labels from the issue") | ||
| .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.
Removing a label after it was added using the GH UI will produce a strange "add label / remove label" events one after the other. This will be solved after we have negated labels rule (as mentioned elsewhere here). That will prevent triggering this handler.
(removing the .unwrap())
| @@ -86,7 +97,7 @@ pub(super) async fn parse_input( | |||
| cfg.required_pr_labels.iter().map(String::as_str).collect(); | |||
| if !contains_any(&pr_labels, &required_pr_labels) { | |||
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 discovered that this check (contains_any on required_pr_labels) has a little bug: If the triagebot configuration is something like:
required-pr-labels = ["t-libs", "t-libs-api"]
this handler will run twice. This is fixable in different ways (in another patch), I just wanted to leave a note about it.
…proved. Revert the `-nominated` label that was added on GitHub.
73fd160 to
19f869b
Compare
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 actually wanted to propose this, I think it's the best solution for now 😆
Do not allow nominating for backport a PR that is already backport approved.
Revert the
-nominatedlabel that was added on GitHub.r? @Kobzol
thanks