misc: Update CONTRIBUTING with gerrit changes
[gem5.git] / CONTRIBUTING.md
1 Authors: Jason Lowe-Power
2 Andreas Sandberg
3 Steve Reinhardt
4
5 If you've made changes to gem5 that might benefit others, we strongly encourage
6 you to contribute those changes to the public gem5 repository. There are
7 several reasons to do this:
8 * Share your work with others, so that they can benefit from new functionality.
9 * Support the scientific principle by enabling others to evaluate your
10 suggestions without having to guess what you did.
11 * Once your changes are part of the main repo, you no longer have to merge
12 them back in every time you update your local repo. This can be a huge time
13 saving!
14 * Once your code is in the main repo, other people have to make their changes
15 work with your code, and not the other way around.
16 * Others may build on your contributions to make them even better, or extend
17 them in ways you did not have time to do.
18 * You will have the satisfaction of contributing back to the community.
19
20 The main method for contributing code to gem5 is via our code review website:
21 https://gem5-review.googlesource.com/. This documents describes the details of
22 how to create code changes, upload your changes, have your changes
23 reviewed, and finally push your changes to gem5. More information can be found
24 from the following sources:
25 * http://gem5.org/Submitting_Contributions
26 * https://gerrit-review.googlesource.com/Documentation/index.html
27 * https://git-scm.com/book
28
29
30 High-level flow for submitting changes
31 ======================================
32
33 +-------------+
34 | Make change |
35 +------+------+
36 |
37 |
38 v
39 +------+------+
40 | Post review |
41 +------+------+
42 |
43 v
44 +--------+---------+
45 | Wait for reviews | <--------+
46 +--------+---------+ |
47 | |
48 | |
49 v |
50 +----+----+ No +------+------+
51 |Reviewers+--------->+ Update code |
52 |happy? | +------+------+
53 +----+----+ ^
54 | |
55 | Yes |
56 v |
57 +----+-----+ No |
58 |Maintainer+----------------+
59 |happy? |
60 +----+-----+
61 |
62 | Yes
63 v
64 +------+------+
65 | Submit code |
66 +-------------+
67
68 After creating your change to gem5, you can post a review on our Gerrit
69 code-review site: https://gem5-review.googlesource.com. Before being able to
70 submit your code to the mainline of gem5, the code is reviewed by others in the
71 community. Additionally, the maintainer for that part of the code must sign off
72 on it.
73
74 Cloning the gem5 repo to contribute
75 ===================================
76
77 If you plan on contributing, it is strongly encouraged for you to clone the
78 repository directly from our gerrit instance at
79 https://gem5.googlesource.com/.
80
81 To clone the master gem5 repository:
82 ```
83 git clone https://gem5.googlesource.com/public/gem5
84 ```
85
86 Other gem5 repositories
87 -----------------------
88
89 There are a few repositories other than the main gem5 development repository.
90
91 * public/m5threads: The code for a pthreads implementation that works with
92 gem5's syscall emulation mode.
93
94 Other gem5 branches
95 -------------------
96
97 None right now.
98
99 Making changes to gem5
100 ======================
101
102 It is strongly encouraged to use git branches when making changes to gem5.
103 Additionally, keeping changes small and concise and only have a single logical
104 change per commit.
105
106 Unlike our previous flow with Mercurial and patch queues, when using git, you
107 will be committing changes to your local branch. By using separate branches in
108 git, you will be able to pull in and merge changes from mainline and simply
109 keep up with upstream changes.
110
111 Requirements for change descriptions
112 ------------------------------------
113 To help reviewers and future contributors more easily understand and track
114 changes, we require all change descriptions be strictly formatted.
115
116 A canonical commit message consists of three parts:
117 * A short summary line describing the change. This line starts with one or
118 more keywords (found in the MAINTAINERS file) separated by commas followed
119 by a colon and a description of the change. This line should be no more than
120 65 characters long since version control systems usually add a prefix that
121 causes line-wrapping for longer lines.
122 * (Optional, but highly recommended) A detailed description. This describes
123 what you have done and why. If the change isn't obvious, you might want to
124 motivate why it is needed. Lines need to be wrapped to 75 characters or
125 less.
126 * Tags describing patch metadata. You are highly recommended to use
127 tags to acknowledge reviewers for their work. Gerrit will automatically add
128 most tags.
129
130 Tags are an optional mechanism to store additional metadata about a patch and
131 acknowledge people who reported a bug or reviewed that patch. Tags are
132 generally appended to the end of the commit message in the order they happen.
133 We currently use the following tags:
134 * Signed-off-by: Added by the author and the submitter (if different).
135 This tag is a statement saying that you believe the patch to be correct and
136 have the right to submit the patch according to the license in the affected
137 files. Similarly, if you commit someone else's patch, this tells the rest
138 of the world that you have have the right to forward it to the main
139 repository. If you need to make any changes at all to submit the change,
140 these should be described within hard brackets just before your
141 Signed-off-by tag. By adding this line, the contributor certifies the
142 contribution is made under the terms of the Developer Certificate of Origin
143 (DCO) [https://developercertificate.org/].
144 * Reviewed-by: Used to acknowledge patch reviewers. It's generally considered
145 good form to add these. Added automatically.
146 * Reported-by: Used to acknowledge someone for finding and reporting a bug.
147 * Reviewed-on: Link to the review request corresponding to this patch. Added
148 automatically.
149 * Change-Id: Used by Gerrit to track changes across rebases. Added
150 automatically with a commit hook by git.
151 * Tested-by: Used to acknowledge people who tested a patch. Sometimes added
152 automatically by review systems that integrate with CI systems.
153
154 Other than the "Signed-off-by", "Reported-by", and "Tested-by" tags, you
155 generally don't need to add these manually as they are added automatically by
156 Gerrit.
157
158 It is encouraged for the author of the patch and the submitter to add a
159 Signed-off-by tag to the commit message. By adding this line, the contributor
160 certifies the contribution is made under the terms of the Developer Certificate
161 of Origin (DCO) [https://developercertificate.org/].
162
163 It is imperative that you use your real name and your real email address in
164 both tags and in the author field of the changeset.
165
166 For significant changes, authors are encouraged to add copyright information
167 and their names at the beginning of the file. The main purpose of the author
168 names on the file is to track who is most knowledgeable about the file (e.g.,
169 who has contributed a significant amount of code to the file).
170
171 Note: If you do not follow these guidelines, the gerrit review site will
172 automatically reject your patch.
173 If this happens, update your changeset descriptions to match the required style
174 and resubmit. The following is a useful git command to update the most recent
175 commit (HEAD).
176
177 ```
178 git commit --amend
179 ```
180
181 Posting a review
182 ================
183
184 If you have not signed up for an account on the Gerrit review site
185 (https://gem5-review.googlesource.com), you first have to create an account.
186
187 Setting up an account
188 ---------------------
189 1. Go to https://gem5.googlesource.com/
190 2. Click "Sign In" in the upper right corner. Note: You will need a Google
191 account to contribute.
192 3. After signing in, click "Generate Password" and follow the instructions.
193
194 Submitting a change
195 -------------------
196
197 In gerrit, to submit a review request, you can simply push your git commits to
198 a special named branch. For more information on git push see
199 https://git-scm.com/docs/git-push.
200
201 There are three ways to push your changes to gerrit.
202
203 Push change to gerrit review
204 ----------------------------
205
206 ```
207 git push origin HEAD:refs/for/master
208 ```
209
210 Assuming origin is https://gem5.googlesource.com/public/gem5 and you want to
211 push the changeset at HEAD, this will create a new review request on top of the
212 master branch. More generally,
213
214 ```
215 git push <gem5 gerrit instance> <changeset>:refs/for/<branch>
216 ```
217
218 See https://gerrit-review.googlesource.com/Documentation/user-upload.html for
219 more information.
220
221 Pushing your first change
222 --------------------------
223 The first time you push a change you may get the following error:
224
225 ```
226 remote: ERROR: [fb1366b] missing Change-Id in commit message footer
227 ...
228 ```
229
230 Within the error message, there is a command line you should run. For every new
231 clone of the git repo, you need to run the following command to automatically
232 insert the change id in the the commit (all on one line).
233
234 ```
235 curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
236 https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; \
237 chmod +x `git rev-parse --git-dir`/hooks/commit-msg
238 ```
239
240 If you receive the above error, simply run this command and then amend your
241 changeset.
242
243 ```
244 git commit --amend
245 ```
246
247 Push change to gerrit as a draft/private
248 ----------------------------------------
249
250 See https://gerrit-review.googlesource.com/Documentation/intro-user.html#private-changes
251 for details on private gerrit changes.
252
253 ```
254 git push origin HEAD:refs/for/master%private
255 ```
256
257 Once you have pushed your change as "private", you can log onto [gerrit]
258 (https://gem5-review.googlesource.com) and once you're happy with the commit
259 click the "unmark private" which may be hidden in the "more options" dropdown
260 in the upper right corner.
261
262 Push change bypassing gerrit
263 -----------------------------
264
265 Only maintainers can bypass gerrit review. This should very rarely be used.
266
267 ```
268 git push origin HEAD:refs/heads/master
269 ```
270
271 Other gerrit push options
272 -------------------------
273
274 There are a number of options you can specify when uploading your changes to
275 gerrit (e.g., reviewers, labels). The gerrit documentation has more
276 information.
277 https://gerrit-review.googlesource.com/Documentation/user-upload.html
278
279
280 Reviewing patches
281 =================
282
283 Reviewing patches is done on our gerrit instance at
284 https://gem5-review.googlesource.com/.
285
286 After logging in with your Google account, you will be able to comment, review,
287 and push your own patches as well as review others' patches. All gem5 users are
288 encouraged to review patches. The only requirement to review patches is to be
289 polite and respectful of others.
290
291 There are multiple labels in Gerrit that can be applied to each review detailed
292 below.
293 * Code-review: This is used by any gem5 user to review patches. When reviewing
294 a patch you can give it a score of -2 to +2 with the following semantics.
295 * -2: This blocks the patch. You believe that this patch should never be
296 committed. This label should be very rarely used.
297 * -1: You would prefer this is not merged as is
298 * 0: No score
299 * +1: This patch seems good, but you aren't 100% confident that it should be
300 pushed.
301 * +2: This is a good patch and should be pushed as is.
302 * Maintainer: Currently only PMC members are maintainers. At least one
303 maintainer must review your patch and give it a +1 before it can be merged.
304 * Verified: This is automatically generated from the continuous integrated
305 (CI) tests. Each patch must receive at least a +1 from the CI tests before
306 the patch can be merged. The patch will receive a +1 if gem5 builds and
307 runs, and it will receive a +2 if the stats match.
308 * Style-Check: This is automatically generated and tests the patch against the
309 gem5 code style (http://www.gem5.org/Coding_Style). The patch must receive a
310 +1 from the style checker to be pushed.
311
312 Note: Whenever the patch creator updates the patch all reviewers must re-review
313 the patch. There is no longer a "Fix it, then Ship It" option.
314
315 Once you have received reviews for your patch, you will likely need to make
316 changes. To do this, you should update the original git changeset. Then, you
317 can simply push the changeset again to the same Gerrit branch to update the
318 review request.
319
320 ```
321 git push origin HEAD:refs/for/master
322 ```
323
324 Note: If you have posted a patch and don't receive any reviews, you may need to
325 prod the reviewers. You can do this by adding a reply to your changeset review
326 on gerrit. It is expected that at least the maintainer will supply a review for
327 your patch.
328
329 Committing changes
330 ==================
331
332 Each patch must meet the following criteria to be merged:
333 * At least one review with +2
334 * At least one maintainer with +1
335 * At least +1 from the CI tests (gem5 must build and run)
336 * At least +1 from the style checker
337
338 Once a patch meets the above criteria, the submitter of the patch will be able
339 to merge the patch by pressing the "Submit" button on Gerrit. When the patch is
340 submitted, it is merged into the public gem5 branch.