-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tool 'uplift_beta' to set a ni when a bug is fixed in nightly a…
…nd is affecting beta (#912) * Add a tool 'uplift_beta' to set a ni when a bug is fixed in nightly and is affecting beta * Remove useless code we can have in the bz query and fix nits
- Loading branch information
1 parent
78104fd
commit 8a93526
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -638,5 +638,8 @@ | |
}, | ||
"close_intermittents": { | ||
"sec": false | ||
}, | ||
"uplift_beta": { | ||
"days_to_wait": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from libmozdata import utils as lmdutils | ||
from libmozdata.bugzilla import Bugzilla | ||
|
||
from auto_nag import utils | ||
from auto_nag.bzcleaner import BzCleaner | ||
|
||
|
||
class UpliftBeta(BzCleaner): | ||
def __init__(self): | ||
super(UpliftBeta, self).__init__() | ||
if not self.init_versions(): | ||
return | ||
|
||
self.beta = self.versions["beta"] | ||
self.status_central = utils.get_flag( | ||
self.versions["central"], "status", "central" | ||
) | ||
self.status_beta = utils.get_flag(self.beta, "status", "beta") | ||
self.extra_ni = {} | ||
|
||
def description(self): | ||
return "Bugs fixed in nightly but still affecting beta" | ||
|
||
def has_assignee(self): | ||
return True | ||
|
||
def get_extra_for_needinfo_template(self): | ||
return self.extra_ni | ||
|
||
def columns(self): | ||
return ["id", "summary", "assignee"] | ||
|
||
def handle_bug(self, bug, data): | ||
bugid = str(bug["id"]) | ||
|
||
assignee = bug.get("assigned_to", "") | ||
if utils.is_no_assignee(assignee): | ||
assignee = "" | ||
nickname = "" | ||
else: | ||
nickname = bug["assigned_to_detail"]["nick"] | ||
|
||
data[bugid] = { | ||
"id": bugid, | ||
"mail": assignee, | ||
"nickname": nickname, | ||
"summary": self.get_summary(bug), | ||
"regressions": bug["regressions"], | ||
} | ||
return bug | ||
|
||
def filter_by_regr(self, bugs): | ||
# Filter the bugs which don't have any regression or where the regressions are all closed | ||
def bug_handler(bug, data): | ||
if bug["status"] in {"RESOLVED", "VERIFIED", "CLOSED"}: | ||
data.add(bug["id"]) | ||
|
||
bugids = {r for info in bugs.values() for r in info["regressions"]} | ||
if not bugids: | ||
return bugs | ||
|
||
fixed_bugs = set() | ||
Bugzilla( | ||
bugids=list(bugids), | ||
include_fields=["id", "status"], | ||
bughandler=bug_handler, | ||
bugdata=fixed_bugs, | ||
).get_data().wait() | ||
|
||
bugs_without_regr = {} | ||
for bugid, info in bugs.items(): | ||
regs = set(info["regression"]) | ||
regs = regs - fixed_bugs | ||
if not regs: | ||
bugs_without_regr[bugid] = info | ||
|
||
return bugs_without_regr | ||
|
||
def get_bz_params(self, date): | ||
self.date = lmdutils.get_date_ymd(date) | ||
to_wait = self.get_config("days_to_wait") | ||
fields = [self.status_beta, "regressions"] | ||
params = { | ||
"include_fields": fields, | ||
"bug_type": "defect", | ||
"resolution": ["---", "FIXED"], | ||
"f1": self.status_central, | ||
"o1": "anyexact", | ||
"v1": ",".join(["fixed", "verified"]), | ||
"f2": self.status_beta, | ||
"o2": "anyexact", | ||
"v2": "affected", | ||
# Changed before 2 days ago and not changed after 2 days ago | ||
# So we get bugs where the last status_central change (fixed or verified) | ||
# was 2 days ago | ||
"f3": self.status_central, | ||
"o3": "changedbefore", | ||
"v3": f"-{to_wait}d", | ||
"n4": 1, | ||
"f4": self.status_central, | ||
"o4": "changedafter", | ||
"v4": f"-{to_wait}d", | ||
# | ||
"f5": "flagtypes.name", | ||
"o5": "notsubstring", | ||
"v5": "approval-mozilla-beta", | ||
"f6": "flagtypes.name", | ||
"o6": "notsubstring", | ||
"v6": "needinfo", | ||
# Don't nag several times | ||
"n7": 1, | ||
"f7": "longdesc", | ||
"o7": "casesubstring", | ||
# this a part of the comment we've in templates/uplift_beta_needinfo.txt | ||
"v7": ", is this bug important enough to require an uplift?", | ||
} | ||
|
||
return params | ||
|
||
def get_bugs(self, date="today", bug_ids=[]): | ||
bugs = super(UpliftBeta, self).get_bugs(date=date, bug_ids=bug_ids) | ||
bugs = self.filter_by_regr(bugs) | ||
|
||
for bugid, data in bugs.items(): | ||
if data["mail"] and data["nickname"]: | ||
self.extra_ni[bugid] = {"regression": len(data["regressions"])} | ||
self.add_auto_ni( | ||
bugid, {"mail": data["mail"], "nickname": data["nickname"]} | ||
) | ||
|
||
return bugs | ||
|
||
|
||
if __name__ == "__main__": | ||
UpliftBeta().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<p>The following {{ plural('bug has', data, pword='bugs have') }} been fixed in nightly and {{ plural('is', data, pword='are') }} affecting beta. {{ plural('Assignee', data) }} got a needinfo to ask if it's worth uplifting the patches: | ||
<table {{ table_attrs }}> | ||
<thead> | ||
<tr> | ||
<th>Bug</th><th>Summary</th><th>Assignee</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for i, (bugid, summary, assignee) in enumerate(data) -%} | ||
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"{% endif -%}> | ||
<td> | ||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a> | ||
</td> | ||
<td> | ||
{{ summary | e }} | ||
</td> | ||
<td> | ||
{{ assignee | e }} | ||
</td> | ||
</tr> | ||
{% endfor -%} | ||
</tbody> | ||
</table> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
The patch landed in nightly and beta is affected. | ||
:{{ nickname }}, is this bug important enough to require an uplift? | ||
If not please set `status_beta` to `wontfix`. | ||
{% if extra[bugid]["regression"] -%}If yes, don't forget to request an uplift for the patches in the {{ plural('regression', extra[bugid]["regression"]) }} caused by this fix.{% endif %} | ||
|
||
{{ documentation }} |