brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 1 | # Code Reviews |
| 2 | |
| 3 | Code reviews are a central part of developing high-quality code for Chromium. |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 4 | All change lists (CLs) must be reviewed. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 5 | |
Daniel Cheng | 6bffde0 | 2020-06-12 19:10:45 | [diff] [blame] | 6 | The general patch, upload, and land process is covered in more detail in the |
Jason D. Clinton | c38b61d8 | 2021-04-20 20:02:14 | [diff] [blame] | 7 | [contributing code](contributing.md) page. To learn about the code review changes |
| 8 | and OWNERS policy changes launched on March 24, 2021, see |
| 9 | [Mandatory Code Review and Native OWNERS](code_review_owners.md). |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 10 | |
| 11 | # Code review policies |
| 12 | |
| 13 | Ideally the reviewer is someone who is familiar with the area of code you are |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 14 | touching. Any committer can review code, but an owner must provide a review |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 15 | for each directory you are touching. If you have doubts, look at the `git blame` |
| 16 | for the file and the `OWNERS` files ([more info](#owners-files)). |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 17 | |
John Abd-El-Malek | dfd1edc | 2021-02-24 22:22:40 | [diff] [blame] | 18 | To indicate a positive review, the reviewer provides a `Code-Review +1` in |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 19 | Gerrit, also known as an LGTM ("Looks Good To Me"). A score of "-1" indicates |
| 20 | the change should not be submitted as-is. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 21 | |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 22 | If you have multiple reviewers, provide a message indicating what you expect |
| 23 | from each reviewer. Otherwise people might assume their input is not required |
| 24 | or waste time with redundant reviews. |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 25 | |
Annie Sullivan | d04212e7 | 2017-10-19 21:11:32 | [diff] [blame] | 26 | Please also read [Respectful Changes](cl_respect.md) and |
| 27 | [Respectful Code Reviews](cr_respect.md). |
| 28 | |
Robert Sesek | a8ee4a9 | 2023-07-13 23:04:30 | [diff] [blame] | 29 | There are also a [collection of tips](cl_tips.md) for productive reviews, though |
| 30 | these are advisory and not policy. |
| 31 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 32 | #### Expectations for all reviewers |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 33 | |
| 34 | * Aim to provide some kind of actionable response within 24 hours of receipt |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 35 | (not counting weekends and holidays). This doesn't mean you have to do a |
| 36 | complete review, but you should be able to give some initial feedback, |
| 37 | request more time, or suggest another reviewer. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 38 | |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 39 | * Use the status field in Gerrit settings to indicate if you're away and when |
Mike Frysinger | 7b15bde | 2018-05-15 09:28:05 | [diff] [blame] | 40 | you'll be back. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 41 | |
| 42 | * Don't generally discourage people from sending you code reviews. This |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 43 | includes using a blanket "slow" in your status field. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 44 | |
| 45 | ## OWNERS files |
| 46 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 47 | In various directories there are files named `OWNERS` that list the email |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 48 | addresses of people qualified to review changes in that directory. You must |
| 49 | get a positive review from an owner of each directory your change touches. |
| 50 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 51 | Owners files are recursive, so each file also applies to its subdirectories. |
| 52 | It's generally best to pick more specific owners. People listed in higher-level |
thestig | 9208d8ba | 2017-06-09 22:05:32 | [diff] [blame] | 53 | directories may have less experience with the code in question. For example, |
| 54 | the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely |
| 55 | be more familiar with code in `//chrome/browser/component_name/sub_component` |
| 56 | than reviewers in the higher-level `//chrome/OWNERS` file. |
| 57 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 58 | More detail on the owners file format is provided [here](#owners-file-details). |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 59 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 60 | *Tip:* The `git cl owners` command can help find owners. Gerrit also provides |
Jason D. Clinton | c38b61d8 | 2021-04-20 20:02:14 | [diff] [blame] | 61 | this functionality in the Reviewers field of CLs. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 62 | |
| 63 | While owners must approve all patches, any committer can contribute to the |
| 64 | review. In some directories the owners can be overloaded or there might be |
| 65 | people not listed as owners who are more familiar with the low-level code in |
| 66 | question. In these cases it's common to request a low-level review from an |
| 67 | appropriate person, and then request a high-level owner review once that's |
| 68 | complete. As always, be clear what you expect of each reviewer to avoid |
| 69 | duplicated work. |
| 70 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 71 | Owners do not have to pick other owners for reviews. Since they should already |
| 72 | be familiar with the code in question, a thorough review from any appropriate |
| 73 | committer is sufficient. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 74 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 75 | #### Expectations of owners |
| 76 | |
| 77 | The existing owners of a directory approve additions to the list. It is |
Wei-Yin Chen (陳威尹) | 681bc32 | 2017-07-20 01:55:11 | [diff] [blame] | 78 | preferable to have many directories, each with a smaller number of specific |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 79 | owners rather than large directories with many owners. Owners should: |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 80 | |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 81 | * Demonstrate excellent judgment, teamwork and ability to uphold |
| 82 | [Chromium development principles](contributing.md). |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 83 | |
| 84 | * Be already acting as an owner, providing high-quality reviews and design |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 85 | feedback. |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 86 | |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 87 | * Be a Chromium project member with full commit access of at least three |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 88 | months tenure. |
| 89 | |
| 90 | * Have submitted a substantial number of non-trivial changes to the affected |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 91 | directory. |
| 92 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 93 | * Have committed or reviewed substantial work to the affected directory |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 94 | within the last ninety days. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 95 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 96 | * Have the bandwidth to contribute to reviews in a timely manner. If the load |
| 97 | is unsustainable, work to expand the number of owners. Don't try to |
| 98 | discourage people from sending reviews, including writing "slow" or |
| 99 | "emeritus" after your name. |
| 100 | |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 101 | Seldom-updated directories may have exceptions to the "substantiality" and |
| 102 | "recency" requirements. |
| 103 | |
| 104 | Directories in `//third_party` should list those most familiar with the |
| 105 | library, regardless of how often the code is updated. |
| 106 | |
| 107 | #### Removal of owners |
| 108 | |
| 109 | If a code owner is not meeting the [expectations of |
| 110 | owners](#expectations-of-owners) listed above for more than one quarter (and |
| 111 | they are not on a leave during that time), then they may be removed by any |
| 112 | co-owner or an owner from the parent directory after a 4-week notice, using |
| 113 | the following process: |
| 114 | |
| 115 | * Upload a change removing the owner and copy all owners in that directory, |
| 116 | including the owner in question. |
| 117 | * If the affected owner approves the change, it may be landed immediately. |
| 118 | * Otherwise, the change author must wait five working days for feedback from |
| 119 | the other owners. |
| 120 | * After that time has elapsed, if the change has received 3 approvals |
| 121 | with no objections from anyone else, the change may be landed. |
| 122 | * If the directory does not have 4 owners, then the decision should |
| 123 | be escalated to the owners of the parent directory (or directories) |
| 124 | as necessary to provide enough of votes. |
| 125 | * If there are objections, then the decision should be escalated to |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 126 | the [../ATL_OWNERS](../ATL_OWNERS) for resolution. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 127 | |
Kentaro Hara | 52294ae | 2022-08-12 07:37:30 | [diff] [blame] | 128 | Note: For the purpose of not slowing down code review, Chromium removes |
| 129 | inactive owners (e.g., those who made no contributions for multiple quarters) |
| 130 | on a regular basis. The script does not take into account personal situations |
| 131 | like a long leave. If you were inactive only for a certain period of time |
| 132 | while you were on a long leave and have been meeting the above owner's |
| 133 | expectations in other times, you can create a CL to re-add yourself and land |
| 134 | after getting local owner's approval (you can refer to this policy in the CL). |
Yulan Lin | 33168662 | 2023-03-30 23:10:51 | [diff] [blame] | 135 | The removal script will cc the removed owner and one other owner to avoid spam. |
Kentaro Hara | 52294ae | 2022-08-12 07:37:30 | [diff] [blame] | 136 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 137 | ### OWNERS file details |
| 138 | |
Anthony Polito | 9ce2a48 | 2022-02-10 18:39:49 | [diff] [blame] | 139 | Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md) |
thestig | 9208d8ba | 2017-06-09 22:05:32 | [diff] [blame] | 140 | for all details on the file format. |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 141 | |
| 142 | This example indicates that two people are owners, in addition to any owners |
| 143 | from the parent directory. `git cl owners` will list the comment after an |
| 144 | owner address, so this is a good place to include restrictions or special |
| 145 | instructions. |
| 146 | ``` |
| 147 | # You can include comments like this. |
| 148 | [email protected] |
| 149 | [email protected] # Only for the frobinator. |
| 150 | ``` |
| 151 | |
| 152 | A `*` indicates that all committers are owners: |
| 153 | ``` |
| 154 | * |
| 155 | ``` |
| 156 | |
brettw | d040b0be | 2017-02-09 19:11:33 | [diff] [blame] | 157 | The text `set noparent` will stop owner propagation from parent directories. |
Jochen Eisinger | ea8f92d8 | 2017-08-02 17:40:14 | [diff] [blame] | 158 | This should be rarely used. If you want to use `set noparent` except for IPC |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 159 | related files, please first reach out to chrome-atls@google.com. |
Jochen Eisinger | ea8f92d8 | 2017-08-02 17:40:14 | [diff] [blame] | 160 | |
Jochen Eisinger | 8f0c8d8 | 2019-10-25 18:28:27 | [diff] [blame] | 161 | You have to use `set noparent` together with a reference to a file that lists |
| 162 | the owners for the given use case. Approved use cases are listed in |
| 163 | `//build/OWNERS.setnoparent`. Owners listed in those files are expected to |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 164 | execute special governance functions such as ATL reviews or ipc security review. |
Jochen Eisinger | 8f0c8d8 | 2019-10-25 18:28:27 | [diff] [blame] | 165 | Every set of owners should implement their own means of auditing membership. The |
| 166 | minimum expectation is that membership in those files is reevaluated on |
| 167 | project, or affiliation changes. |
| 168 | |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 169 | In this example, only the ATLs are owners: |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 170 | ``` |
| 171 | set noparent |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 172 | file://ATL_OWNERS |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 173 | ``` |
| 174 | |
| 175 | The `per-file` directive allows owners to be added that apply only to files |
Wei-Yin Chen (陳威尹) | 681bc32 | 2017-07-20 01:55:11 | [diff] [blame] | 176 | matching a pattern. In this example, owners from the parent directory |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 177 | apply, plus one person for some classes of files, and all committers are |
| 178 | owners for the readme: |
| 179 | ``` |
| 180 | per-file [email protected] |
| 181 | per-file foo.*[email protected] |
| 182 | |
| 183 | per-file readme.txt=* |
| 184 | ``` |
| 185 | |
| 186 | Other `OWNERS` files can be included by reference by listing the path to the |
| 187 | file with `file://...`. This example indicates that only the people listed in |
| 188 | `//ipc/SECURITY_OWNERS` can review the messages files: |
| 189 | ``` |
| 190 | per-file *_messages*.h=set noparent |
| 191 | per-file *_messages*.h=file://ipc/SECURITY_OWNERS |
Wei-Yin Chen (陳威尹) | 1fb88e2 | 2023-01-09 18:39:55 | [diff] [blame] | 192 | ``` |
Anthony Polito | 9ce2a48 | 2022-02-10 18:39:49 | [diff] [blame] | 193 | |
| 194 | File globbing is supported using the |
Wei-Yin Chen (陳威尹) | 1fb88e2 | 2023-01-09 18:39:55 | [diff] [blame] | 195 | [simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions) |
| 196 | format. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 197 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 198 | ### Owners-Override |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 199 | |
John Abd-El-Malek | dfd1edc | 2021-02-24 22:22:40 | [diff] [blame] | 200 | Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 201 | [sheriffs](sheriffs.md), Release Program Managers, |
| 202 | [Large Scale Changes](#large-scale-changes), |
| 203 | [Global Approvers](#global-approvals) reviewers, |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 204 | [Chrome ATLs](../ATL_OWNERS) |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 205 | have this capability. The power to use Owners-Override should be restricted |
Kentaro Hara | 7e85d34a | 2021-10-08 15:33:16 | [diff] [blame] | 206 | as follows: |
| 207 | |
Kentaro Hara | 23878c6 | 2022-01-28 00:18:41 | [diff] [blame] | 208 | * Active sheriffs and Release Program Managers can set Owners-Override only on |
| 209 | CLs needed for sheriffing and releasing (e.g., revert, reland, test fix, |
| 210 | cherry-pick). |
Kentaro Hara | 0cdc607 | 2021-10-15 00:35:16 | [diff] [blame] | 211 | * Large Scale Change reviewers can set Owners-Override only on sheriffing CLs |
| 212 | and CLs about the approved Large Scale Change. |
| 213 | * Global approvers can set Owners-Override only on sheriffing CLs and |
| 214 | mechanical CLs associated with their API changes. For example, |
| 215 | //base/OWNERS can set Owners-Override on mechanical CLs associated with |
| 216 | //base/ API changes. |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 217 | * Chrome ATLs can set Owners-Override on any changes to help with cases that |
| 218 | cannot be handled by the above groups and expedite CLs when LSC is too |
| 219 | heavyweight. However, please use one of the above groups before asking |
| 220 | Chrome ATLs. |
Kentaro Hara | 0cdc607 | 2021-10-15 00:35:16 | [diff] [blame] | 221 | |
| 222 | When you need Owners-Override on sheriffing CLs, please reach out to the |
| 223 | Active Sheriffs and Release Program Managers first. If none of them is |
| 224 | available, please send an email to lsc-owners-override@chromium.org for help. |
| 225 | |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 226 | Note that Owners-Override by itself is not enough on your own CLs. Where this |
| 227 | matters is when you are sheriffing. For example, if you want to revert or |
Stephen McGruer | 282391a | 2022-08-04 16:46:55 | [diff] [blame] | 228 | disable a test, your Owners-Override on the CL is not enough. You also need |
| 229 | either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit: |
| 230 | +1` from the [rubber-stamper bot](#automated-code_review). |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 231 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 232 | ## Mechanical changes |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 233 | |
John Abd-El-Malek | dfd1edc | 2021-02-24 22:22:40 | [diff] [blame] | 234 | ### Global Approvals |
Dave Tapuska | 4661b90 | 2023-07-12 17:21:45 | [diff] [blame] | 235 | For one-off CLs, API owners of `base`, `build`, `content`, |
| 236 | `third_party/blink/public` and `url` can `Owners-Override +1` a change to their |
| 237 | APIs to avoid waiting for rubberstamp +1s from affected directories' owners. |
| 238 | This should only be used for mechanical updates to the affected directories. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 239 | |
Dirk Pranke | 3042ec9 | 2022-01-12 16:53:40 | [diff] [blame] | 240 | If you are making one-off CLs that touch many directories and cannot be |
John Abd-El-Malek | 704bca0 | 2022-12-14 18:47:59 | [diff] [blame] | 241 | handled by the global approvers, you can ask one of Chrome ATLs. |
Kentaro Hara | 7e85d34a | 2021-10-08 15:33:16 | [diff] [blame] | 242 | |
| 243 | ### Large Scale Changes |
| 244 | You can use the [Large Scale Changes](process/lsc/large_scale_changes.md) |
| 245 | process to get approval to bypass OWNERS enforcement for large changes like |
| 246 | refactoring, architectural changes, or other repetitive code changes across the |
| 247 | whole codebase. This is used for work that span many dozen CLs. |
| 248 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 249 | ## Documentation updates |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 250 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 251 | Documentation updates require code review. We may revisit this decision in the |
| 252 | future. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 253 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 254 | ## Automated code-review |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 255 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 256 | For verifiably safe changes like translation files, clean reverts, and clean |
| 257 | cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label |
| 258 | allowing the CL to be submitted without human code-review. Add `Rubber Stamper` |
| 259 | ([email protected]) to your CL as a reviewer to |
| 260 | activate this automation. It will scan the CL after about 1 minute and reply |
| 261 | with its verdict. `Bot-Commit` votes are not sticky between patchsets and so |
| 262 | only add the bot once the CL is finalized. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 263 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 264 | When combined with the [`Owners-Override`](#owners_override) power, sheriffs can |
| 265 | effectively revert and reland on their own. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 266 | |
Jason Clinton | 6026fd19 | 2021-03-24 19:58:33 | [diff] [blame] | 267 | Rubber Stamper never provides OWNERS approval, by design. It's intended to be |
Jason D. Clinton | c38b61d8 | 2021-04-20 20:02:14 | [diff] [blame] | 268 | used by those who have owners in the directory modified or who are sheriffs. If |
| 269 | it provided both code review and OWNERS approval, that would be an abuse vector: |
| 270 | that would allow anyone who can create a revert or cherry-pick to land it |
| 271 | without any other person being involved (e.g. the silent revert of security |
| 272 | patches). |
Jason Clinton | 6026fd19 | 2021-03-24 19:58:33 | [diff] [blame] | 273 | |
Jason D. Clinton | c38b61d8 | 2021-04-20 20:02:14 | [diff] [blame] | 274 | Changes not supported by `Rubber Stamper` always need a +1 from another |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 275 | committer. |