Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 1 | # Commit Checklist for Chromium Workflow |
| 2 | |
| 3 | Here is a helpful checklist to go through before uploading change lists (CLs) |
| 4 | on Gerrit. This checklist is designed to be streamlined. See [contributing to |
| 5 | Chromium][contributing] for a more thorough reference. |
| 6 | |
| 7 | [TOC] |
| 8 | |
| 9 | ## 1. Create a new branch |
| 10 | |
| 11 | You should create a new branch before starting any development work. It's |
| 12 | helpful to branch early and to branch often in Git. |
| 13 | |
| 14 | git new-branch <branch_name> |
| 15 | |
| 16 | which is equivalent to |
| 17 | |
| 18 | git checkout -b <branch_name> --track origin/master |
| 19 | |
| 20 | ## 2. Make sure the code builds correctly |
| 21 | |
| 22 | After making your changes, check that common targets build correctly: |
| 23 | |
| 24 | * chrome (for Linux, ChromeOS, etc.) |
| 25 | * unit_tests |
| 26 | * browser_tests |
| 27 | |
| 28 | It's easy to inadvertently break one of the other builds you're not currently |
| 29 | working on without realizing it. Even though the Commit Queue should catch any |
| 30 | build errors, checking locally first can save you some time since the CQ Dry Run |
| 31 | can take a while. |
| 32 | |
| 33 | ## 3. Test your changes |
| 34 | |
| 35 | Make sure you hit every code path you changed. |
| 36 | |
| 37 | ## 4. Write unit or browser tests for any new code |
| 38 | |
| 39 | Consider automating any manual testing you did in the previous step. |
| 40 | |
| 41 | ## 5. Ensure the code is formatted nicely |
| 42 | |
| 43 | Run `git cl format --js`. The `--js` option also formats JavaScript changes. |
| 44 | |
| 45 | ## 6. Check over your changes |
| 46 | |
| 47 | Run `git upstream-diff` to check over all of the changes you've made from |
| 48 | the most recent checkpoint on the remote repository. |
| 49 | |
| 50 | ## 7. Stage relevant files for commit |
| 51 | |
| 52 | Run `git add <path_to_file>` for all of the relevant files you've modified. |
| 53 | |
| 54 | ## 8. Commit your changes |
| 55 | |
| 56 | Run `git commit`. Here are some |
| 57 | [tips for writing good commit messages][uploading-a-change-for-review]. |
| 58 | |
| 59 | ## 9. Rebase your local repository |
| 60 | |
| 61 | Run `git rebase-update`. This command updates all of your local branches with |
| 62 | remote changes that have landed since you started development work, which |
| 63 | could've been a while ago. It also deletes any branches that match the remote |
| 64 | repository, such as after the CL associated with that branch had merged. You |
| 65 | may run into rebase conflicts which should be manually fixed before proceeding |
| 66 | with `git rebase --continue`. Rebasing prevents unintended changes from creeping |
| 67 | into your CL. |
| 68 | |
| 69 | Note that rebasing has the potential to break your build, so you might want to |
| 70 | try re-building afterwards. |
| 71 | |
| 72 | ## 10. Upload the CL to Gerrit |
| 73 | |
| 74 | Run `git cl upload`. Some useful options include: |
| 75 | |
| 76 | * `--cq-dry-run` (or `-d`) will set the patchset to do a CQ Dry Run. |
| 77 | * `-r <chromium_username>` will add reviewers. |
| 78 | * `-b <bug_number>` automatically populates the bug reference line of the commit |
| 79 | message. |
| 80 | |
| 81 | ## 11. Check the CL again in Gerrit |
| 82 | |
| 83 | Run `git cl web` to go to the Gerrit URL associated with the current branch. |
| 84 | Open the latest patch set and verify that all of the uploaded files are |
| 85 | correct. Click `Expand All` to check over all of the individual line-by-line |
| 86 | changes again. |
| 87 | |
| 88 | ## 12. Make sure all auto-regression tests pass |
| 89 | |
| 90 | Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the |
| 91 | commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before |
| 92 | notifying your reviewers, in case the results require major changes in your CL. |
| 93 | |
| 94 | ## 13. Add reviewers to review your code |
| 95 | |
| 96 | Click `Find Owners` or run `git cl owners` to find file owners to review your |
| 97 | code and instruct them about which parts you want them to focus on. Add anyone |
| 98 | else you think should review your code. For your CL to land, you need an |
| 99 | approval from an owner for each file you've changed, unless you are an owner of |
| 100 | some files, in which case you don't need separate owner approval for those |
| 101 | files. |
| 102 | |
| 103 | ## 14. Implement feedback from your reviewers |
| 104 | |
| 105 | Then go through this commit checklist again. Reply to all comments from the |
| 106 | reviewers on Gerrit and mark all resolved issues as resolved (clicking `Done` or |
| 107 | `Ack` will do this automatically). Click `Reply` to ensure that your reviewers |
| 108 | receive a notification. Doing this signals that your CL is ready for review |
| 109 | again, since the assumption is that your CL is not ready for review until you |
| 110 | hit reply. |
| 111 | |
| 112 | ## 15. Land your CL |
| 113 | |
| 114 | Once you have obtained a Looks Good To Me (LGTM), which is reflected by a |
| 115 | Code-Review+1 in Gerrit, from at least one owner for each file, then you have |
| 116 | the minimum prerequisite to land your changes. It may be helpful to wait for all |
| 117 | of your reviewers to approve your changes as well, even if they're not owners. |
| 118 | Click `Submit to CQ` to try your change in the commit queue (CQ), which will |
| 119 | land it if successful. |
| 120 | |
| 121 | After your CL is landed, you can use `git rebase-update` or `git cl archive` to |
| 122 | clean up your local branches. |
| 123 | |
| 124 | [//]: # (the reference link section should be alphabetically sorted) |
| 125 | [contributing]: contributing.md |
| 126 | [uploading-a-change-for-review]: contributing.md#Uploading-a-change-for-review |