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

mozilla / relman-auto-nag / #5628

03 Oct 2025 09:53AM UTC coverage: 20.781% (-0.02%) from 20.799%
#5628

push

coveralls-python

marco-c
Don't close intermittent bugs that have recent classifications

Fixes #2451

426 of 3024 branches covered (14.09%)

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

3 existing lines in 2 files now uncovered.

1942 of 9345 relevant lines covered (20.78%)

0.21 hits per line

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

0.0
/bugbot/rules/close_intermittents.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 requests
×
NEW
8
from dateutil.relativedelta import relativedelta
×
9

10
from bugbot.bzcleaner import BzCleaner
×
11
from bugbot.components import ComponentName, fetch_component_teams
×
12

13

14
class Intermittents(BzCleaner):
×
15
    normal_changes_max: int = 2100
×
16

17
    def __init__(self):
×
18
        super().__init__()
×
19
        self.component_teams = fetch_component_teams()
×
NEW
20
        r = requests.get(
×
21
            "https://treeherder.mozilla.org/api/failures/?startday={}&endday={}&tree=trunk".format(
22
                (datetime.today() - relativedelta(weeks=1)).strftime("%Y-%m-%d"),
23
                datetime.today().strftime("%Y-%m-%d"),
24
            ),
25
            headers={"Accept": "application/json", "User-Agent": "bugbot"},
26
        )
NEW
27
        r.raise_for_status()
×
NEW
28
        self.failure_bugs = {
×
29
            item["bug_id"] for item in r.json() if item["bug_id"] is not None
30
        }
31

32
    def description(self):
×
33
        return "Intermittent test failure bugs unchanged in 21 days"
×
34

35
    def get_max_actions(self):
×
36
        limit_per_run = 2100
×
37
        limit_per_team = 42
×
38

39
        # Number of teams that have bugs to be autoclosed
40
        number_of_teams = len(self.quota_actions)
×
41

42
        return min([limit_per_run // number_of_teams, limit_per_team])
×
43

44
    def has_product_component(self):
×
45
        return True
×
46

47
    def columns(self):
×
48
        return ["product", "component", "id", "summary"]
×
49

50
    def get_bz_params(self, date):
×
51
        params = {
×
52
            "include_fields": ["_custom", "product", "component"],
53
            "n1": "1",
54
            "f1": "longdescs.count",
55
            "o1": "changedafter",
56
            "v1": "-3w",
57
            "f3": "flagtypes.name",
58
            "o3": "notequals",
59
            "v3": "needinfo?",
60
            "f4": "OP",
61
            "n4": "1",
62
            "f5": "bug_status",
63
            "o5": "changedto",
64
            "v5": "REOPENED",
65
            "f6": "bug_status",
66
            "o6": "changedafter",
67
            "v6": "-7d",
68
            "f7": "CP",
69
            "f8": "bug_severity",
70
            "o8": "notequals",
71
            "v8": "S1",
72
            "f9": "keywords",
73
            "o9": "allwords",
74
            "v9": "intermittent-failure",
75
            "f10": "keywords",
76
            "o10": "nowords",
77
            "v10": "test-verify-fail,test-disabled,topcrash",
78
            "j11": "OR",
79
            "f11": "OP",
80
            "f12": "blocked",
81
            "o12": "isempty",
82
            # We want to include bugs that are blocked by sm-defects-intermittent
83
            # since it is rooting all SpiderMonkey's intermittent failures.
84
            # See https://github.com/mozilla/bugbot/issues/2635
85
            "f13": "blocked",
86
            "o13": "equals",
87
            "v13": 1729503,
88
            "f14": "CP",
89
            "resolution": "---",
90
            "status_whiteboard_type": "notregexp",
91
            "status_whiteboard": "(test disabled|test-disabled|testdisabled)",
92
        }
93

94
        return params
×
95

96
    def handle_bug(self, bug, data):
×
NEW
97
        if bug["id"] in self.failure_bugs:
×
NEW
98
            return None
×
99

UNCOV
100
        status_flags = {
×
101
            field: "wontfix"
102
            for field, value in bug.items()
103
            if field.startswith("cf_status_") and value in ("affected", "fix-optional")
104
        }
105

106
        autofix = {
×
107
            **status_flags,
108
            "status": "RESOLVED",
109
            "resolution": "INCOMPLETE",
110
            "keywords": {"remove": ["leave-open"]},
111
            "comment": {
112
                "body": f"https://wiki.mozilla.org/Bug_Triage#Intermittent_Test_Failure_Cleanup\n{self.get_documentation()}"
113
            },
114
        }
115

116
        team_name = self.component_teams[ComponentName.from_bug(bug)]
×
117

118
        self.add_prioritized_action(bug, quota_name=team_name, autofix=autofix)
×
119

120
        return bug
×
121

122

123
if __name__ == "__main__":
×
124
    Intermittents().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