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

mozilla / relman-auto-nag / #4349

pending completion
#4349

push

coveralls-python

sosa-e
Revert "Minimizing config file"

This reverts commit 614159597.

564 of 3081 branches covered (18.31%)

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

1804 of 7980 relevant lines covered (22.61%)

0.23 hits per line

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

0.0
/auto_nag/scripts/regression.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 auto_nag.bugbug_utils import get_bug_ids_classification
×
6
from auto_nag.bzcleaner import BzCleaner
×
7
from auto_nag.utils import nice_round
×
8

9

10
class Regression(BzCleaner):
×
11
    def __init__(self):
×
12
        super().__init__()
×
13
        self.autofix_regression = []
×
14

15
    def description(self):
×
16
        return "[Using ML] Bugs with missing regression keyword"
×
17

18
    def columns(self):
×
19
        return ["id", "summary", "confidence", "autofixed"]
×
20

21
    def sort_columns(self):
×
22
        return lambda p: (-p[2], -int(p[0]))
×
23

24
    def get_bz_params(self, date):
×
25
        start_date, end_date = self.get_dates(date)
×
26

27
        resolution_skiplist = self.get_config("resolution_skiplist", default=[])
×
28
        resolution_skiplist = " ".join(resolution_skiplist)
×
29

30
        reporter_skiplist = self.get_config("reporter_skiplist", default=[])
×
31
        reporter_skiplist = ",".join(reporter_skiplist)
×
32

33
        params = {
×
34
            "include_fields": ["id", "groups", "summary"],
35
            "bug_type": "defect",
36
            "f1": "keywords",
37
            "o1": "nowords",
38
            "v1": "regression,feature,meta",
39
            "f2": "resolution",
40
            "o2": "nowords",
41
            "v2": resolution_skiplist,
42
            "f3": "longdesc",
43
            "o3": "changedafter",
44
            "v3": start_date,
45
            "f4": "reporter",
46
            "o4": "nowords",
47
            "v4": reporter_skiplist,
48
        }
49

50
        return params
×
51

52
    def get_bugs(self, date="today", bug_ids=[]):
×
53
        # Retrieve the bugs with the fields defined in get_bz_params
54
        raw_bugs = super().get_bugs(date=date, bug_ids=bug_ids, chunk_size=7000)
×
55

56
        if len(raw_bugs) == 0:
×
57
            return {}
×
58

59
        # Extract the bug ids
60
        bug_ids = list(raw_bugs.keys())
×
61

62
        # Classify those bugs
63
        bugs = get_bug_ids_classification("regression", bug_ids)
×
64

65
        results = {}
×
66

67
        for bug_id in sorted(bugs.keys()):
×
68
            bug_data = bugs[bug_id]
×
69

70
            if not bug_data.get("available", True):
×
71
                # The bug was not available, it was either removed or is a
72
                # security bug
73
                continue
×
74

75
            if not {"prob"}.issubset(bug_data.keys()):
×
76
                raise Exception(f"Invalid bug response {bug_id}: {bug_data!r}")
×
77

78
            bug = raw_bugs[bug_id]
×
79
            prob = bug_data["prob"]
×
80

81
            if prob[1] < 0.5:
×
82
                continue
×
83

84
            bug_id = str(bug_id)
×
85
            results[bug_id] = {
×
86
                "id": bug_id,
87
                "summary": bug["summary"],
88
                "confidence": nice_round(prob[1]),
89
                "autofixed": False,
90
            }
91

92
            # Only autofix results for which we are sure enough.
93
            if prob[1] >= self.get_config("confidence_threshold"):
×
94
                results[bug_id]["autofixed"] = True
×
95
                self.autofix_regression.append((bug_id, prob[1]))
×
96

97
        return results
×
98

99
    def get_autofix_change(self):
×
100
        cc = self.get_config("cc")
×
101

102
        autofix_change = {}
×
103
        for bug_id, confidence in self.autofix_regression:
×
104
            autofix_change[bug_id] = {
×
105
                "keywords": {"add": ["regression"]},
106
                "cc": {"add": cc},
107
            }
108

109
            if confidence != 1.0:
×
110
                autofix_change[bug_id]["comment"] = {
×
111
                    "body": "The [Bugbug](https://github.com/mozilla/bugbug/) bot thinks this bug is a regression, but please revert this change in case of error."
112
                }
113

114
        return autofix_change
×
115

116

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