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

mozilla / relman-auto-nag / #4077

pending completion
#4077

push

coveralls-python

suhaibmujahid
Merge remote-tracking branch 'upstream/master' into wiki-missed

549 of 3109 branches covered (17.66%)

615 of 615 new or added lines in 27 files covered. (100.0%)

1773 of 8016 relevant lines covered (22.12%)

0.22 hits per line

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

0.0
/auto_nag/scripts/severity_migration.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

6
from collections import defaultdict
×
7

8
from libmozdata.bugzilla import BugzillaProduct
×
9

10
from auto_nag.bzcleaner import BzCleaner
×
11
from auto_nag.components import ComponentName
×
12

13

14
class SeverityMigration(BzCleaner):
×
15
    """Drop old severities to let teams retriage them.
16

17
    TODO: This script is temporary; it should be removed once all old severities
18
    are dropped.
19
    """
20

21
    def __init__(self):
×
22
        super().__init__()
×
23
        self.component_team = self._get_component_team_mapping()
×
24

25
    def description(self):
×
26
        return "Bugs with old severities"
×
27

28
    def must_run(self, date):
×
29
        return date.weekday() == 0  # Monday
×
30

31
    def columns(self):
×
32
        return ["team_name", "id", "summary"]
×
33

34
    def _get_component_team_mapping(self):
×
35
        result = {}
×
36

37
        def handler(product, data):
×
38
            for component in product["components"]:
×
39
                data[ComponentName(product["name"], component["name"])] = component[
×
40
                    "team_name"
41
                ]
42

43
        BugzillaProduct(
×
44
            product_types="accessible",
45
            include_fields=[
46
                "name",
47
                "components.name",
48
                "components.team_name",
49
            ],
50
            product_handler=handler,
51
            product_data=result,
52
        ).wait()
53

54
        return result
×
55

56
    def handle_bug(self, bug, data):
×
57
        component_name = ComponentName(bug["product"], bug["component"])
×
58
        team_name = self.component_team[component_name]
×
59

60
        bugid = str(bug["id"])
×
61
        data[bugid] = {
×
62
            "team_name": team_name,
63
        }
64

65
        return bug
×
66

67
    def get_bugs(self, date="today", bug_ids=[], chunk_size=None):
×
68
        bugs = super().get_bugs(date, bug_ids, chunk_size)
×
69

70
        team_bugs = defaultdict(list)
×
71
        for bug in bugs.values():
×
72
            team_bugs[bug["team_name"]].append(bug)
×
73

74
        bugs = {
×
75
            bug["id"]: bug
76
            for _bugs in team_bugs.values()
77
            for bug in sorted(_bugs, key=lambda x: x["id"], reverse=True)[:10]
78
        }
79

80
        return bugs
×
81

82
    def get_autofix_change(self):
×
83
        return {
×
84
            "keywords": {"remove": "triaged"},
85
            "severity": "--",
86
            "comment": {
87
                "body": "In the process of [migrating remaining bugs to the new severity system](https://bugzilla.mozilla.org/show_bug.cgi?id=1789259), the severity for this bug cannot be automatically determined. Please retriage this bug using the [new severity system](https://wiki.mozilla.org/BMO/UserGuide/BugFields#bug_severity).",
88
            },
89
        }
90

91
    def filter_no_nag_keyword(self):
×
92
        return False
×
93

94
    def ignore_meta(self):
×
95
        return False
×
96

97
    def has_access_to_sec_bugs(self):
×
98
        return True
×
99

100
    def get_bz_params(self, date):
×
101
        params = {
×
102
            "include_fields": ["product", "component"],
103
            "resolution": "---",
104
            "bug_severity": {"blocker", "critical", "major"},
105
            "f1": "cf_crash_signature",
106
            "o1": "isempty",
107
            "f2": "product",
108
            "o2": "notequals",
109
            "v2": "Testing",
110
            "f3": "keywords",
111
            "o3": "nowords",
112
            "v3": "crash",
113
        }
114

115
        return params
×
116

117

118
if __name__ == "__main__":
×
119
    SeverityMigration().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