Justin Wood | c9bbb25 | 2020-03-03 10:03:58 -0800 | [diff] [blame^] | 1 | Contributing to CHIP |
| 2 | ======================== |
| 3 | |
| 4 | Want to contribute? Great! First, read this page (including the small |
| 5 | print at the end). |
| 6 | By submitting a pull request, you represent that you have the right to license your contribution to Zigbee and the |
| 7 | community, and agree by submitting the patch that your contributions are licensed under the |
| 8 | [Apache 2.0 license](./LICENSE.md). |
| 9 | |
| 10 | Before submitting the pull request, please make sure you have tested your changes and that they follow the project |
| 11 | [guidelines for contributing code](./docs/contribution_guidelines.md). |
| 12 | |
| 13 | |
| 14 | ## Bugs |
| 15 | |
| 16 | If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). The best bug reports provide a detailed description of the issue and step-by-step instructions for predictably reproducing the issue. Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix. |
| 17 | |
| 18 | ## New Features |
| 19 | |
| 20 | You can request a new feature by [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). |
| 21 | |
| 22 | If you would like to implement a new feature, please consider the scope of the new feature: |
| 23 | |
| 24 | * *Large feature*: first [submit a GitHub |
| 25 | Issue](https://github.com/project-chip/connectedhomeip/issues/new) and communicate |
| 26 | your proposal so that the community can review and provide feedback. Getting |
| 27 | early feedback will help ensure your implementation work is accepted by the |
| 28 | community. This will also allow us to better coordinate our efforts and |
| 29 | minimize duplicated effort. |
| 30 | |
| 31 | * *Small feature*: can be implemented and directly [submitted as a Pull |
| 32 | Request](#submitting-a-pull-request). |
| 33 | |
| 34 | ## Contributing Code |
| 35 | |
| 36 | CHIP follows the "Fork-and-Pull" model for accepting contributions. |
| 37 | |
| 38 | ### Initial Setup |
| 39 | |
| 40 | Setup your GitHub fork and continuous-integration services: |
| 41 | |
| 42 | 1. Fork the [CHIP |
| 43 | repository](https://github.com/project-chip/connectedhomeip) by clicking "Fork" |
| 44 | on the web UI. |
| 45 | |
| 46 | 2. All contributions must pass all checks and reviews to be accepted. |
| 47 | |
| 48 | Setup your local development environment: |
| 49 | |
| 50 | ```bash |
| 51 | # Clone your fork |
| 52 | git clone git@github.com:<username>/connectedhomeip.git |
| 53 | |
| 54 | # Configure upstream alias |
| 55 | git remote add upstream git@github.com:project-chip/connectedhomeip.git |
| 56 | ``` |
| 57 | |
| 58 | ### Submitting a Pull Request |
| 59 | |
| 60 | #### Branch |
| 61 | |
| 62 | For each new feature, create a working branch: |
| 63 | |
| 64 | ```bash |
| 65 | # Create a working branch for your new feature |
| 66 | git branch --track <branch-name> origin/master |
| 67 | |
| 68 | # Checkout the branch |
| 69 | git checkout <branch-name> |
| 70 | ``` |
| 71 | |
| 72 | #### Create Commits |
| 73 | |
| 74 | ```bash |
| 75 | # Add each modified file you'd like to include in the commit |
| 76 | git add <file1> <file2> |
| 77 | |
| 78 | # Create a commit |
| 79 | git commit |
| 80 | ``` |
| 81 | |
| 82 | This will open up a text editor where you can craft your commit message. |
| 83 | |
| 84 | #### Upstream Sync and Clean Up |
| 85 | |
| 86 | Prior to submitting your pull request, you might want to do a few things to |
| 87 | clean up your branch and make it as simple as possible for the original |
| 88 | repository's maintainer to test, accept, and merge your work. |
| 89 | |
| 90 | If any commits have been made to the upstream master branch, you should rebase |
| 91 | your development branch so that merging it will be a simple fast-forward that |
| 92 | won't require any conflict resolution work. |
| 93 | |
| 94 | ```bash |
| 95 | # Fetch upstream master and merge with your repository's master branch |
| 96 | git checkout master |
| 97 | git pull upstream master |
| 98 | |
| 99 | # If there were any new commits, rebase your development branch |
| 100 | git checkout <branch-name> |
| 101 | git rebase master |
| 102 | ``` |
| 103 | |
| 104 | Now, it may be desirable to squash some of your smaller commits down into a |
| 105 | small number of larger more cohesive commits. You can do this with an |
| 106 | interactive rebase: |
| 107 | |
| 108 | ```bash |
| 109 | # Rebase all commits on your development branch |
| 110 | git checkout |
| 111 | git rebase -i master |
| 112 | ``` |
| 113 | |
| 114 | This will open up a text editor where you can specify which commits to squash. |
| 115 | |
| 116 | |
| 117 | #### Push and Test |
| 118 | |
| 119 | ```bash |
| 120 | # Checkout your branch |
| 121 | git checkout <branch-name> |
| 122 | |
| 123 | # Push to your GitHub fork: |
| 124 | git push origin <branch-name> |
| 125 | ``` |
| 126 | |
| 127 | This will trigger the continuous-integration checks. You |
| 128 | can view the results in the respective services. Note that the integration |
| 129 | checks will report failures on occasion. |
| 130 | |
| 131 | #### Pull Request Requirements |
| 132 | |
| 133 | CHIP considers there to be a few different types of pull requests: |
| 134 | - Trivial bug fix |
| 135 | - - Decription 1 |
| 136 | - - Decription 2 |
| 137 | - Small Bug fix |
| 138 | - - Decription 1 |
| 139 | - - Decription 2 |
| 140 | - Bug Fix |
| 141 | - - Decription 1 |
| 142 | - - Decription 2 |
| 143 | - Significiant Change |
| 144 | - - Decription 1 |
| 145 | - - Decription 2 |
| 146 | - Feature |
| 147 | - - Decription 1 |
| 148 | - - Decription 2 |
| 149 | - Architecture Change |
| 150 | - - Decription 1 |
| 151 | - - Decription 2 |
| 152 | |
| 153 | ### Prior to review, all changes require: |
| 154 | - [GitHub Workflows](../.github/workflows) pass |
| 155 | - [Certification Tests](tests/certification/README.md) pass |
| 156 | - [Unit Tests](tests/unit/README.md) pass |
| 157 | - [Fuzz Tests](tests/fuzz/README.md) pass |
| 158 | - [Integration Tests](tests/integration/README.md) pass |
| 159 | - Linting passes |
| 160 | - Code style passes |
| 161 | |
| 162 | Each type of change has unique additional requirements, here's a table of those: |
| 163 | | Type | Reviewer Requirements | New Unit Tests | New Certification Tests | New Fuzz Tests | New Integration Tests | |
| 164 | |----|----|----|----|----|----| |
| 165 | | Trivial bug fix | | | | | | |
| 166 | | Small Bug fix | | | | | | | |
| 167 | | Bug Fix | | | | | | | |
| 168 | | Significiant Change | | | | | | | |
| 169 | | Feature | | | | | | | |
| 170 | | Architecture Change | | | | | | | |
| 171 | |
| 172 | |
| 173 | |
| 174 | #### Submit Pull Request |
| 175 | |
| 176 | Once you've validated the CI results, go to the page for |
| 177 | your fork on GitHub, select your development branch, and click the pull request |
| 178 | button. If you need to make any adjustments to your pull request, just push the |
| 179 | updates to GitHub. Your pull request will automatically track the changes on |
| 180 | your development branch and update. |
| 181 | |
| 182 | #### Code reviews |
| 183 | |
| 184 | All submissions, including submissions by project members, require review. |
| 185 | |
| 186 | ### Documentation |
| 187 | |
| 188 | Documentation undergoes the same review process as code |
| 189 | |
| 190 | See the [Documentation Style Guide][doc-style] for more information on |
| 191 | how to author and format documentation for contribution. |
| 192 | |