Skip to content

Commit 32d7f50

Browse files
chuttenbadboy
authored andcommitted
Support more bugzilla URLs for scraping bug numbers from for FOG checks
1 parent aa4912b commit 32d7f50

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

probe_scraper/fog_checks.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
its own expiry checks. Sending its own emails. Filing its own bugs.
1010
"""
1111

12+
import re
1213
from collections import defaultdict
1314
from typing import Any, Dict, List, Optional, Set, TypedDict
1415

@@ -99,6 +100,9 @@ class EmailInfo(TypedDict):
99100
""" # noqa
100101

101102

103+
BUG_NUMBER_PATTERN = re.compile(r"\d+")
104+
105+
102106
def get_expiring_metrics(
103107
metrics: Dict[str, Dict], latest_nightly_version: str
104108
) -> Dict[str, Dict]:
@@ -138,14 +142,20 @@ def bug_number_from_url(url: str) -> Optional[int]:
138142
Given a bug url, get its bug number.
139143
If we can't figure out a reasonable bug number, return None.
140144
"""
141-
# ASSUMPTION: bug urls end in the pattern `=<bug number>`
142-
# TODO: Write a test in Firefox Desktop that asserts this is true.
143-
try:
144-
return int(url.rsplit("=")[-1])
145-
except ValueError:
146-
print(f"Can't figure out bug number for url: {url}")
145+
if "bugz" not in url:
146+
# Not a bugzilla url. We don't understand you.
147+
print(f"Can't figure out bug number for non-bugzilla url: {url}")
147148
return None
148149

150+
bug = BUG_NUMBER_PATTERN.search(url)
151+
if bug is not None:
152+
try:
153+
bug = int(bug[0])
154+
except Exception:
155+
print(f"Can't figure out bug number for url: {url}")
156+
return None
157+
return bug
158+
149159

150160
def file_bugs(
151161
expiring_metrics: Dict[str, Dict],

probe_scraper/scrapers/git_scraper.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@
8383
"b80d1b362960cef8ee389ed54cdc41702ca832d9",
8484
# Broken yaml in toolkit/components/translations/metrics.yaml, fixed in subsequent commit
8585
"3ac10c73a280b1f9bba82bb08082db7bcfd5d2de",
86+
"01a75161fac9acfc5a603bc2256245e914591e5e", # Missing dom/security/metrics.yaml
87+
"cdb47e79cd499b67d5de2804cbfb70eb2ab29796", # Missing parser/html/metrics.yaml
88+
"ed40307b32b221322505a86ebd33a322c64820bb", # Missing security/ct/metrics.yaml
89+
# Missing toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml
90+
"32aceda20e3960fae23b3959be179693ec825599",
91+
# Missing toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml
92+
"189fed694934b8cde47c83fa9fb56ae76b93092c",
93+
# Missing toolkit/components/antitracking/imageinputmetadatastripper/metrics.yaml
94+
"3b9744aaa5694b1c633acb0d0ea1fe8ec31c9d28",
95+
# Missing toolkit/components/reader/metrics.yaml
96+
"5bd2d84327d9385a4f4a0fbc4f55e4e0a0302bb2",
97+
"abbfb0e92e37e68d008ba0af29dbe199651fd2f3", # Missing toolkit/profile/metrics.yaml
98+
# Missing toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml
99+
"84748d4bd6523268d905b0bc78cc7773a37bbca9",
100+
# Missing toolkit/components/antitracking/bouncetrackingprotection/metrics.yaml
101+
"7b49203aee2818b96242b4746fed722844619760",
102+
# Missing toolkit/components/resistfingerprinting/pings.yaml
103+
"de714a36bce1431b1332b52c48106fedb2d4142a",
104+
# Missing toolkit/components/resistfingerprinting/pings.yaml
105+
"2df76493a78a6cc21c37b699fa4ae3eb91f87218",
86106
],
87107
"firefox-desktop": [
88108
"c5d5f045aaba41933622b5a187c39da0d6ab5d80", # Missing toolkit/components/glean/tags.yaml
@@ -92,6 +112,23 @@
92112
"642be079c4465445ab42b55d18e0a4d644c19c36", # No toolkit/components/telemetry/pings.yaml
93113
# Missing toolkit/components/telemetry/dap/metrics.yaml
94114
"c5c002f81f08a73e04868e0c2bf0eb113f200b03",
115+
# Missing browser/components/backup/metrics.yaml
116+
"4d4322e829aa7ba8a4abd00fca0dcd3b10e127a3",
117+
# Missing browser/components/privatebrowsing/metrics.yaml
118+
"47da40cec7bb1235bd9dc597a26f7b69b48fc2a7",
119+
# Missing dom/media/platforms/wmf/metrics.yaml
120+
"41edcdf7fe44678c5913a603a286b1fc3979d540",
121+
# Missing toolkit/components/contentrelevancy/metrics.yaml
122+
"856ef9e3e5132cf536dc5662e220c0e0e5127a7e",
123+
# Missing toolkit/components/contentrelevancy/metrics.yaml
124+
"c7f67706fcdac6a6198d8867cb102546213dbaf8",
125+
# Missing toolkit/components/places/metrics.yaml
126+
"bc739eb4ae15600f5eb668a060de8732e34e7e26",
127+
# Missing toolkit/components/shopping/metrics.yaml
128+
"f03abd1c7bf9f721afd0df7e36023f4ea925afd2",
129+
"c9bbde88a4e816950372d1647827491902f62af4", # Missing widget/windows/metrics.yaml
130+
"21001e9ab793daf750ad988ce86cc7eefd29b856", # Missing toolkit/components/nimbus/pings.yaml
131+
"514742c4bda3c0a5ea5c631029929efa8fd6f855", # Missing toolkit/components/nimbus/pings.yaml
95132
],
96133
"firefox-desktop-background-update": [
97134
"c5d5f045aaba41933622b5a187c39da0d6ab5d80", # Missing toolkit/components/glean/tags.yaml

tests/test_fog_checks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,17 @@ def test_bug_number_from_url():
178178
)
179179
== 1701769
180180
)
181-
# Parser isn't smart, but it's Best Effort anyway so just make sure it returns None
181+
assert (
182+
fog_checks.bug_number_from_url("https://bugzilla.mozilla.org/1885138")
183+
== 1885138
184+
)
182185
assert (
183186
fog_checks.bug_number_from_url(
184187
"https://bugzilla.mozilla.org/show_bug.cgi?id=1701769#c1"
185188
)
186-
is None
189+
== 1701769
187190
)
188-
assert fog_checks.bug_number_from_url("https://bugzil.la/1701769") is None
191+
assert fog_checks.bug_number_from_url("https://bugzil.la/1701769") == 1701769
189192
# Parser shouldn't give a good number for github urls
190193
assert (
191194
fog_checks.bug_number_from_url(

0 commit comments

Comments
 (0)