Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 1 | # Contributing |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 2 | |
| 3 | We'd love to accept your patches and contributions to Pigweed. There are just a |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 4 | few small guidelines you need to follow. Before making or sending major changes, |
| 5 | please reach out on the [mailing list](mailto:pigweed@googlegroups.com) first to |
| 6 | ensure the changes make sense for upstream. We generally go through a design |
| 7 | phase before making large changes. |
| 8 | |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 9 | Before participating in our community, please take a moment to review our [code |
| 10 | of conduct](CODE_OF_CONDUCT.md). We expect everyone who interacts with the |
| 11 | project to respect these guidelines. |
| 12 | |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 13 | Pigweed contribution overview: |
| 14 | 1. One-time contributor setup: |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 15 | * Sign the [Contributor License Agreement](https://cla.developers.google.com/). |
David Rogers | 839a29e | 2020-03-24 19:29:49 -0700 | [diff] [blame^] | 16 | * Verify that Git user email (git config user.email) is either Google Account |
| 17 | email or an Alternate email for the Google account used to sign the CLA (Manage |
| 18 | Google account->Personal Info->email). |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 19 | * Install the [Gerrit commit hook](CONTRIBUTING.md#gerrit-commit-hook) to |
David Rogers | 839a29e | 2020-03-24 19:29:49 -0700 | [diff] [blame^] | 20 | automatically add a `Change-Id: ...` line to your commit. |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 21 | * Install the Pigweed presubmit check hook (`pw presubmit --install`). |
David Rogers | 839a29e | 2020-03-24 19:29:49 -0700 | [diff] [blame^] | 22 | (recommended). |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 23 | 2. Ensure all files include a correct [copyright and license header](CONTRIBUTING.md#source-code-headers). |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 24 | 2. Upload the change with `git push origin HEAD:refs/for/master`. |
David Rogers | 839a29e | 2020-03-24 19:29:49 -0700 | [diff] [blame^] | 25 | 3. Address any reviewer feedback by amending the commit (`git commit --amend`). |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 26 | 4. Submit change to CI builders to merge. |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 27 | |
| 28 | ## Contributor License Agreement |
| 29 | |
| 30 | Contributions to this project must be accompanied by a Contributor License |
| 31 | Agreement. You (or your employer) retain the copyright to your contribution; |
| 32 | this simply gives us permission to use and redistribute your contributions as |
| 33 | part of the project. Head over to <https://cla.developers.google.com/> to see |
| 34 | your current agreements on file or to sign a new one. |
| 35 | |
| 36 | You generally only need to submit a CLA once, so if you've already submitted one |
| 37 | (even if it was for a different project), you probably don't need to do it |
| 38 | again. |
| 39 | |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 40 | ## Gerrit Commit Hook |
| 41 | |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 42 | Gerrit requires all changes to have a `Change-Id` tag at the bottom of each CL. |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 43 | You should set this up to be done automatically using the instructions below. |
| 44 | |
| 45 | **Linux/macOS**<br/> |
| 46 | ```bash |
| 47 | $ f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f |
| 48 | ``` |
| 49 | |
| 50 | **Windows**<br/> |
| 51 | Download [the Gerrit commit hook](https://gerrit-review.googlesource.com/tools/hooks/commit-msg) |
| 52 | and then copy it to the `.git\hooks` directory in the Pigweed repository. |
| 53 | ```batch |
| 54 | copy %HOMEPATH%\Downloads\commit-msg %HOMEPATH%\pigweed\.git\hooks\commit-msg |
| 55 | ``` |
| 56 | |
| 57 | ## Code Reviews |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 58 | |
| 59 | All Pigweed development happens on Gerrit, following the [typical Gerrit |
| 60 | development workflow](http://ceres-solver.org/contributing.html). |
| 61 | |
| 62 | In the future we may support GitHub pull requests, but until that time we will |
| 63 | close GitHub pull requests and ask that the changes be uploaded to Gerrit |
| 64 | instead. |
| 65 | |
| 66 | ## Community Guidelines |
| 67 | |
| 68 | This project follows [Google's Open Source Community |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 69 | Guidelines](https://opensource.google/conduct/) and the [Pigweed Code of |
| 70 | Conduct](CODE_OF_CONDUCT.md). |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 71 | |
| 72 | ## Source Code Headers |
| 73 | |
| 74 | Every Pigweed file containing source code must include copyright and license |
| 75 | information. This includes any JS/CSS files that you might be serving out to |
| 76 | browsers. |
| 77 | |
| 78 | Apache header for C and C++ files: |
| 79 | |
| 80 | ```javascript |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 81 | // Copyright 2020 The Pigweed Authors |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 82 | // |
| 83 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 84 | // use this file except in compliance with the License. You may obtain a copy of |
| 85 | // the License at |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 86 | // |
| 87 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 88 | // |
| 89 | // Unless required by applicable law or agreed to in writing, software |
| 90 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 91 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 92 | // License for the specific language governing permissions and limitations under |
| 93 | // the License. |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 94 | ``` |
| 95 | |
| 96 | Apache header for Python and GN files: |
| 97 | |
| 98 | ```python |
Keir Mierle | 086ef1c | 2020-03-19 02:03:51 -0700 | [diff] [blame] | 99 | # Copyright 2020 The Pigweed Authors |
Keir Mierle | 5d1226f | 2019-10-31 12:23:43 -0700 | [diff] [blame] | 100 | # |
| 101 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 102 | # use this file except in compliance with the License. You may obtain a copy of |
| 103 | # the License at |
| 104 | # |
| 105 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 106 | # |
| 107 | # Unless required by applicable law or agreed to in writing, software |
| 108 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 109 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 110 | # License for the specific language governing permissions and limitations under |
| 111 | # the License. |
| 112 | ``` |
Armando Montanez | 7b7a32f | 2020-03-18 11:02:41 -0700 | [diff] [blame] | 113 | |
| 114 | ## Continuous Integration |
| 115 | |
| 116 | All Pigweed CLs must adhere to Pigweed's style guide and pass a suite of |
| 117 | automated builds, tests, and style checks to be merged upstream. Much of this |
| 118 | checking is done using Pigweed's pw_presubmit module by automated builders. To |
| 119 | speed up the review process, consider adding `pw presubmit` as a git push hook |
| 120 | using the following command: |
| 121 | |
| 122 | **Linux/macOS**<br/> |
| 123 | ```bash |
| 124 | $ pw presubmit --install |
| 125 | ``` |
| 126 | |
| 127 | This will be effectively the same as running the following command before every |
| 128 | `git push`: |
| 129 | ```bash |
| 130 | $ pw presubmit --program quick |
| 131 | ``` |
| 132 | |
| 133 |  |
| 134 | |
| 135 | Running `pw presubmit` manually will default to running the `full` presubmit |
| 136 | program. |
| 137 | |
| 138 | If you ever need to bypass the presubmit hook (due to it being broken, for example) you |
| 139 | may push using this command: |
| 140 | |
| 141 | ```bash |
| 142 | $ git push origin HEAD:refs/for/master --no-verify |
| 143 | ``` |