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 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 29 | #### Expectations for all reviewers |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 30 | |
| 31 | * Aim to provide some kind of actionable response within 24 hours of receipt |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 32 | (not counting weekends and holidays). This doesn't mean you have to do a |
| 33 | complete review, but you should be able to give some initial feedback, |
| 34 | request more time, or suggest another reviewer. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 35 | |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 36 | * 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] | 37 | you'll be back. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 38 | |
| 39 | * Don't generally discourage people from sending you code reviews. This |
Michael Giuffrida | af36705 | 2018-03-22 20:22:34 | [diff] [blame] | 40 | includes using a blanket "slow" in your status field. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 41 | |
| 42 | ## OWNERS files |
| 43 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 44 | In various directories there are files named `OWNERS` that list the email |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 45 | addresses of people qualified to review changes in that directory. You must |
| 46 | get a positive review from an owner of each directory your change touches. |
| 47 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 48 | Owners files are recursive, so each file also applies to its subdirectories. |
| 49 | It's generally best to pick more specific owners. People listed in higher-level |
thestig | 9208d8ba | 2017-06-09 22:05:32 | [diff] [blame] | 50 | directories may have less experience with the code in question. For example, |
| 51 | the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely |
| 52 | be more familiar with code in `//chrome/browser/component_name/sub_component` |
| 53 | than reviewers in the higher-level `//chrome/OWNERS` file. |
| 54 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 55 | More detail on the owners file format is provided [here](#owners-file-details). |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 56 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 57 | *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] | 58 | this functionality in the Reviewers field of CLs. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 59 | |
| 60 | While owners must approve all patches, any committer can contribute to the |
| 61 | review. In some directories the owners can be overloaded or there might be |
| 62 | people not listed as owners who are more familiar with the low-level code in |
| 63 | question. In these cases it's common to request a low-level review from an |
| 64 | appropriate person, and then request a high-level owner review once that's |
| 65 | complete. As always, be clear what you expect of each reviewer to avoid |
| 66 | duplicated work. |
| 67 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 68 | Owners do not have to pick other owners for reviews. Since they should already |
| 69 | be familiar with the code in question, a thorough review from any appropriate |
| 70 | committer is sufficient. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 71 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 72 | #### Expectations of owners |
| 73 | |
| 74 | 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] | 75 | preferable to have many directories, each with a smaller number of specific |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 76 | owners rather than large directories with many owners. Owners should: |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 77 | |
| 78 | * Demonstrate excellent judgment, teamwork and ability to uphold Chrome |
| 79 | development principles. |
| 80 | |
| 81 | * Be already acting as an owner, providing high-quality reviews and design |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 82 | feedback. |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 83 | |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 84 | * Be a Chromium project member with full commit access of at least three |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 85 | months tenure. |
| 86 | |
| 87 | * Have submitted a substantial number of non-trivial changes to the affected |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 88 | directory. |
| 89 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 90 | * Have committed or reviewed substantial work to the affected directory |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 91 | within the last ninety days. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 92 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 93 | * Have the bandwidth to contribute to reviews in a timely manner. If the load |
| 94 | is unsustainable, work to expand the number of owners. Don't try to |
| 95 | discourage people from sending reviews, including writing "slow" or |
| 96 | "emeritus" after your name. |
| 97 | |
Dirk Pranke | 4f9740c | 2018-10-17 03:01:06 | [diff] [blame] | 98 | The above are guidelines more than they are hard rules, and exceptions are |
| 99 | okay as long as there is a consensus by the existing owners for them. |
| 100 | For example, seldom-updated directories may have exceptions to the |
| 101 | "substantiality" and "recency" requirements. Directories in `third_party` |
| 102 | should list those most familiar with the library, regardless of how often |
| 103 | the code is updated. |
brettw | 40e953e | 2017-02-08 17:49:28 | [diff] [blame] | 104 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 105 | ### OWNERS file details |
| 106 | |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 107 | Refer to the [source code](https://chromium.googlesource.com/chromium/tools/depot_tools/+/main/owners.py) |
thestig | 9208d8ba | 2017-06-09 22:05:32 | [diff] [blame] | 108 | for all details on the file format. |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 109 | |
| 110 | This example indicates that two people are owners, in addition to any owners |
| 111 | from the parent directory. `git cl owners` will list the comment after an |
| 112 | owner address, so this is a good place to include restrictions or special |
| 113 | instructions. |
| 114 | ``` |
| 115 | # You can include comments like this. |
| 116 | [email protected] |
| 117 | [email protected] # Only for the frobinator. |
| 118 | ``` |
| 119 | |
| 120 | A `*` indicates that all committers are owners: |
| 121 | ``` |
| 122 | * |
| 123 | ``` |
| 124 | |
brettw | d040b0be | 2017-02-09 19:11:33 | [diff] [blame] | 125 | The text `set noparent` will stop owner propagation from parent directories. |
Jochen Eisinger | ea8f92d8 | 2017-08-02 17:40:14 | [diff] [blame] | 126 | This should be rarely used. If you want to use `set noparent` except for IPC |
| 127 | related files, please first reach out to chrome-eng-review@google.com. |
| 128 | |
Jochen Eisinger | 8f0c8d8 | 2019-10-25 18:28:27 | [diff] [blame] | 129 | You have to use `set noparent` together with a reference to a file that lists |
| 130 | the owners for the given use case. Approved use cases are listed in |
| 131 | `//build/OWNERS.setnoparent`. Owners listed in those files are expected to |
| 132 | execute special governance functions such as eng review or ipc security review. |
| 133 | Every set of owners should implement their own means of auditing membership. The |
| 134 | minimum expectation is that membership in those files is reevaluated on |
| 135 | project, or affiliation changes. |
| 136 | |
| 137 | In this example, only the eng reviewers are owners: |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 138 | ``` |
| 139 | set noparent |
Jochen Eisinger | 8f0c8d8 | 2019-10-25 18:28:27 | [diff] [blame] | 140 | file://ENG_REVIEW_OWNERS |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 141 | ``` |
| 142 | |
| 143 | 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] | 144 | matching a pattern. In this example, owners from the parent directory |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 145 | apply, plus one person for some classes of files, and all committers are |
| 146 | owners for the readme: |
| 147 | ``` |
| 148 | per-file [email protected] |
| 149 | per-file foo.*[email protected] |
| 150 | |
| 151 | per-file readme.txt=* |
| 152 | ``` |
| 153 | |
George Burgess IV | 1ef0493 | 2018-01-27 07:04:04 | [diff] [blame] | 154 | Note that `per-file` directives cannot directly specify subdirectories, e.g: |
| 155 | ``` |
| 156 | per-file foo/[email protected] |
| 157 | ``` |
| 158 | |
| 159 | is not OK; instead, place a `per-file` directive in `foo/OWNERS`. |
| 160 | |
brettw | 2019b9e | 2017-02-09 06:40:20 | [diff] [blame] | 161 | Other `OWNERS` files can be included by reference by listing the path to the |
| 162 | file with `file://...`. This example indicates that only the people listed in |
| 163 | `//ipc/SECURITY_OWNERS` can review the messages files: |
| 164 | ``` |
| 165 | per-file *_messages*.h=set noparent |
| 166 | per-file *_messages*.h=file://ipc/SECURITY_OWNERS |
| 167 | ``` |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 168 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 169 | ### Owners-Override |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 170 | |
John Abd-El-Malek | dfd1edc | 2021-02-24 22:22:40 | [diff] [blame] | 171 | Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active |
Kentaro Hara | 7e85d34a | 2021-10-08 15:33:16 | [diff] [blame^] | 172 | [sheriffs](sheriffs.md), Release Program Managers, |
| 173 | [Large Scale Changes](#large-scale-changes), |
| 174 | [Global Approvers](#global-approvals) reviewers, |
| 175 | [Chrome Eng Review members](https://chromium.googlesource.com/chromium/src/+/HEAD/ENG_REVIEW_OWNERS) |
| 176 | have this capability. The power to use Owners-Override should be restricted |
| 177 | as follows: |
| 178 | |
| 179 | * Active sheriffs can set Owners-Override only on changes needed for |
| 180 | sheriffing (e.g., revert, reland, test fix). |
| 181 | * Release Program Managers can set Owners-Override only on changes needed |
| 182 | for releasing (e.g., revert, reland, test fix, cherry-pick). |
| 183 | * Large Scale Change reviewers can set Owners-Override only on changes |
| 184 | about the approved Large Scale Change. |
| 185 | * Global approvers can set Owners-Override only on mechanical changes |
| 186 | associated with their API changes. For example, //base/OWNERS can set |
| 187 | Owners-Override only on mechanical changes associated with //base/ API |
| 188 | changes. |
| 189 | * Chrome Eng Review members can set Owners-Override on any changes to help |
| 190 | with cases that cannot be handled by the above groups. However, please |
| 191 | use one of the above groups before asking Chrome Eng Review members. |
| 192 | |
| 193 | Note that Owners-Override by itself is not enough on your own CLs. Where this |
| 194 | matters is when you're sheriffing. For example, if you want to revert or |
| 195 | disable a test, your Owners-Override on the CL is not enough. You need |
| 196 | another committer to LGTM the CL. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 197 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 198 | ## Mechanical changes |
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 | ### Global Approvals |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 201 | For one-off CLs, API owners of `base`, `build`, `content`, `third_party/blink` |
| 202 | and `url` can `Owners-Override +1` a change to their APIs to avoid waiting for |
| 203 | rubberstamp +1s from affected directories' owners. This should only be used for |
| 204 | mechanical updates to the affected directories. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 205 | |
Kentaro Hara | 7e85d34a | 2021-10-08 15:33:16 | [diff] [blame^] | 206 | If you are making one-off CLs that touch many directories and cannot be |
| 207 | handled by the global approvers, you can ask one of Chrome Eng Review members. |
| 208 | |
| 209 | ### Large Scale Changes |
| 210 | You can use the [Large Scale Changes](process/lsc/large_scale_changes.md) |
| 211 | process to get approval to bypass OWNERS enforcement for large changes like |
| 212 | refactoring, architectural changes, or other repetitive code changes across the |
| 213 | whole codebase. This is used for work that span many dozen CLs. |
| 214 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 215 | ## Documentation updates |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 216 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 217 | Documentation updates require code review. We may revisit this decision in the |
| 218 | future. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 219 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 220 | ## Automated code-review |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 221 | |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 222 | For verifiably safe changes like translation files, clean reverts, and clean |
| 223 | cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label |
| 224 | allowing the CL to be submitted without human code-review. Add `Rubber Stamper` |
| 225 | (rubber-stamper@appspot.gserviceaccount.com) to your CL as a reviewer to |
| 226 | activate this automation. It will scan the CL after about 1 minute and reply |
| 227 | with its verdict. `Bot-Commit` votes are not sticky between patchsets and so |
| 228 | only add the bot once the CL is finalized. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 229 | |
Lei Zhang | 3b32caa | 2021-03-22 17:24:19 | [diff] [blame] | 230 | When combined with the [`Owners-Override`](#owners_override) power, sheriffs can |
| 231 | effectively revert and reland on their own. |
Steve Kobes | f885edf | 2018-09-11 13:41:11 | [diff] [blame] | 232 | |
Jason Clinton | 6026fd19 | 2021-03-24 19:58:33 | [diff] [blame] | 233 | 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] | 234 | used by those who have owners in the directory modified or who are sheriffs. If |
| 235 | it provided both code review and OWNERS approval, that would be an abuse vector: |
| 236 | that would allow anyone who can create a revert or cherry-pick to land it |
| 237 | without any other person being involved (e.g. the silent revert of security |
| 238 | patches). |
Jason Clinton | 6026fd19 | 2021-03-24 19:58:33 | [diff] [blame] | 239 | |
Jason D. Clinton | c38b61d8 | 2021-04-20 20:02:14 | [diff] [blame] | 240 | Changes not supported by `Rubber Stamper` always need a +1 from another |
Jason Clinton | 0daf7b0 | 2021-02-09 20:36:22 | [diff] [blame] | 241 | committer. |