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

mozilla / relman-auto-nag / #5299

31 Oct 2024 12:12PM CUT coverage: 21.57% (-0.09%) from 21.659%
#5299

push

coveralls-python

gmierz
Clean up code.

426 of 2888 branches covered (14.75%)

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

13 existing lines in 1 file now uncovered.

1943 of 9008 relevant lines covered (21.57%)

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
        }
56
        return bug
×
57

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

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

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

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

83
        return bugs_without_regr
×
84

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

UNCOV
127
        return params
×
128

UNCOV
129
    def get_bugs(self, date="today", bug_ids=[]):
×
UNCOV
130
        bugs = super(UpliftBeta, self).get_bugs(date=date, bug_ids=bug_ids)
×
UNCOV
131
        bugs = self.filter_by_regr(bugs)
×
132

UNCOV
133
        for bugid, data in bugs.items():
×
UNCOV
134
            if data["mail"] and data["nickname"]:
×
UNCOV
135
                self.extra_ni[bugid] = {"regression": len(data["regressions"])}
×
UNCOV
136
                self.add_auto_ni(
×
137
                    bugid, {"mail": data["mail"], "nickname": data["nickname"]}
138
                )
139

UNCOV
140
        return bugs
×
141

142

UNCOV
143
if __name__ == "__main__":
×
UNCOV
144
    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