Skip to content

Commit 4d84d8c

Browse files
EvaBardouEva Bardou
and
Eva Bardou
authored
Add documentation on how to test the publication on Phabricator (#1203)
* Add documentation on how to test the publication on Phabricator * Nit Co-authored-by: Eva Bardou <ebardou@teklia.com>
1 parent c49797f commit 4d84d8c

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

docs/projects/bot.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ We publish two things (when issues are published):
8282

8383
For more information, read the [phabricator](/docs/phabricator.md) documentation.
8484

85+
See below, how to [test the publication on Phabricator](#test-the-publication-on-phabricator).
86+
8587
### Debug
8688

8789
The debug reporter lists all the issues in a public JSON artifact and sends an email to admins with the full list of issues.
@@ -97,3 +99,113 @@ Build errors are really bad, and we want to send an email to the developer when
9799
The backend has no reporter as it's more tightly coupled to the bot system, but every issue is published on the backend.
98100

99101
Each Issue also has a unique hash calculated, using the modified lines source code, the issue summary. It's used to be able to compare issues between each other.
102+
103+
## Test the publication on Phabricator
104+
### Submit a fake patch on Firefox
105+
There is an [online documentation](https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html) that explains how to publish a patch on Firefox. Here are a few tips on how to simplify/accelerate this workflow.
106+
107+
In the repository, you can install dependencies using the command:
108+
```
109+
./mach bootstrap
110+
```
111+
:warning: Using `./mach build` as suggested in the documentation will result in a build that can take forever to complete.
112+
113+
Make a patch by editing one of Firefox files and then run the desired linter using the command:
114+
```
115+
./mach lint -l my_linter
116+
```
117+
118+
For example, to run flake8 on the repository, you can use:
119+
```
120+
./mach lint -l flake8
121+
```
122+
123+
### Retrieve `TRY_TASK_GROUP_ID` and `TRY_TASK_ID`
124+
Once you have submitted a patch on Phabricator using `moz-phab`, you'll need to retrieve two values to run the Code Review Bot locally on this specific diff.
125+
126+
First, you have to find your patch on Phabricator, for example, this one was created for testing purposes:
127+
https://phabricator.services.mozilla.com/D150515
128+
129+
Then you have two ways to retrieve the desired information.
130+
131+
#### First option
132+
1. On the Phabricator page for your diff, find the **Build 111111: Source Code Analysis** link in the **Diff Detail** panel, next to the **Build Status** label.
133+
2. Next to this link, you should have a link called **CI (Treeherder) Jobs**, click on it and you'll be redirected to Treeherder.
134+
3. On the Treeherder page, find the green **D** next to **Gecko Decision Task opt** and click on it, a panel will appear on the bottom of the page.
135+
4. On the left side of the newly opened panel, find the **Task** label and click on the task ID link next to it, a Taskcluster page will open.
136+
5. On the top of the page, click on the **Task Group** link, next to **Gecko Decision Task**.
137+
6. There you can retrieve the ID after `https://firefox-ci-tc.services.mozilla.com/tasks/groups/` in the URL, that's the `TRY_TASK_GROUP_ID` needed to launch the Code Review Bot.
138+
7. Once you have this first ID, you can find the task named **code-review-issues** in the displayed list, click on it.
139+
8. There you can retrieve the ID after `https://firefox-ci-tc.services.mozilla.com/tasks/` in the URL, that's the `TRY_TASK_ID` needed to launch the Code Review Bot.
140+
141+
***Example***
142+
1. On https://phabricator.services.mozilla.com/D150515
143+
2. Redirected to https://treeherder.mozilla.org/jobs?repo=try&revision=5ec034a3e77223ee58d2bad5689b99e09c61a4bb
144+
3. Panel opened https://treeherder.mozilla.org/jobs?repo=try&revision=5ec034a3e77223ee58d2bad5689b99e09c61a4bb&selectedTaskRun=Y44yN6dtSsWQ6oyTYMYhQw.0
145+
4. Redirected to https://firefox-ci-tc.services.mozilla.com/tasks/Y44yN6dtSsWQ6oyTYMYhQw
146+
5. On https://firefox-ci-tc.services.mozilla.com/tasks/groups/Y44yN6dtSsWQ6oyTYMYhQw
147+
6. Here `TRY_TASK_GROUP_ID=Y44yN6dtSsWQ6oyTYMYhQw`
148+
7. On https://firefox-ci-tc.services.mozilla.com/tasks/LfiiQNAXR4WV9e1RT4PVsQ
149+
8. Here `TRY_TASK_ID=LfiiQNAXR4WV9e1RT4PVsQ`
150+
151+
#### Second option
152+
1. On the Phabricator page for your diff, retrieve your diff ID in the URL after `https://phabricator.services.mozilla.com/D`.
153+
2. Then go to `https://firefox-ci-tc.services.mozilla.com/tasks/index/project.relman.production.code-review.phabricator.<diff_id>`.
154+
3. Click on the first Indexed Task.
155+
4. Under the **Data** label you'll have a JSON payload containing both needed information, `try_task_id` and `try_group_id`.
156+
157+
***Example***
158+
1. On https://phabricator.services.mozilla.com/D150515, here `diff_id=150515`
159+
2. Go to https://firefox-ci-tc.services.mozilla.com/tasks/index/project.relman.production.code-review.phabricator.150515
160+
3. On https://firefox-ci-tc.services.mozilla.com/tasks/index/project.relman.production.code-review.phabricator.150515/AUAnqdfRTPq64aBFHS0g3Q
161+
4. Here `TRY_TASK_ID=LfiiQNAXR4WV9e1RT4PVsQ` (`try_task_id`) and `TRY_TASK_GROUP_ID=Y44yN6dtSsWQ6oyTYMYhQw` (`try_group_id`)
162+
163+
### Launch the Code Review Bot
164+
An example of a working development configuration:
165+
```
166+
---
167+
bot:
168+
ZERO_COVERAGE_ENABLED: false
169+
REPORTERS:
170+
- reporter: phabricator
171+
backend:
172+
username: <backend_user>
173+
url: 'http://localhost:8000'
174+
password: <backend_password>
175+
176+
common:
177+
APP_CHANNEL: dev
178+
179+
PHABRICATOR:
180+
api_key: <phab_api_token>
181+
url: 'https://phabricator.services.mozilla.com//api/'
182+
publish: true
183+
184+
repositories:
185+
- checkout: robust
186+
try_url: 'ssh://hg.mozilla.org/try'
187+
try_mode: json
188+
try_name: try
189+
name: mozilla-central
190+
ssh_user: <ssh_user>
191+
url: 'https://hg.mozilla.org/mozilla-central'
192+
decision_env_revision: GECKO_HEAD_REV
193+
decision_env_repository: GECKO_HEAD_REPOSITORY
194+
```
195+
196+
**Note**: You can generate/find your Phabricator API Token on this page: https://phabricator.services.mozilla.com/settings/user/--phabricator_username--/page/apitokens/.
197+
198+
Then, you can create a script named `code_review_testing.sh`, containing the following lines:
199+
```
200+
export TRY_TASK_GROUP_ID="<TASK_GROUP_ID>"
201+
export TRY_TASK_ID="<TASK_ID>"
202+
203+
code-review-bot -c <path/to/your/configuration>.yml
204+
```
205+
206+
Run the script with:
207+
```
208+
bash code_review_testing.sh
209+
```
210+
211+
:tada: A new comment should have been published! :tada:

0 commit comments

Comments
 (0)