clapre | 0a06d85 | 2021-05-28 17:11:00 -0400 | [diff] [blame] | 1 | # Contributing to Matter (formerly Project CHIP) |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 2 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 3 | Want to contribute? Great! First, read this page (including the small print at |
| 4 | the end). By submitting a pull request, you represent that you have the right to |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 5 | license your contribution to the Connectivity Standards Alliance and the |
| 6 | community, and agree by submitting the patch that your contributions are |
| 7 | licensed under the [Apache 2.0 license](./LICENSE). Before submitting the pull |
| 8 | request, please make sure you have tested your changes and that they follow the |
| 9 | project guidelines for contributing code. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 10 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 11 | # Contributing as an Open Source Contributor |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 12 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 13 | As an open source contributor you can report bugs and request features in the |
| 14 | [Issue Tracker](https://github.com/project-chip/connectedhomeip/issues), as well |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 15 | as contribute bug fixes and features that do not impact Matter specification as |
| 16 | a pull request. For example: ports of Matter to add APIs to alternative |
| 17 | programming languages (e.g. Java, JS), hardware ports, or an optimized |
| 18 | implementation of existing functionality. For features that impact the |
| 19 | specification, please join Matter work group within the Connectivity Standards |
| 20 | Alliance. The requirements to become an open source contributor of the |
| 21 | [Matter Repository](https://github.com/project-chip/connectedhomeip) are: |
Justin Wood | 2eb7487 | 2020-03-03 15:36:27 -0800 | [diff] [blame] | 22 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 23 | - Agree to the [Code of Conduct](./CODE_OF_CONDUCT.md) |
| 24 | - Agree to the [License](./LICENSE) |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 25 | - Have signed the |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 26 | [Matter Working Group CLA](https://gist.github.com/clapre/65aa9fc63981da765039e0bb7e8701be) |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 27 | |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 28 | # Contributing as a Connectivity Standards Alliance Matter Working Group Member |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 29 | |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 30 | As a participant of the Connectivity Standards Alliance Matter Working Group, |
| 31 | you can attend Working Group meetings, propose changes to the Matter |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 32 | specification, and contribute code for approved updates to the specification. |
| 33 | The requirements to become a member of the |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 34 | [Matter Repository](https://github.com/project-chip/connectedhomeip) are: |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 35 | |
| 36 | - Must be a [Participant member](http://www.zigbeealliance.org/join) or higher |
clapre | 0a06d85 | 2021-05-28 17:11:00 -0400 | [diff] [blame] | 37 | of the Connectivity Standards Alliance |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 38 | - Must be a Matter Working Group member |
| 39 | - Have signed the Alliance Matter Working Group CLA |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 40 | - Have approval from your company's official approver |
Justin Wood | 2eb7487 | 2020-03-03 15:36:27 -0800 | [diff] [blame] | 41 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 42 | # Bugs |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 43 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 44 | If you find a bug in the source code, you can help us by |
| 45 | [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). |
| 46 | The best bug reports provide a detailed description of the issue and |
| 47 | step-by-step instructions for predictably reproducing the issue. Even better, |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 48 | you can |
| 49 | [submit a Pull Request](https://github.com/project-chip/connectedhomeip/blob/master/CONTRIBUTING.md#submitting-a-pull-request) |
| 50 | with a fix. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 51 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 52 | # New Features |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 53 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 54 | You can request a new feature by |
| 55 | [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 56 | If you would like to implement a new feature, please consider the scope of the |
| 57 | new feature: |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 58 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 59 | - _Large feature_: first |
| 60 | [submit a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new) |
| 61 | and communicate your proposal so that the community can review and provide |
| 62 | feedback. Getting early feedback will help ensure your implementation work |
| 63 | is accepted by the community. This will also allow us to better coordinate |
| 64 | our efforts and minimize duplicated effort. |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 65 | - _Small feature_: can be implemented and directly |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 66 | [submitted as a Pull Request](https://github.com/project-chip/connectedhomeip/blob/master/CONTRIBUTING.md#submitting-a-pull-request). |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 67 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 68 | # Contributing Code |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 69 | |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 70 | Matter follows the "Fork-and-Pull" model for accepting contributions. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 71 | |
| 72 | ### Initial Setup |
| 73 | |
| 74 | Setup your GitHub fork and continuous-integration services: |
| 75 | |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 76 | 1. Fork the [Matter repository](https://github.com/project-chip/connectedhomeip) |
| 77 | by clicking "Fork" on the web UI. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 78 | |
| 79 | 2. All contributions must pass all checks and reviews to be accepted. |
| 80 | |
| 81 | Setup your local development environment: |
| 82 | |
| 83 | ```bash |
| 84 | # Clone your fork |
| 85 | git clone git@github.com:<username>/connectedhomeip.git |
| 86 | |
| 87 | # Configure upstream alias |
| 88 | git remote add upstream git@github.com:project-chip/connectedhomeip.git |
| 89 | ``` |
| 90 | |
| 91 | ### Submitting a Pull Request |
| 92 | |
| 93 | #### Branch |
| 94 | |
| 95 | For each new feature, create a working branch: |
| 96 | |
| 97 | ```bash |
| 98 | # Create a working branch for your new feature |
| 99 | git branch --track <branch-name> origin/master |
| 100 | |
| 101 | # Checkout the branch |
| 102 | git checkout <branch-name> |
| 103 | ``` |
| 104 | |
| 105 | #### Create Commits |
| 106 | |
| 107 | ```bash |
| 108 | # Add each modified file you'd like to include in the commit |
| 109 | git add <file1> <file2> |
| 110 | |
| 111 | # Create a commit |
| 112 | git commit |
| 113 | ``` |
| 114 | |
| 115 | This will open up a text editor where you can craft your commit message. |
| 116 | |
| 117 | #### Upstream Sync and Clean Up |
| 118 | |
| 119 | Prior to submitting your pull request, you might want to do a few things to |
| 120 | clean up your branch and make it as simple as possible for the original |
| 121 | repository's maintainer to test, accept, and merge your work. |
| 122 | |
| 123 | If any commits have been made to the upstream master branch, you should rebase |
| 124 | your development branch so that merging it will be a simple fast-forward that |
| 125 | won't require any conflict resolution work. |
| 126 | |
| 127 | ```bash |
| 128 | # Fetch upstream master and merge with your repository's master branch |
| 129 | git checkout master |
| 130 | git pull upstream master |
| 131 | |
| 132 | # If there were any new commits, rebase your development branch |
| 133 | git checkout <branch-name> |
| 134 | git rebase master |
| 135 | ``` |
| 136 | |
| 137 | Now, it may be desirable to squash some of your smaller commits down into a |
| 138 | small number of larger more cohesive commits. You can do this with an |
| 139 | interactive rebase: |
| 140 | |
| 141 | ```bash |
| 142 | # Rebase all commits on your development branch |
Matt Smith | e9d068f | 2021-06-17 02:21:03 +0800 | [diff] [blame] | 143 | git checkout <branch-name> |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 144 | git rebase -i master |
| 145 | ``` |
| 146 | |
| 147 | This will open up a text editor where you can specify which commits to squash. |
| 148 | |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 149 | #### Push and Test |
| 150 | |
| 151 | ```bash |
| 152 | # Checkout your branch |
| 153 | git checkout <branch-name> |
| 154 | |
| 155 | # Push to your GitHub fork: |
| 156 | git push origin <branch-name> |
| 157 | ``` |
| 158 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 159 | This will trigger the continuous-integration checks. You can view the results in |
| 160 | the respective services. Note that the integration checks will report failures |
| 161 | on occasion. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 162 | |
Justin Wood | 7b11651 | 2020-03-03 16:13:59 -0800 | [diff] [blame] | 163 | ### Review Requirements |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 164 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 165 | #### Documentation Best Practices |
Justin Wood | 7b11651 | 2020-03-03 16:13:59 -0800 | [diff] [blame] | 166 | |
Grzegorz Ferenc | bae3e7d | 2021-10-19 15:49:45 +0200 | [diff] [blame] | 167 | Matter uses Doxygen to markup (or markdown) all C, C++, Objective C, Objective |
| 168 | C++, Perl, Python, and Java code. Read our |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 169 | [Doxygen Best Practices, Conventions, and Style](https://github.com/project-chip/connectedhomeip/blob/master/docs/style/DOXYGEN.adoc) |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 170 | |
| 171 | #### Submit Pull Request |
| 172 | |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 173 | Once you've validated the CI results, go to the page for your fork on GitHub, |
| 174 | select your development branch, and click the pull request button. If you need |
| 175 | to make any adjustments to your pull request, just push the updates to GitHub. |
| 176 | Your pull request will automatically track the changes on your development |
| 177 | branch and update. |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 178 | |
Justin Wood | 95174b4 | 2020-03-03 15:58:18 -0800 | [diff] [blame] | 179 | #### Merge Requirements |
| 180 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 181 | - Github Workflows pass |
| 182 | - Builds pass |
| 183 | - Tests pass |
Justin Wood | 0a9545e | 2020-04-20 18:15:21 -0700 | [diff] [blame] | 184 | - Linting passes |
| 185 | - Code style passes |
Justin Wood | 95174b4 | 2020-03-03 15:58:18 -0800 | [diff] [blame] | 186 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 187 | When can I merge? After these have been satisfied, a reviewer will merge the PR |
| 188 | into master |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 189 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 190 | #### Documentation |
Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame] | 191 | |
Justin Wood | d4a0615 | 2020-07-01 08:58:02 -0700 | [diff] [blame] | 192 | Documentation undergoes the same review process as code See the |
| 193 | [Documentation Style Guide](https://github.com/project-chip/connectedhomeip/blob/master/docs/STYLE_GUIDE.md) |
| 194 | for more information on how to author and format documentation for contribution. |
Justin Wood | 8839e4c | 2021-10-22 17:27:05 -0700 | [diff] [blame] | 195 | |
| 196 | ## Merge Processes |
| 197 | |
| 198 | Merges require at least 3 approvals from unique require-reviewers lists, and all |
| 199 | CI tests passing. |
| 200 | |
| 201 | ### Shorter Reviews |
| 202 | |
| 203 | Development Lead & Vice Leads can merge a change with fewer then the required |
| 204 | approvals have been submitted. |
| 205 | |
| 206 | A separate "fast track" label will be created that will only require a single |
| 207 | checkbox to be set, this label shall only be set by the Development Lead, and/or |
| 208 | Vice Lead (unless they’re both unavailable, in which case a replacement can be |
| 209 | temporarily appointed) |
| 210 | |
| 211 | "Day" here means "business day" (i.e. PRs on friday do not get fast-tracked |
| 212 | faster). |
| 213 | |
| 214 | ### Fast track types |
| 215 | |
| 216 | ### Trivial changes |
| 217 | |
| 218 | Small changes or changes that do not affect the main functionality of the code |
| 219 | can be fast tracked immediately. Examples: |
| 220 | |
| 221 | - Adding/removing documentation (.md files) |
| 222 | - Adding tests (may include small reorganization/method adding/changes to |
| 223 | enable testability): |
| 224 | - certification tests |
| 225 | - stability tests |
| 226 | - integration tests |
| 227 | - functional tests |
| 228 | - Test scripts |
| 229 | - Additional tests following a pattern (e.g. YAML tests) |
| 230 | - Adding/updating/fixing tooling to aid in development |
| 231 | - Re-running code generation |
| 232 | - Code readability refactors: |
| 233 | - renaming enum/classes/structure members |
| 234 | - moving constant header location |
| 235 | - Obviously trivial build rule changes (e.g. adding missing files to build |
| 236 | rules) |
| 237 | - Changing comments |
| 238 | - Adding/removing includes (include what you need and only what you need |
| 239 | rules) |
| 240 | - Pulling new third-party repo files |
| 241 | - Platform vendors/maintainers adding platform features/logic/bug fixes to |
| 242 | their own platforms |
| 243 | - Most changes to existing docker files (pulling new versions, reorganizing) |
| 244 | - Most changes to new dockerfile version in workflows |
| 245 | |
| 246 | #### Fast track changes |
| 247 | |
| 248 | Larger functionality changes are allowed to be fast tracked with these |
| 249 | requirements/restrictions: |
| 250 | |
| 251 | - Require at least 1 day to have passed since the creation of the PR |
| 252 | - Require at least 1 checkmark from someone familiar with the code or problem |
| 253 | space |
| 254 | - This requirement shall be dropped after a PR is 3 days old with stale or |
| 255 | no feedback. |
| 256 | - Code is sufficiently covered by automated tests (or impossible to |
| 257 | automatically test with a very solid reason for this - e.g. changes to BLE |
| 258 | parameters cannot be automatically tested, but should have been manually |
| 259 | verified) |
| 260 | |
| 261 | Fast tracking these changes will involve resolving any obviously 'resolved' |
| 262 | comments (judgment call here: were they replied to or addressed) and merging the |
| 263 | change. |
| 264 | |
| 265 | Any "request for changes" marker will always be respected unless obviously |
| 266 | resolved (i.e. author marked "requesting changes because of X and X was done in |
| 267 | the PR") |
| 268 | |
| 269 | - This requirement shall be dropped after a PR is 3 days old with stale or no |
| 270 | feedback. |