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

mozilla / relman-auto-nag / #5168

17 Jul 2024 07:40PM CUT coverage: 21.692% (-0.07%) from 21.766%
#5168

push

coveralls-python

benjaminmah
Separated `no_severity` rule into two separate rules

585 of 3499 branches covered (16.72%)

0 of 108 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

1933 of 8911 relevant lines covered (21.69%)

0.22 hits per line

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

0.0
/bugbot/rules/workflow/no_severity_nag.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

NEW
5
from datetime import datetime
×
6

NEW
7
import numpy
×
NEW
8
from libmozdata import utils as lmdutils
×
9

NEW
10
from bugbot import utils
×
NEW
11
from bugbot.bzcleaner import BzCleaner
×
NEW
12
from bugbot.escalation import Escalation
×
NEW
13
from bugbot.nag_me import Nag
×
NEW
14
from bugbot.round_robin import RoundRobin
×
15

16

NEW
17
class NoSeverityNag(BzCleaner, Nag):
×
NEW
18
    def __init__(self, inactivity_days: int = 4):
×
19
        """Constructor
20

21
        Args:
22
            inactivity_days: number of days that a bug should be inactive before
23
                being considered.
24
        """
NEW
25
        super(NoSeverityNag, self).__init__()
×
NEW
26
        self.lookup_second = utils.get_config(self.name(), "weeks_lookup", 4)
×
NEW
27
        self.escalation = Escalation(
×
28
            self.people,
29
            data=utils.get_config(self.name(), "escalation-{}".format("second")),
30
            skiplist=utils.get_config("workflow", "supervisor_skiplist", []),
31
        )
NEW
32
        self.round_robin = RoundRobin.get_instance()
×
NEW
33
        self.components_skiplist = utils.get_config("workflow", "components_skiplist")
×
NEW
34
        self.activity_date = str(
×
35
            numpy.busday_offset(lmdutils.get_date("today"), -inactivity_days)
36
        )
37

NEW
38
    def description(self):
×
NEW
39
        return "Bugs without a severity or statuses set"
×
40

NEW
41
    def nag_template(self):
×
NEW
42
        return self.template()
×
43

NEW
44
    def nag_preamble(self):
×
NEW
45
        return """<p>
×
46
  <ul>
47
    <li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/policies/triage-bugzilla.html#why-triage">Why triage?</a></li>
48
    <li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/policies/triage-bugzilla.html#what-do-you-triage">What do you triage?</a></li>
49
    <li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/guides/priority.html">Priority definitions</a></li>
50
    <li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/guides/severity.html">Severity definitions</a></li>
51
  </ul>
52
</p>"""
53

NEW
54
    def get_extra_for_template(self):
×
NEW
55
        return {"nweeks": self.lookup_second}
×
56

NEW
57
    def get_extra_for_nag_template(self):
×
NEW
58
        return self.get_extra_for_template()
×
59

NEW
60
    def has_product_component(self):
×
NEW
61
        return True
×
62

NEW
63
    def ignore_meta(self):
×
NEW
64
        return True
×
65

NEW
66
    def columns(self):
×
NEW
67
        return ["product", "component", "id", "summary"]
×
68

NEW
69
    def handle_bug(self, bug, data):
×
NEW
70
        if (
×
71
            # check if the product::component is in the list
72
            utils.check_product_component(self.components_skiplist, bug)
73
            or utils.get_last_no_bot_comment_date(bug) > self.activity_date
74
        ):
NEW
75
            return None
×
NEW
76
        return bug
×
77

NEW
78
    def set_people_to_nag(self, bug, buginfo):
×
NEW
79
        priority = "default"
×
NEW
80
        if not self.filter_bug(priority):
×
NEW
81
            return None
×
82

NEW
83
        owners = self.round_robin.get(bug, self.date, only_one=False, has_nick=False)
×
NEW
84
        real_owner = bug["triage_owner"]
×
NEW
85
        self.add_triage_owner(owners, real_owner=real_owner)
×
NEW
86
        if not self.add(owners, buginfo, priority=priority):
×
NEW
87
            self.add_no_manager(buginfo["id"])
×
NEW
88
        return bug
×
89

NEW
90
    def get_bz_params(self, date):
×
NEW
91
        fields = [
×
92
            "triage_owner",
93
            "flags",
94
            "comments.creator",
95
            "comments.creation_time",
96
        ]
NEW
97
        params = {
×
98
            "include_fields": fields,
99
            "keywords": "intermittent-failure",
100
            "keywords_type": "nowords",
101
            "email2": "wptsync@mozilla.bugs",
102
            "emailreporter2": "1",
103
            "emailtype2": "notequals",
104
            "resolution": "---",
105
            "f31": "bug_type",
106
            "o31": "equals",
107
            "v31": "defect",
108
            "f32": "flagtypes.name",
109
            "o32": "notsubstring",
110
            "v32": "needinfo?",
111
            "f33": "bug_severity",
112
            "o33": "anyexact",
113
            "v33": "--, n/a",
114
        }
NEW
115
        self.date = lmdutils.get_date_ymd(date)
×
NEW
116
        second = f"-{self.lookup_second * 7}d"
×
NEW
117
        params.update(
×
118
            {
119
                "j2": "OR",
120
                "f2": "OP",
121
                "j3": "AND",
122
                "f3": "OP",
123
                "f4": "product",
124
                "o4": "changedbefore",
125
                "v4": second,
126
                "n5": 1,
127
                "f5": "product",
128
                "o5": "changedafter",
129
                "v5": second,
130
                "n6": 1,
131
                "f6": "component",
132
                "o6": "changedafter",
133
                "v6": second,
134
                "f7": "CP",
135
                "j8": "AND",
136
                "f8": "OP",
137
                "f9": "component",
138
                "o9": "changedbefore",
139
                "v9": second,
140
                "n10": 1,
141
                "f10": "product",
142
                "o10": "changedafter",
143
                "v10": second,
144
                "n11": 1,
145
                "f11": "component",
146
                "o11": "changedafter",
147
                "v11": second,
148
                "f12": "CP",
149
                "j13": "AND",
150
                "f13": "OP",
151
                "f14": "creation_ts",
152
                "o14": "lessthaneq",
153
                "v14": second,
154
                "n15": 1,
155
                "f15": "product",
156
                "o15": "everchanged",
157
                "n16": 1,
158
                "f16": "component",
159
                "o16": "everchanged",
160
                "f17": "CP",
161
                "f18": "CP",
162
                "n20": 1,
163
                "j20": "OR",
164
                "f20": "OP",
165
                "f21": "bug_severity",
166
                "o21": "changedfrom",
167
                "v21": "critical",
168
                "f22": "bug_severity",
169
                "o22": "changedfrom",
170
                "v22": "major",
171
                "f23": "bug_severity",
172
                "o23": "changedfrom",
173
                "v23": "blocker",
174
                "f30": "CP",
175
            }
176
        )
177

178
        # TODO: the following code can be removed in 2024.
179
        # https://github.com/mozilla/bugbot/issues/1596
180
        # Almost 500 old bugs have no severity set. The intent of the following
181
        # is to have them triaged in batches where every week we include more
182
        # bugs. Once the list of old bugs are reduced, we could safely remove
183
        # the following code.
NEW
184
        passed_time = datetime.now() - datetime.fromisoformat("2023-06-09")
×
NEW
185
        oldest_bug_months = 56 + passed_time.days
×
NEW
186
        n = utils.get_last_field_num(params)
×
NEW
187
        params.update(
×
188
            {
189
                f"f{n}": "creation_ts",
190
                f"o{n}": "greaterthan",
191
                f"v{n}": f"-{oldest_bug_months}m",
192
            }
193
        )
194

NEW
195
        return params
×
196

197

NEW
198
if __name__ == "__main__":
×
NEW
199
    NoSeverityNag().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