• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #5305

01 Nov 2024 03:38PM UTC coverage: 21.652% (-0.007%) from 21.659%
#5305

push

coveralls-python

benjaminmah
Removed second Bugzilla call, included data in fields

426 of 2876 branches covered (14.81%)

0 of 3 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

1942 of 8969 relevant lines covered (21.65%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/rules/uplift_beta.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
from libmozdata import utils as lmdutils
×
6
from libmozdata.bugzilla import Bugzilla
×
7

8
from bugbot import utils
×
9
from bugbot.bzcleaner import BzCleaner
×
10

11

12
class UpliftBeta(BzCleaner):
×
13
    def __init__(self):
×
14
        super(UpliftBeta, self).__init__()
×
15
        if not self.init_versions():
×
16
            return
×
17

18
        self.beta = self.versions["beta"]
×
19
        self.status_central = utils.get_flag(
×
20
            self.versions["central"], "status", "central"
21
        )
22
        self.status_beta = utils.get_flag(self.beta, "status", "beta")
×
23

24
        # Bugs will be added to `extra_ni` later after being fetched
25
        self.extra_ni = {"status_beta": f"status-firefox{self.beta}"}
×
26

27
    def description(self):
×
28
        return "Bugs fixed in nightly but still affecting beta"
×
29

30
    def has_assignee(self):
×
31
        return True
×
32

33
    def get_extra_for_needinfo_template(self):
×
34
        return self.extra_ni
×
35

36
    def columns(self):
×
37
        return ["id", "summary", "assignee"]
×
38

39
    def handle_bug(self, bug, data):
×
40
        bugid = str(bug["id"])
×
41

42
        assignee = bug.get("assigned_to", "")
×
43
        if utils.is_no_assignee(assignee):
×
44
            assignee = ""
×
45
            nickname = ""
×
46
        else:
47
            nickname = bug["assigned_to_detail"]["nick"]
×
48

49
        data[bugid] = {
×
50
            "id": bugid,
51
            "mail": assignee,
52
            "nickname": nickname,
53
            "summary": self.get_summary(bug),
54
            "regressions": bug["regressions"],
55
            "assigned_to": assignee,
56
            "flags": bug.get("flags", []),
57
        }
58
        return bug
×
59

60
    def filter_by_regr(self, bugs):
×
61
        # Filter the bugs which don't have any regression or where the regressions are all closed
62
        def bug_handler(bug, data):
×
63
            if bug["status"] in {"RESOLVED", "VERIFIED", "CLOSED"}:
×
64
                data.add(bug["id"])
×
65

66
        bugids = {r for info in bugs.values() for r in info["regressions"]}
×
67
        if not bugids:
×
68
            return bugs
×
69

70
        fixed_bugs = set()
×
71
        Bugzilla(
×
72
            bugids=list(bugids),
73
            include_fields=["id", "status"],
74
            bughandler=bug_handler,
75
            bugdata=fixed_bugs,
76
        ).get_data().wait()
77

78
        bugs_without_regr = {}
×
79
        for bugid, info in bugs.items():
×
80
            regs = set(info["regressions"])
×
81
            regs = regs - fixed_bugs
×
82
            if not regs:
×
83
                bugs_without_regr[bugid] = info
×
84

85
        return bugs_without_regr
×
86

87
    def filter_bugs_by_ni(self, bugs):
×
88
        bugs_without_ni_on_assignee = {}
×
89

NEW
90
        for bugid, data in bugs.items():
×
91
            needinfos = [
×
92
                {"requestee": flag["requestee"], "type": flag["name"]}
93
                for flag in data["flags"]
94
                if flag["name"] == "needinfo" and flag["status"] == "?"
95
            ]
96

NEW
97
            assignee = data["assigned_to"]
×
98

99
            ni_for_assignee = any(ni["requestee"] == assignee for ni in needinfos)
×
100

101
            if not ni_for_assignee:
×
NEW
102
                bugs_without_ni_on_assignee[bugid] = data
×
103

104
        return bugs_without_ni_on_assignee
×
105

106
    def get_bz_params(self, date):
×
107
        self.date = lmdutils.get_date_ymd(date)
×
108
        fields = [
×
109
            self.status_beta,
110
            "regressions",
111
            "attachments.creation_time",
112
            "attachments.is_obsolete",
113
            "attachments.content_type",
114
            "cf_last_resolved",
115
            "assigned_to",
116
            "flags",
117
        ]
118
        params = {
×
119
            "include_fields": fields,
120
            "bug_type": "defect",
121
            "resolution": ["---", "FIXED"],
122
            "f1": self.status_central,
123
            "o1": "anyexact",
124
            "v1": ",".join(["fixed", "verified"]),
125
            "f2": self.status_beta,
126
            "o2": "anyexact",
127
            "v2": ["affected", "fix-optional"],
128
            "f3": "flagtypes.name",
129
            "o3": "notsubstring",
130
            "v3": "approval-mozilla-beta",
131
            # Don't nag several times
132
            "n5": 1,
133
            "f5": "longdesc",
134
            "o5": "casesubstring",
135
            # this a part of the comment we've in templates/uplift_beta_needinfo.txt
136
            "v5": ", is this bug important enough to require an uplift?",
137
            # Check if have at least one attachment which is a Phabricator request
138
            "f6": "attachments.mimetype",
139
            "o6": "anyexact",
140
            "v6": ["text/x-phabricator-request", "text/x-github-pull-request"],
141
            # skip if whiteboard contains checkin-needed-beta (e.g. test-only uplift)
142
            "f7": "status_whiteboard",
143
            "o7": "notsubstring",
144
            "v7": "[checkin-needed-beta]",
145
        }
146

147
        return params
×
148

149
    def get_bugs(self, date="today", bug_ids=[]):
×
150
        bugs = super(UpliftBeta, self).get_bugs(date=date, bug_ids=bug_ids)
×
151
        bugs = self.filter_by_regr(bugs)
×
152
        bugs = self.filter_bugs_by_ni(bugs)
×
153

154
        for bugid, data in bugs.items():
×
155
            if data["mail"] and data["nickname"]:
×
156
                self.extra_ni[bugid] = {"regression": len(data["regressions"])}
×
157
                self.add_auto_ni(
×
158
                    bugid, {"mail": data["mail"], "nickname": data["nickname"]}
159
                )
160

161
        return bugs
×
162

163

164
if __name__ == "__main__":
×
165
    UpliftBeta().run()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc