Skip to content

Commit b5a997d

Browse files
Add Lando revision link to uplift request comments
Agent-Logs-Url: https://github.com/mozilla/bugbot/sessions/c14d247a-c967-4d1d-95ed-ce273490a637 Co-authored-by: suhaibmujahid <4151357+suhaibmujahid@users.noreply.github.com>
1 parent 649a5bf commit b5a997d

7 files changed

Lines changed: 256 additions & 2 deletions

File tree

bugbot.egg-info/PKG-INFO

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
Metadata-Version: 2.4
2+
Name: bugbot
3+
Version: 0.1.0
4+
Summary: Bugzilla management bot
5+
Author: Mozilla Corporation
6+
License-Expression: BSD-3-Clause
7+
Requires-Python: <3.13,>=3.10
8+
Description-Content-Type: text/x-rst
9+
License-File: LICENSE
10+
Requires-Dist: alembic==1.14.1
11+
Requires-Dist: argparse==1.4.0
12+
Requires-Dist: filelock==3.25.2
13+
Requires-Dist: google-cloud-bigquery==3.39.0
14+
Requires-Dist: gspread==6.2.1
15+
Requires-Dist: humanize>=0.5.1
16+
Requires-Dist: icalendar==6.3.2
17+
Requires-Dist: Jinja2==3.1.6
18+
Requires-Dist: libmozdata==0.2.12
19+
Requires-Dist: numpy==2.2.6
20+
Requires-Dist: pep8==1.7.1
21+
Requires-Dist: pyflakes==3.4.0
22+
Requires-Dist: python-dateutil>=2.8.2
23+
Requires-Dist: python-Levenshtein>=0.12.0
24+
Requires-Dist: pytz>=2018.9
25+
Requires-Dist: PyYAML==6.0.2
26+
Requires-Dist: recurring-ical-events==3.8.1
27+
Requires-Dist: requests==2.33.0
28+
Requires-Dist: sentry-sdk>=2.42.1
29+
Requires-Dist: sqlalchemy==1.3.24
30+
Requires-Dist: tenacity==9.1.4
31+
Requires-Dist: whatthepatch>=0.0.5
32+
Provides-Extra: dev
33+
Requires-Dist: coverage==7.13.5; extra == "dev"
34+
Requires-Dist: mock==5.2.0; extra == "dev"
35+
Requires-Dist: responses==0.26.0; extra == "dev"
36+
Provides-Extra: test
37+
Requires-Dist: coveralls==4.1.0; extra == "test"
38+
Requires-Dist: pre-commit==4.5.1; extra == "test"
39+
Requires-Dist: tox==4.32.0; extra == "test"
40+
Dynamic: license-file
41+
42+
.. image:: https://community-tc.services.mozilla.com/api/github/v1/repository/mozilla/bugbot/master/badge.svg
43+
:target: https://community-tc.services.mozilla.com/api/github/v1/repository/mozilla/bugbot/master/latest
44+
.. image:: https://coveralls.io/repos/github/mozilla/bugbot/badge.svg
45+
:target: https://coveralls.io/github/mozilla/bugbot
46+
47+
48+
This tool is used by Mozilla release management to send emails to the Firefox developers. It will query the bugzilla.mozilla.org database and send emails to Mozilla developers and their managers (if Mozilla staff).
49+
50+
The tool will also notify release managers about potential issues in bugzilla and autofix some categories of issues.
51+
52+
The list of checkers is documented on the Mozilla wiki:
53+
https://wiki.mozilla.org/BugBot
54+
55+
This package currently uses Mozilla's `Bugzilla REST API <https://wiki.mozilla.org/Bugzilla:REST_API>`_, and the Mozilla IAM `phonebook <https://github.com/mozilla-iam/cis/blob/master/docs/PersonAPI.md>`_ (to access bug assignees' managers & Mozilla email addresses).
56+
57+
58+
Installation
59+
------------
60+
61+
#. Check out the code::
62+
63+
git clone https://github.com/mozilla/bugbot.git
64+
65+
bugbot uses `uv <https://docs.astral.sh/uv/>`_ to manage the Python environment; this must be installed locally.
66+
67+
Auto-formatting with pre-commit
68+
-------------------------------
69+
70+
This project uses `pre-commit <https://pre-commit.com/>`_.
71+
72+
#. Install pre-commit::
73+
74+
uv tool install pre-commit
75+
76+
Every time you try to commit, pre-commit checks your files to ensure they follow our style standards and aren't affected by some simple issues. If the checks fail, pre-commit won't let you commit.
77+
78+
Running the Bot Rules
79+
---------------------
80+
81+
Before running:
82+
83+
1. The LDAP + SMTP infos are used to send emails
84+
2. Need to generate an API key from bugzilla admin ( https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey )
85+
3. Should generate an API key from Phabricator ( https://phabricator.services.mozilla.com/settings/user )
86+
4. The IAM secrets are used to generate a dump of phonebook, which is required for some scripts (employees can request them by `filing a bug in the SSO: Requests component <https://bugzilla.mozilla.org/enter_bug.cgi?product=Infrastructure%20%26%20Operations&component=SSO%3A%20Requests>`_ )
87+
88+
.. code-block:: json
89+
90+
# in configs/config.json
91+
{
92+
"ldap_username": "xxx@xxxx.xxx",
93+
"ldap_password": "xxxxxxxxxxxxxx",
94+
"smtp_server": "smtp.xxx.xxx",
95+
"smtp_port": 314,
96+
"smtp_ssl": true,
97+
"bz_api_key": "xxxxxxxxxxxxxx",
98+
"bz_api_key_nomail": "xxxxxxxxxxxxxx",
99+
"phab_api_key": "xxxxxxxxxxxxxx",
100+
"iam_client_secret": "xxxxxxxxxxxxxx",
101+
"iam_client_id": "xxxxxxxxxxxxxx",
102+
"socorro_token": "xxxxxxxxxxxxxx"
103+
}
104+
105+
Do a dryrun::
106+
107+
uv run -m bugbot.rules.stalled
108+
109+
There is a ton of rules in bugbot/rules/ so you should be able to find some good examples.
110+
111+
Setting up 'Round Robin' triage rotations
112+
-----------------------------------------
113+
114+
One use case for this tool is managing triage of multiple components across a team of multiple people.
115+
116+
To set up a new Round Robin rotation, a manager or team lead should create a calendar with the rotation of triagers and add a link to the rotation calendar in the `triage rotations spreadsheet <https://docs.google.com/spreadsheets/d/1EK6iCtdD8KP4UflIHscuZo6W5er2vy_TX7vsmaaBVd4>`_.
117+
118+
119+
Running on a server
120+
-------------------
121+
122+
This needs to run on a private server because it will have login for smtp and bugzilla key so it can't currently be shared access.
123+
124+
Cronjob::
125+
126+
CRON_DIR=/path/to/repository
127+
00 12 * * 1-5 cd $CRON_DIR ; ./cron_run_weekdays.sh &> /tmp/bugbot-weekdays.log
128+
00 8 * * * cd $CRON_DIR ; ./cron_run_daily.sh &> /tmp/bugbot-daily.log
129+
40 */1 * * * cd $CRON_DIR ; ./cron_run_hourly.sh &> /tmp/bugbot-hourly.log
130+
131+
132+
We run hourly jobs at minute 40 past every hour to avoid overlap with daily jobs.

bugbot.egg-info/SOURCES.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
LICENSE
2+
README.rst
3+
pyproject.toml
4+
bugbot/__init__.py
5+
bugbot/auto_mock.py
6+
bugbot/bugbug_utils.py
7+
bugbot/bzcleaner.py
8+
bugbot/cache.py
9+
bugbot/component_triagers.py
10+
bugbot/components.py
11+
bugbot/config.py
12+
bugbot/constants.py
13+
bugbot/db.py
14+
bugbot/erroneous_bzmail.py
15+
bugbot/escalation.py
16+
bugbot/gcp.py
17+
bugbot/history.py
18+
bugbot/iam.py
19+
bugbot/log.py
20+
bugbot/mail.py
21+
bugbot/multi_autofixers.py
22+
bugbot/multinaggers.py
23+
bugbot/nag_me.py
24+
bugbot/people.py
25+
bugbot/round_robin.py
26+
bugbot/round_robin_calendar.py
27+
bugbot/round_robin_fallback.py
28+
bugbot/severity.py
29+
bugbot/team_managers.py
30+
bugbot/topcrash.py
31+
bugbot/user_activity.py
32+
bugbot/utils.py
33+
bugbot/webcompat_priority.py
34+
bugbot.egg-info/PKG-INFO
35+
bugbot.egg-info/SOURCES.txt
36+
bugbot.egg-info/dependency_links.txt
37+
bugbot.egg-info/requires.txt
38+
bugbot.egg-info/top_level.txt
39+
tests/test_bug_analyzer.py
40+
tests/test_bzcleaner.py
41+
tests/test_cache.py
42+
tests/test_calendar.py
43+
tests/test_db.py
44+
tests/test_duplicate_copy_metadata.py
45+
tests/test_email_no_assignee.py
46+
tests/test_escalation.py
47+
tests/test_mail.py
48+
tests/test_multi_autofixers.py
49+
tests/test_new_utils.py
50+
tests/test_regression_set_status_flags.py
51+
tests/test_round_robin.py
52+
tests/test_severity.py
53+
tests/test_topcrash.py
54+
tests/test_user_activity.py
55+
tests/test_webcompat_priority.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

bugbot.egg-info/requires.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
alembic==1.14.1
2+
argparse==1.4.0
3+
filelock==3.25.2
4+
google-cloud-bigquery==3.39.0
5+
gspread==6.2.1
6+
humanize>=0.5.1
7+
icalendar==6.3.2
8+
Jinja2==3.1.6
9+
libmozdata==0.2.12
10+
numpy==2.2.6
11+
pep8==1.7.1
12+
pyflakes==3.4.0
13+
python-dateutil>=2.8.2
14+
python-Levenshtein>=0.12.0
15+
pytz>=2018.9
16+
PyYAML==6.0.2
17+
recurring-ical-events==3.8.1
18+
requests==2.33.0
19+
sentry-sdk>=2.42.1
20+
sqlalchemy==1.3.24
21+
tenacity==9.1.4
22+
whatthepatch>=0.0.5
23+
24+
[dev]
25+
coverage==7.13.5
26+
mock==5.2.0
27+
responses==0.26.0
28+
29+
[test]
30+
coveralls==4.1.0
31+
pre-commit==4.5.1
32+
tox==4.32.0

bugbot.egg-info/top_level.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bugbot

bugbot/rules/uplift_beta.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
33
# You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
import base64
6+
import re
7+
58
from libmozdata import utils as lmdutils
69
from libmozdata.bugzilla import Bugzilla
710

811
from bugbot import utils
912
from bugbot.bzcleaner import BzCleaner
1013

14+
PHAB_URL_PAT = re.compile(r"https://phabricator\.services\.mozilla\.com/D([0-9]+)")
15+
LANDO_BASE_URL = "https://lando.moz.tools/"
16+
1117

1218
class UpliftBeta(BzCleaner):
1319
def __init__(self):
@@ -36,6 +42,27 @@ def get_extra_for_needinfo_template(self):
3642
def columns(self):
3743
return ["id", "summary", "assignee"]
3844

45+
@staticmethod
46+
def get_lando_url(attachments):
47+
"""Get the Lando URL for the most recently created non-obsolete
48+
Phabricator attachment, or None if no such attachment exists."""
49+
phab_attachments = [
50+
a
51+
for a in attachments
52+
if a["content_type"] == "text/x-phabricator-request"
53+
and not a["is_obsolete"]
54+
]
55+
if not phab_attachments:
56+
return None
57+
58+
latest = max(phab_attachments, key=lambda a: a["creation_time"])
59+
phab_url = base64.b64decode(latest["data"]).decode("utf-8")
60+
m = PHAB_URL_PAT.search(phab_url)
61+
if not m:
62+
return None
63+
64+
return f"{LANDO_BASE_URL}D{m.group(1)}"
65+
3966
def handle_bug(self, bug, data):
4067
bugid = str(bug["id"])
4168

@@ -55,6 +82,7 @@ def handle_bug(self, bug, data):
5582
"nickname": nickname,
5683
"summary": self.get_summary(bug),
5784
"regressions": bug["regressions"],
85+
"lando_url": self.get_lando_url(bug.get("attachments", [])),
5886
}
5987

6088
return bug
@@ -102,6 +130,7 @@ def get_bz_params(self, date):
102130
"attachments.creation_time",
103131
"attachments.is_obsolete",
104132
"attachments.content_type",
133+
"attachments.data",
105134
"cf_last_resolved",
106135
"assigned_to",
107136
"flags",
@@ -143,7 +172,10 @@ def get_bugs(self, date="today", bug_ids=[]):
143172

144173
for bugid, data in bugs.items():
145174
if data["mail"] and data["nickname"]:
146-
self.extra_ni[bugid] = {"regression": len(data["regressions"])}
175+
self.extra_ni[bugid] = {
176+
"regression": len(data["regressions"]),
177+
"lando_url": data["lando_url"],
178+
}
147179
self.add_auto_ni(
148180
bugid, {"mail": data["mail"], "nickname": data["nickname"]}
149181
)

templates/uplift_beta_needinfo.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
The patch landed in nightly and beta is affected.
22
:{{ nickname }}, is this bug important enough to require an uplift?
33
- If yes, please nominate the patch for beta approval.{% if extra[bugid]["regression"] %} Also, don't forget to request an uplift for the patches in the {{ plural('regression', extra[bugid]["regression"]) }} caused by this fix.{% endif %}
4-
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
4+
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.{% if extra[bugid]["lando_url"] %}
5+
- The patch is available at {{ extra[bugid]["lando_url"] }}.{% endif %}
56
- If no, please set `{{ extra["status_beta"] }}` to `wontfix`.
67

78
{{ documentation }}

0 commit comments

Comments
 (0)