Debian Codegraph @

Documentation/contributing/gerrit_guidelines.md

raw symbols SCIP
1 coreboot Gerrit Etiquette and Guidelines
2 ========================================
3
4 The following rules are the requirements for behavior in the coreboot
5 codebase in gerrit. These have mainly been unwritten rules up to this
6 point, and should be familiar to most users who have been active in
7 coreboot for a period of time. Following these rules will help reduce
8 friction in the community.
9
10 Note that as with many rules, there are exceptions. Some have been noted
11 in the 'More Detail' section. If you feel there is an exception not listed
12 here, please discuss it in the mailing list to get this document updated.
13 Don't just assume that it's okay, even if someone on IRC says it is.
14
15
16 Summary
17 -------
18 These are the expectations for committing, reviewing, and submitting code
19 into coreboot git and gerrit. While breaking individual rules may not have
20 immediate consequences, the coreboot leadership may act on repeated or
21 flagrant violations with or without notice.
22
23 * Don't violate the licenses.
24 * Let non-trivial patches sit in a review state for at least 24 hours
25 before submission.
26 * Try to coordinate with platform maintainers when making changes to
27 platforms.
28 * If you give a patch a -2, you are responsible for giving concrete
29 recommendations for what could be changed to resolve the issue the patch
30 addresses.
31 * Don't modify other people's patches without their consent.
32 * Be respectful to others when commenting.
33 * Don’t submit patches that you know will break other platforms.
34
35
36 More detail
37 -----------
38 * Don't violate the licenses. If you're submitting code that you didn't
39 write yourself, make sure the license is compatible with the license of the
40 project you're submitting the changes to. If you’re submitting code that
41 you wrote that might be owned by your employer, make sure that your
42 employer is aware and you are authorized to submit the code. For
43 clarification, see the Developer's Certificate of Origin in the coreboot
44 [Signed-off-by policy](#sign-off-procedure).
45
46 * In general, patches should remain open for review for at least 24 hours
47 since the last significant modification to the change. The purpose is to
48 let coreboot developers around the world have a chance to review. Complex
49 reworks, even if they don't change the purpose of the patch but the way
50 it's implemented, should restart the wait period.
51
52 * A change can go in without the wait period if its purpose is to fix
53 a recently-introduced issue (build, boot or OS-level compatibility, not
54 necessarily identified by coreboot.org facilities). Its commit message
55 has to explain what change introduced the problem and the nature of
56 the problem so that the emergency need becomes apparent. Avoid stating
57 something like "fix build error" in the commit summary, describe what
58 the commit does instead, just like any other commit. In addition, it is
59 recommended to reference the commit that introduced the issue. The change
60 itself should be as limited in scope and impact as possible to make it
61 simple to assess the impact. Such a change can be merged early with 3
62 Code-Review+2. For emergency fixes that affect a single project (SoC,
63 mainboard, ...) it's _strongly_ recommended to get a review by somebody
64 not involved with that project to ensure that the documentation of the
65 issue is clear enough.
66
67 * Trivial changes that deal with minor issues like inconsistencies in
68 whitespace or spelling fixes that don't impact the final binary output
69 also don't need to wait. Such changes should point out in their commit
70 messages how the the author verified that the binary output is identical
71 (e.g. a TIMELESS build for a given configuration). When submitting
72 such changes early, the submitter must be different from the author
73 and must document the intent in the Gerrit discussion, e.g. "landed the
74 change early because it's trivial". Note that trivial fixes shouldn't
75 necessarily be expedited: Just like they're not critical enough for
76 things to go wrong because of them, they're not critical enough to
77 require quick handling. This exception merely serves to acknowledge that
78 a round-the-world review just isn't necessary for some types of changes.
79
80 * As explained in our Code of Conduct, we try to assume the best of each
81 other in this community. It's okay to discuss mistakes (e.g. isolated
82 instances of non-trivial and non-critical changes submitted early) but
83 try to keep such inquiries blameless. If a change leads to problems with
84 our code, the focus should be on fixing the issue, not on assigning blame.
85
86 * Do not +2 patches that you authored or own, even for something as trivial
87 as whitespace fixes. When working on your own patches, it’s easy to
88 overlook something like accidentally updating file permissions or git
89 submodule commit IDs. Let someone else review the patch. An exception to
90 this would be if two people worked in the patch together. If both +2 the
91 patch, that is acceptable, as each is giving a +2 to the other's work.
92
93 * Try to coordinate with platform maintainers and other significant
94 contributors to the code when making changes to platforms. The platform
95 maintainers are the users who initially pushed the code for that platform,
96 as well as users who have made significant changes to a platform. To find
97 out who maintains a piece of code, please use util/scripts/maintainers.go
98 or refer to the original author of the code in git log.
99
100 * If you give a patch a -2, you are responsible for giving concrete
101 recommendations for what could be changed to resolve the issue the patch
102 addresses. If you feel strongly that a patch should NEVER be merged, you
103 are responsible for defending your position and listening to other points
104 of view. Giving a -2 and walking away is not acceptable, and may cause your
105 -2 to be removed by the coreboot leadership after no less than a week. A
106 notification that the -2 will be removed unless there is a response will
107 be sent out at least 2 days before it is removed.
108
109 * Don't modify other people's patches unless you have coordinated this with
110 the owner of that patch. Not only is this considered rude, but your changes
111 could be unintentionally lost. An exception to this would be for patches
112 that have not been updated for more than 90 days. In that case, the patch
113 can be taken over if the original author does not respond to requests for
114 updates. Alternatively, a new patch can be pushed with the original
115 content, and both patches should be updated to reference the other.
116
117 * Be respectful to others when commenting on patches. Comments should
118 be kept to the code, and should be kept in a polite tone. We are a
119 worldwide community and English is a difficult language. Assume your
120 colleagues are intelligent and do not intend disrespect. Resist the urge to
121 retaliate against perceived verbal misconduct, such behavior is not
122 conducive to getting patches merged.
123
124 * Don’t submit code that you know will break other platforms. If your patch
125 affects code that is used by other platforms, it should be compatible with
126 those platforms. While it would be nice to update any other platforms, you
127 must at least provide a path that will allow other platforms to continue
128 working.
129
130 Sign-off Procedure
131 ------------------
132 The coreboot project employs a sign-off procedure similar to what is
133 used by the Linux kernel. Each gerrit commit requires a sign-off line
134 saying that the contributed code abides by the Developer's certificate
135 of origin, below.
136 ```text
137 Signed-off-by: Random J Developer <[email protected]>
138 ```
139
140 Using '-s' with 'git commit' will automatically add a Signed-off-by line
141 to your commit message. Patches without a Signed-off-by should not be
142 pushed to gerrit, and will be rejected by coreboot's CI system.
143
144 You must use a known identity in the Signed-off-by line. Anonymous
145 contributions cannot be committed! This can be anything sufficient to
146 identify and contact the source of a contribution, such as your name or
147 an established alias/nickname. Refer to [this LKML thread] and the
148 [SCO-Linux disputes] for the rationale behind the DCO.
149
150 Developer's Certificate of Origin 1.1
151
152 > By making a contribution to this project, I certify that:
153 >
154 > (a) The contribution was created in whole or in part by me and I have
155 > the right to submit it under the open source license indicated in the
156 > file; or
157 >
158 > (b) The contribution is based upon previous work that, to the best of
159 > my knowledge, is covered under an appropriate open source license and
160 > I have the right under that license to submit that work with
161 > modifications, whether created in whole or in part by me, under the
162 > same open source license (unless I am permitted to submit under a
163 > different license), as indicated in the file; or
164 >
165 > (c) The contribution was provided directly to me by some other person
166 > who certified (a), (b) or (c) and I have not modified it; and
167 >
168 > (d) In the case of each of (a), (b), or (c), I understand and agree
169 > that this project and the contribution are public and that a record of
170 > the contribution (including all personal information I submit with it,
171 > including my sign-off) is maintained indefinitely and may be
172 > redistributed consistent with this project or the open source license
173 > indicated in the file.
174
175 Note: The [Developer's Certificate of Origin 1.1] is licensed under the
176 terms of the [Creative Commons Attribution-ShareAlike 2.5 License].
177
178
179 Recommendations for gerrit activity
180 -----------------------------------
181 These guidelines are less strict than the ones listed above. These are more
182 of the “good idea” variety. You are requested to follow the below
183 guidelines, but there will probably be no actual consequences if they’re
184 not followed. That said, following the recommendations below will speed up
185 review of your patches, and make the members of the community do less work.
186
187 * Each patch should be kept to one logical change, which should be
188 described in the title of the patch. Unrelated changes should be split out
189 into separate patches. Fixing whitespace on a line you’re editing is
190 reasonable. Fixing whitespace around the code you’re working on should be a
191 separate ‘cleanup’ patch. Larger patches that touch several areas are fine,
192 so long as they are one logical change. Adding new chips and doing code
193 cleanup over wide areas are two examples of this.
194
195 * Test your patches before submitting them to gerrit. It's also appreciated
196 if you add a line to the commit message describing how the patch was
197 tested. This prevents people from having to ask whether and how the patch
198 was tested. Examples of this sort of comment would be ‘TEST=Built
199 platform’ or ‘Tested by building and booting platform’. Stating that the
200 patch was not tested is also fine, although you might be asked to do some
201 testing in cases where that would be reasonable.
202
203 * Take advantage of the lint tools to make sure your patches don’t contain
204 trivial mistakes. By running ‘make gitconfig’, the lint-stable tools are
205 automatically put in place and will test your patches before they are
206 committed. As a violation of these tools will cause the jenkins build test
207 to fail, it’s to your advantage to test this before pushing to gerrit.
208
209 * Don't submit patch trains longer than around 20 patches unless you
210 understand how to manage long patch trains. Long patch trains can become
211 difficult to handle and tie up the build servers for long periods of time
212 if not managed well. Rebasing a patch train over and over as you fix
213 earlier patches in the train can hide comments, and make people review the
214 code multiple times to see if anything has changed between revisions. When
215 pushing long patch trains, it is recommended to only push the full patch
216 train once - the initial time, and only to rebase three or four patches at
217 a time.
218
219 * Run 'make what-jenkins-does' locally on patch trains before submitting.
220 This helps verify that the patch train won’t tie up the jenkins builders
221 for no reason if there are failing patches in the train. For running
222 parallel builds, you can specify the number of cores to use by setting the
223 the CPUS environment variable. Example:
224
225 ```Bash
226 make what-jenkins-does CPUS=8
227 ```
228
229 * Use a topic when pushing a train of patches. This groups the commits
230 together so people can easily see the connection at the top level of
231 gerrit. Topics can be set for individual patches in gerrit by going into
232 the patch and clicking on the icon next to the topic line. Topics can also
233 be set when you push the patches into gerrit. For example, to push a set of
234 commits with the i915-kernel-x60 set, use the command:
235
236 ```Bash
237 git push origin HEAD:refs/for/main%topic=i915-kernel-x60
238 ```
239
240 * If one of your patches isn't ready to be merged, make sure it's obvious
241 that you don't feel it's ready for merge yet. The preferred way to show
242 this is by marking in the commit message that it’s not ready until X. The
243 commit message can be updated easily when it’s ready to be pushed.
244 Examples of this are "WIP: title" or "[NEEDS_TEST]: title". Another way to
245 mark the patch as not ready would be to give it a -1 or -2 review, but
246 isn't as obvious as the commit message. These patches can also be pushed with
247 the wip flag:
248
249 ```Bash
250 git push origin HEAD:refs/for/main%wip
251 ```
252
253 * When pushing patches that are not for submission, these should be marked
254 as such. This can be done in the title ‘[DONOTSUBMIT]’, or can be pushed as
255 private changes, so that only explicitly added reviewers will see them. These
256 sorts of patches are frequently posted as ideas or RFCs for the community to
257 look at. Note that private changes can still be fetched from Gerrit by anybody
258 who knows their commit ID, so don't use this for sensitive changes. To push
259 a private change, use the command:
260
261 ```Bash
262 git push origin HEAD:refs/for/main%private
263 ```
264
265 * Multiple push options can be combined:
266
267 ```Bash
268 git push origin HEAD:refs/for/main%private,wip,topic=experiment
269 ```
270
271 * Respond to anyone who has taken the time to review your patches, even if
272 it's just to say that you disagree. While it may seem annoying to address a
273 request to fix spelling or 'trivial' issues, it’s generally easy to handle
274 in gerrit’s built-in editor. If you do use the built-in editor, remember to
275 get that change to your local copy before re-pushing. It's also acceptable
276 to add fixes for these sorts of comments to another patch, but it's
277 recommended that that patch be pushed to gerrit before the initial patch
278 gets submitted.
279
280 * Consider breaking up large individual patches into smaller patches
281 grouped by areas. This makes the patches easier to review, but increases
282 the number of patches. The way you want to handle this is a personal
283 decision, as long as each patch is still one logical change.
284
285 * If you have an interest in a particular area or mainboard, set yourself
286 up as a ‘maintainer’ of that area by adding yourself to the MAINTAINERS
287 file in the coreboot root directory. Eventually, this should automatically
288 add you as a reviewer when an area that you’re listed as a maintainer is
289 changed.
290
291 * Submit mainboards that you’re working on to the board-status repo. This
292 helps others and shows that these mainboards are currently being
293 maintained. At some point, boards that are not up to date in the
294 board-status repo will probably end up getting removed from the coreboot
295 main branch.
296
297 * Abandon patches that are no longer useful, or that you don’t intend to
298 keep working on to get submitted.
299
300 * Bring attention to patches that you would like reviewed. Add reviewers,
301 ask for reviewers on IRC or even just rebase it against the current
302 codebase to bring it to the top of the gerrit list. If you’re not sure who
303 would be a good reviewer, look in the MAINTAINERS file or git history of
304 the files that you’ve changed, and add those people.
305
306 * Familiarize yourself with the coreboot [commit message
307 guidelines](#commit-message-guidelines), before pushing
308 patches. This will help to keep annoying requests to fix your commit
309 message to a minimum.
310
311 * If there have been comments or discussion on a patch, verify that the
312 comments have been addressed before giving a +2. If you feel that a comment
313 is invalid, please respond to that comment instead of just ignoring it.
314
315 * Be conscientious when reviewing patches. As a reviewer who approves (+2)
316 a patch, you are responsible for the patch and the effect it has on the
317 codebase. In the event that the patch breaks things, you are expected to
318 be actively involved in the cleanup effort. This means you shouldn’t +2 a
319 patch just because you trust the author of a patch - Make sure you
320 understand what the implications of a patch might be, or leave the review
321 to others. Partial reviews, reviewing code style, for example, can be given
322 a +1 instead of a +2. This also applies if you think the patch looks good,
323 but may not have the experience to know if there may be unintended
324 consequences.
325
326 * If there is still ongoing discussion to a patch, try to wait for a
327 conclusion to the discussion before submitting it to the tree. If you feel
328 that someone is just bikeshedding, maybe just state that and give a time
329 that the patch will be submitted if no new objections are raised.
330
331 * When working with patch trains, for minor requests it’s acceptable to
332 create a fix addressing a comment in another patch at the end of the patch
333 train. This minimizes rebases of the patch train while still addressing the
334 request. For major problems where the change doesn’t work as intended or
335 breaks other platforms, the change really needs to go into the original
336 patch.
337
338 * When bringing in a patch from another git repo, update the original
339 git/gerrit tags by prepending the lines with 'Original-'. Marking
340 the original text this way makes it much easier to tell what changes
341 happened in which repository. This applies to these lines, not the actual
342 commit message itself:
343
344 * Commit-Id:
345 * Change-Id:
346 * Signed-off-by:
347 * Reviewed-on:
348 * Tested-by:
349 * Reviewed-by:
350
351 The script `util/scripts/cross-repo-cherrypick` can be used to help
352 automate this. Other tags such as 'Commit-Queue' can simply be removed.
353
354 * Check if there's documentation that needs to be updated to remain current
355 after your change. If there's no documentation for the part of coreboot
356 you're working on, consider adding some.
357
358 * When contributing a significant change to core parts of the code base (such
359 as the boot state machine or the resource allocator), or when introducing
360 a new way of doing something that you think is worthwhile to apply across
361 the tree (e.g. board variants), please bring up your design on the [mailing
362 list](../community/forums.md). When changing behavior substantially, an
363 explanation of what changes and why may be useful to have, either in the
364 commit message or, if the discussion of the subject matter needs way more
365 space, in the documentation. Since "what we did in the past and why it isn't
366 appropriate anymore" isn't the most useful reading several years down the road,
367 such a description could be put into the release notes for the next version
368 (that you can find in Documentation/releases/) where it will inform people
369 now without cluttering up the regular documentation, and also gives a nice
370 shout-out to your contribution by the next release.
371
372 Expectations contributors should have
373 -------------------------------------
374 * Don't expect that people will review your patch unless you ask them to.
375 Adding other people as reviewers is the easiest way. Asking for reviews for
376 individual patches in the IRC channel, or by sending a direct request to an
377 individual through your favorite messenger is usually the best way to get a
378 patch reviewed quickly.
379
380 * Don't expect that your patch will be submitted immediately after getting
381 a +2. As stated previously, non-trivial patches should wait at least 24
382 hours before being submitted. That said, if you feel that your patch or
383 series of patches has been sitting longer than needed, you can ask for it
384 to be submitted on IRC, or comment that it's ready for submission in the
385 patch. This will move it to the top of the list where it's more likely to
386 be noticed and acted upon.
387
388 * Reviews are about the code. It's easy to take it personally when someone
389 is criticising your code, but the whole idea is to get better code into our
390 codebase. Again, this also applies in the other direction: review code,
391 criticize code, but don’t make it personal.
392
393 Gerrit user roles
394 -----------------
395 There are a few relevant roles a user can have on Gerrit:
396
397 - The anonymous user can check out source code.
398 - A registered user can also comment and give "+1" code reviews.
399 - A reviewer can give "-1" and "+2" code reviews.
400 - A core developer can also give "-2" (that is, blocking) code reviews
401 and submit changes.
402
403 Anybody can register an account on our instance, using either an
404 OpenID provider or OAuth through GitHub or Google.
405
406 The reviewer group is still quite open: Any core developer can add
407 registered users to that group and should do so once some activity
408 (commits, code reviews, and so on) has demonstrated rough knowledge
409 of how we handle things.
410
411 A core developer should be sufficiently well established in the
412 community so that they feel comfortable when submitting good patches,
413 when asking for improvements to less good patches and reasonably
414 uncomfortable when -2'ing patches. They're typically the go-to
415 person for _some_ part of the coreboot tree and ideally listed as its
416 maintainer in our MAINTAINERS registry. To become part of this group,
417 a candidate developer who already demonstrated proficiency with the
418 code base as a reviewer should be nominated, by themselves or others,
419 at the regular [coreboot leadership meetings](../community/forums.md)
420 where a decision is made.
421
422 Core developers are expected to use their privileges for the good of the
423 project, which includes any of their own coreboot development but also beyond
424 that. They should make sure that [ready changes] don't linger around needlessly
425 just because their authors aren't well-connected with core developers but
426 submit them if they went through review and generally look reasonable. They're
427 also expected to help clean-up breakage as a result of their submissions.
428
429 Since the project expects some activity by core developers, long-term absence
430 (as in "years") can lead to removal from the group, which can easily be
431 reversed after they come back.
432
433 Requests for clarification and suggestions for updates to these guidelines
434 should be sent to the coreboot mailing list at <[email protected]>.
435
436 Commit message guidelines
437 -------------------------
438 Git does not enforce a certain style for commit messages. For all aspects of
439 Git to work best with, it's important to follow these simple guidelines for
440 commit messages:
441
442 * The first line of the commit message consists of a short
443 (less than 65 characters, absolute maximum is 75) summary
444 * The second line is empty (no whitespace at all)
445 * The third and any following number of lines contains a longer description
446 of the commit as is necessary, including relevant background information
447 and quite possibly rationale for why the issue was solved in this particular
448 way. These lines should never be longer than 75 characters.
449 * The next line is empty (no whitespace at all)
450 * An optional TEST= line which describes the test that was done in order to
451 validate the patch
452 * An optional BUG= line to reference to a bug (of [coreboot's bug tracker] or any
453 other) this patch resolves
454 * The next line is empty if the optional lines are used
455 * A Change-Id: line to let Gerrit track this logical change
456 * A Signed-off-by: line according to [Signed-off-by policy](#sign-off-procedure)
457
458 Please do not create the Change-Id: and Signed-off-by: entries manually because
459 it is boring and error-prone. Instead, please install the commit-msg hook, e.g.
460 by running
461 ```Bash
462 make gitconfig
463 ```
464 in coreboot's top-level directory, and let the hook script do it for you.
465 And remember to always use
466 ```Bash
467 git commit -s
468 ```
469 to have git add your Signed-off-by: automatically.
470
471 When you write your commit message, please keep the following two hints in mind:
472
473 * If anyone involved in coreboot reads your comment in a year or so, they
474 shall still be able to understand what your commit is about, without the need
475 to analyze the code.
476 * Double-check that you are really committing what you think you are, e.g. by
477 typing the following in the top-level coreboot directory:
478 ```Bash
479 git show
480 ```
481
482 [ready changes]: https://review.coreboot.org/q/age:1d+project:coreboot+status:open+is:mergeable+label:All-Comments-Resolved%253Dok+label:Code-Review%253D2+-label:Code-Review%253C0+label:Verified%253D1+-label:Verified-1
483 [Developer's Certificate of Origin 1.1]: https://developercertificate.org/
484 [Creative Commons Attribution-ShareAlike 2.5 License]: https://creativecommons.org/licenses/by-sa/2.5/
485 [this LKML thread]: https://lkml.org/lkml/2004/5/23/10
486 [SCO-Linux disputes]: https://en.wikipedia.org/wiki/SCO%E2%80%93Linux_disputes
487 [coreboot's bug tracker]: https://ticket.coreboot.org/