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

mozilla / relman-auto-nag / #5333

13 Nov 2024 10:46AM CUT coverage: 21.429% (-0.09%) from 21.516%
#5333

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 46 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

1943 of 9067 relevant lines covered (21.43%)

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.sightline_ids = set()
×
17

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

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

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

NEW
27
    def handle_bug(
×
28
        self, bug: dict[str, Any], data: dict[str, Any]
29
    ) -> Optional[dict[str, Any]]:
NEW
30
        bug_id = str(bug["id"])
×
NEW
31
        whiteboard = bug["whiteboard"]
×
32

NEW
33
        if bug["id"] in self.sightline_ids:
×
NEW
34
            if self.WHITEBOARD_ENTRY not in whiteboard:
×
NEW
35
                self.autofix_changes[bug_id] = {
×
36
                    "whiteboard": whiteboard + self.WHITEBOARD_ENTRY
37
                }
NEW
38
        elif self.WHITEBOARD_ENTRY in whiteboard:
×
NEW
39
            self.autofix_changes[bug_id] = {
×
40
                "whiteboard": whiteboard.replace(self.WHITEBOARD_ENTRY, "")
41
            }
42

NEW
43
        return None
×
44

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

NEW
61
    def get_sightline_bug_ids(self) -> set[int]:
×
NEW
62
        project = "moz-fx-dev-dschubert-wckb"
×
NEW
63
        dataset = "webcompat_knowledge_base"
×
64

NEW
65
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
NEW
66
        query = f"""
×
67
        SELECT number FROM `{project}.{dataset}.webcompat_topline_metric_site_reports` as bugs
68
        """
69

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

72

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