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

mozilla / relman-auto-nag / #5255

11 Oct 2024 03:14PM CUT coverage: 21.55% (-0.1%) from 21.646%
#5255

push

coveralls-python

jgraham
Add a rule to sync [webcompat:sightline] whiteboard entry

This should be set on all bugs that are part of the webcompat metrics
set, and by no bugs that aren't.

This initial approach just gets all the bugs that are either in that
set or have the whiteboard entry, and implements the logic to update
them in the client. Given that we expect initially to have ~700 bugs
in that set, this means we need to set the maximum number of bugs to
update to something rather high.

426 of 2886 branches covered (14.76%)

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

12 existing lines in 1 file now uncovered.

1941 of 9007 relevant lines covered (21.55%)

0.22 hits per line

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

0.0
/bugbot/rules/webcompat_sightline.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 typing import Any, Optional
×
6

NEW
7
from bugbot import gcp
×
NEW
8
from bugbot.bzcleaner import BzCleaner
×
9

10

NEW
11
class WebcompatSightline(BzCleaner):
×
NEW
12
    normal_changes_max = 1000
×
NEW
13
    whiteboard_entry = "[webcompat:sightline]"
×
14

NEW
15
    def __init__(self):
×
NEW
16
        super().__init__()
×
NEW
17
        self.autofix_changes = {}
×
NEW
18
        self.sightline_ids = []
×
19

NEW
20
    def description(self) -> str:
×
NEW
21
        return "Web Compat site report in the sightline metric set"
×
22

NEW
23
    def filter_no_nag_keyword(self) -> bool:
×
NEW
24
        return False
×
25

NEW
26
    def has_default_products(self) -> bool:
×
NEW
27
        return False
×
28

NEW
29
    def get_autofix_change(self) -> dict[str, Any]:
×
NEW
30
        return self.autofix_changes
×
31

NEW
32
    def handle_bug(
×
33
        self, bug: dict[str, Any], data: dict[str, Any]
34
    ) -> Optional[dict[str, Any]]:
NEW
35
        bug_id = str(bug["id"])
×
NEW
36
        whiteboard = bug["whiteboard"]
×
37

NEW
38
        if bug["id"] in self.sightline_ids:
×
NEW
39
            if self.whiteboard_entry not in whiteboard:
×
NEW
40
                self.autofix_changes[bug_id] = {
×
41
                    "whiteboard": whiteboard + self.whiteboard_entry
42
                }
NEW
43
        elif self.whiteboard_entry in whiteboard:
×
NEW
44
            self.autofix_changes[bug_id] = {
×
45
                "whiteboard": whiteboard.replace(self.whiteboard_entry, "")
46
            }
47

NEW
48
        return None
×
49

NEW
50
    def get_bz_params(self, date) -> dict[str, Any]:
×
NEW
51
        fields = ["id", "summary", "whiteboard"]
×
NEW
52
        self.sightline_ids = self.get_bug_ids()
×
53
        # Get all bugs that either have, or should have, the [webcompat:sightline]
54
        # whiteboard entry
NEW
55
        return {
×
56
            "include_fields": fields,
57
            "j_top": "OR",
58
            "f1": "bug_id",
59
            "o1": "anyexact",
60
            "v1": ",".join(str(item) for item in self.sightline_ids),
61
            "f2": "status_whiteboard",
62
            "o2": "substring",
63
            "v2": self.whiteboard_entry,
64
        }
65

NEW
66
    def get_bug_ids(self) -> list[int]:
×
NEW
67
        project = "moz-fx-dev-dschubert-wckb"
×
NEW
68
        dataset = "webcompat_knowledge_base"
×
69

NEW
70
        client = gcp.get_bq_client(project, ["cloud-platform", "drive"])
×
NEW
71
        query = f"""
×
72
        SELECT number FROM `{project}.{dataset}.webcompat_topline_metric_site_reports` as bugs
73
        """
74

NEW
75
        return list(row["number"] for row in client.query(query).result())
×
76

77

NEW
78
if __name__ == "__main__":
×
NEW
79
    WebcompatSightline().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