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

mozilla / relman-auto-nag / #4538

pending completion
#4538

push

coveralls-python

suhaibmujahid
[uplift_beta] Revert a workaround to handle the new uplift workflow

641 of 3216 branches covered (19.93%)

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

1821 of 7990 relevant lines covered (22.79%)

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

120
        return params
×
121

122
    def get_bugs(self, date="today", bug_ids=[]):
×
123
        bugs = super(UpliftBeta, self).get_bugs(date=date, bug_ids=bug_ids)
×
124
        bugs = self.filter_by_regr(bugs)
×
125

126
        for bugid, data in bugs.items():
×
127
            if data["mail"] and data["nickname"]:
×
128
                self.extra_ni[bugid] = {"regression": len(data["regressions"])}
×
129
                self.add_auto_ni(
×
130
                    bugid, {"mail": data["mail"], "nickname": data["nickname"]}
131
                )
132

133
        return bugs
×
134

135

136
if __name__ == "__main__":
×
137
    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