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

mozilla / relman-auto-nag / #5313

04 Nov 2024 09:17PM CUT coverage: 21.667% (+0.007%) from 21.66%
#5313

push

coveralls-python

benjaminmah
Removed unnecessary fields and cleaned up code

426 of 2874 branches covered (14.82%)

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

1942 of 8963 relevant lines covered (21.67%)

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
        if self.is_needinfo_on_assignee(bug.get("flags", []), assignee):
×
50
            return None
×
51

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

60
        return bug
×
61

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

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

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

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

87
        return bugs_without_regr
×
88

89
    def is_needinfo_on_assignee(self, flags, assignee):
×
NEW
90
        return any(
×
91
            flag["name"] == "needinfo"
92
            and flag["status"] == "?"
93
            and flag["requestee"] == assignee
94
            for flag in flags
95
        )
96

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

138
        return params
×
139

140
    def get_bugs(self, date="today", bug_ids=[]):
×
141
        bugs = super(UpliftBeta, self).get_bugs(date=date, bug_ids=bug_ids)
×
142
        bugs = self.filter_by_regr(bugs)
×
143

144
        for bugid, data in bugs.items():
×
145
            if data["mail"] and data["nickname"]:
×
146
                self.extra_ni[bugid] = {"regression": len(data["regressions"])}
×
147
                self.add_auto_ni(
×
148
                    bugid, {"mail": data["mail"], "nickname": data["nickname"]}
149
                )
150

151
        return bugs
×
152

153

154
if __name__ == "__main__":
×
155
    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