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

mozilla / relman-auto-nag / #5325

06 Nov 2024 10:53AM CUT coverage: 21.411% (-0.1%) from 21.516%
#5325

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 2902 branches covered (14.68%)

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

1 existing line in 1 file now uncovered.

1942 of 9070 relevant lines covered (21.41%)

0.21 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
    whiteboard_entry = "[webcompat:sightline]"
×
13

NEW
14
    def __init__(self):
×
NEW
15
        super().__init__()
×
NEW
16
        self.autofix_changes = {}
×
NEW
17
        self.sightline_ids = set()
×
18

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

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

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

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

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

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

NEW
47
        return None
×
48

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

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

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

NEW
74
        return {row["number"] for row in client.query(query).result()}
×
75

76

NEW
77
if __name__ == "__main__":
×
NEW
78
    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