1*4a64e381SAndroid Build Coastguard Worker# Contributing to OpenThread 2*4a64e381SAndroid Build Coastguard Worker 3*4a64e381SAndroid Build Coastguard WorkerWe would love for you to contribute to OpenThread and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow. 4*4a64e381SAndroid Build Coastguard Worker 5*4a64e381SAndroid Build Coastguard Worker- [1 Code of Conduct](#code-of-conduct) 6*4a64e381SAndroid Build Coastguard Worker- [2 Bugs](#bugs) 7*4a64e381SAndroid Build Coastguard Worker- [3 New Features](#new-features) 8*4a64e381SAndroid Build Coastguard Worker- [4 Contributing Code](#contributing-code) 9*4a64e381SAndroid Build Coastguard Worker - [4.1 Initial Setup](#initial-setup) 10*4a64e381SAndroid Build Coastguard Worker - [4.2 Contributor License Agreement (CLA)](#contributor-license-agreement--cla-) 11*4a64e381SAndroid Build Coastguard Worker - [4.3 Submitting a Pull Request](#submitting-a-pull-request) 12*4a64e381SAndroid Build Coastguard Worker- [5 Contributing Documentation](#contributing-documentation) 13*4a64e381SAndroid Build Coastguard Worker 14*4a64e381SAndroid Build Coastguard Worker## Code of Conduct 15*4a64e381SAndroid Build Coastguard Worker 16*4a64e381SAndroid Build Coastguard WorkerHelp us keep OpenThread open and inclusive. Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). 17*4a64e381SAndroid Build Coastguard Worker 18*4a64e381SAndroid Build Coastguard Worker## Bugs 19*4a64e381SAndroid Build Coastguard Worker 20*4a64e381SAndroid Build Coastguard WorkerIf you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/openthread/ot-br-posix/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. 21*4a64e381SAndroid Build Coastguard Worker 22*4a64e381SAndroid Build Coastguard Worker## New Features 23*4a64e381SAndroid Build Coastguard Worker 24*4a64e381SAndroid Build Coastguard WorkerYou can request a new feature by [submitting a GitHub Issue](https://github.com/openthread/ot-br-posix/issues/new). 25*4a64e381SAndroid Build Coastguard Worker 26*4a64e381SAndroid Build Coastguard WorkerIf you would like to implement a new feature, please consider the scope of the new feature: 27*4a64e381SAndroid Build Coastguard Worker 28*4a64e381SAndroid Build Coastguard Worker- _Large feature_: first [submit a GitHub Issue](https://github.com/openthread/ot-br-posix/issues/new) and communicate your proposal so that the community can review and provide feedback. Getting early feedback will help ensure your implementation work is accepted by the community. This will also allow us to better coordinate our efforts and minimize duplicated effort. 29*4a64e381SAndroid Build Coastguard Worker 30*4a64e381SAndroid Build Coastguard Worker- _Small feature_: can be implemented and directly [submitted as a Pull Request](#submitting-a-pull-request). 31*4a64e381SAndroid Build Coastguard Worker 32*4a64e381SAndroid Build Coastguard Worker## Contributing Code 33*4a64e381SAndroid Build Coastguard Worker 34*4a64e381SAndroid Build Coastguard WorkerThe OpenThread Project follows the "Fork-and-Pull" model for accepting contributions. 35*4a64e381SAndroid Build Coastguard Worker 36*4a64e381SAndroid Build Coastguard Worker### Initial Setup 37*4a64e381SAndroid Build Coastguard Worker 38*4a64e381SAndroid Build Coastguard WorkerSetup your GitHub fork and continuous-integration services: 39*4a64e381SAndroid Build Coastguard Worker 40*4a64e381SAndroid Build Coastguard Worker1. Fork the [OpenThread repository](https://github.com/openthread/ot-br-posix) by clicking "Fork" on the web UI. 41*4a64e381SAndroid Build Coastguard Worker 42*4a64e381SAndroid Build Coastguard WorkerSetup your local development environment: 43*4a64e381SAndroid Build Coastguard Worker 44*4a64e381SAndroid Build Coastguard Worker```bash 45*4a64e381SAndroid Build Coastguard Worker# Clone your fork 46*4a64e381SAndroid Build Coastguard Workergit clone [email protected]:<username>/openthread.git 47*4a64e381SAndroid Build Coastguard Worker 48*4a64e381SAndroid Build Coastguard Worker# Configure upstream alias 49*4a64e381SAndroid Build Coastguard Workergit remote add upstream [email protected]:openthread/ot-br-posix.git 50*4a64e381SAndroid Build Coastguard Worker``` 51*4a64e381SAndroid Build Coastguard Worker 52*4a64e381SAndroid Build Coastguard Worker### Contributor License Agreement (CLA) 53*4a64e381SAndroid Build Coastguard Worker 54*4a64e381SAndroid Build Coastguard WorkerContributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to <https://cla.developers.google.com/> to see your current agreements on file or to sign a new one. 55*4a64e381SAndroid Build Coastguard Worker 56*4a64e381SAndroid Build Coastguard WorkerYou generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. 57*4a64e381SAndroid Build Coastguard Worker 58*4a64e381SAndroid Build Coastguard Worker### Submitting a Pull Request 59*4a64e381SAndroid Build Coastguard Worker 60*4a64e381SAndroid Build Coastguard Worker#### Branch 61*4a64e381SAndroid Build Coastguard Worker 62*4a64e381SAndroid Build Coastguard WorkerFor each new feature, create a working branch: 63*4a64e381SAndroid Build Coastguard Worker 64*4a64e381SAndroid Build Coastguard Worker```bash 65*4a64e381SAndroid Build Coastguard Worker# Create a working branch for your new feature 66*4a64e381SAndroid Build Coastguard Workergit branch --track <branch-name> origin/main 67*4a64e381SAndroid Build Coastguard Worker 68*4a64e381SAndroid Build Coastguard Worker# Checkout the branch 69*4a64e381SAndroid Build Coastguard Workergit checkout <branch-name> 70*4a64e381SAndroid Build Coastguard Worker``` 71*4a64e381SAndroid Build Coastguard Worker 72*4a64e381SAndroid Build Coastguard Worker#### Create Commits 73*4a64e381SAndroid Build Coastguard Worker 74*4a64e381SAndroid Build Coastguard Worker```bash 75*4a64e381SAndroid Build Coastguard Worker# Add each modified file you'd like to include in the commit 76*4a64e381SAndroid Build Coastguard Workergit add <file1> <file2> 77*4a64e381SAndroid Build Coastguard Worker 78*4a64e381SAndroid Build Coastguard Worker# Create a commit 79*4a64e381SAndroid Build Coastguard Workergit commit 80*4a64e381SAndroid Build Coastguard Worker``` 81*4a64e381SAndroid Build Coastguard Worker 82*4a64e381SAndroid Build Coastguard WorkerThis will open up a text editor where you can craft your commit message. 83*4a64e381SAndroid Build Coastguard Worker 84*4a64e381SAndroid Build Coastguard Worker#### Upstream Sync and Clean Up 85*4a64e381SAndroid Build Coastguard Worker 86*4a64e381SAndroid Build Coastguard WorkerPrior to submitting your pull request, you might want to do a few things to clean up your branch and make it as simple as possible for the original repo's maintainer to test, accept, and merge your work. 87*4a64e381SAndroid Build Coastguard Worker 88*4a64e381SAndroid Build Coastguard WorkerIf any commits have been made to the upstream main branch, you should rebase your development branch so that merging it will be a simple fast-forward that won't require any conflict resolution work. 89*4a64e381SAndroid Build Coastguard Worker 90*4a64e381SAndroid Build Coastguard Worker```bash 91*4a64e381SAndroid Build Coastguard Worker# Fetch upstream main and merge with your repo's main branch 92*4a64e381SAndroid Build Coastguard Workergit checkout main 93*4a64e381SAndroid Build Coastguard Workergit pull upstream main 94*4a64e381SAndroid Build Coastguard Worker 95*4a64e381SAndroid Build Coastguard Worker# If there were any new commits, rebase your development branch 96*4a64e381SAndroid Build Coastguard Workergit checkout <branch-name> 97*4a64e381SAndroid Build Coastguard Workergit rebase main 98*4a64e381SAndroid Build Coastguard Worker``` 99*4a64e381SAndroid Build Coastguard Worker 100*4a64e381SAndroid Build Coastguard WorkerNow, it may be desirable to squash some of your smaller commits down into a small number of larger more cohesive commits. You can do this with an interactive rebase: 101*4a64e381SAndroid Build Coastguard Worker 102*4a64e381SAndroid Build Coastguard Worker```bash 103*4a64e381SAndroid Build Coastguard Worker# Rebase all commits on your development branch 104*4a64e381SAndroid Build Coastguard Workergit checkout 105*4a64e381SAndroid Build Coastguard Workergit rebase -i main 106*4a64e381SAndroid Build Coastguard Worker``` 107*4a64e381SAndroid Build Coastguard Worker 108*4a64e381SAndroid Build Coastguard WorkerThis will open up a text editor where you can specify which commits to squash. 109*4a64e381SAndroid Build Coastguard Worker 110*4a64e381SAndroid Build Coastguard Worker#### Coding Conventions and Style 111*4a64e381SAndroid Build Coastguard Worker 112*4a64e381SAndroid Build Coastguard WorkerOpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v14.0.0](https://releases.llvm.org/download.html#14.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python. 113*4a64e381SAndroid Build Coastguard Worker 114*4a64e381SAndroid Build Coastguard WorkerAs part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks. 115*4a64e381SAndroid Build Coastguard Worker 116*4a64e381SAndroid Build Coastguard Worker#### Push and Test 117*4a64e381SAndroid Build Coastguard Worker 118*4a64e381SAndroid Build Coastguard Worker```bash 119*4a64e381SAndroid Build Coastguard Worker# Checkout your branch 120*4a64e381SAndroid Build Coastguard Workergit checkout <branch-name> 121*4a64e381SAndroid Build Coastguard Worker 122*4a64e381SAndroid Build Coastguard Worker# Push to your GitHub fork: 123*4a64e381SAndroid Build Coastguard Workergit push origin <branch-name> 124*4a64e381SAndroid Build Coastguard Worker``` 125*4a64e381SAndroid Build Coastguard Worker 126*4a64e381SAndroid Build Coastguard WorkerThis will trigger continuous-integration checks using GitHub Actions. You can view the status and logs via the "Actions" tab in your fork. 127*4a64e381SAndroid Build Coastguard Worker 128*4a64e381SAndroid Build Coastguard Worker#### Submit Pull Request 129*4a64e381SAndroid Build Coastguard Worker 130*4a64e381SAndroid Build Coastguard WorkerOnce you've validated that all continuous-integration checks have passed, go to the page for your fork on GitHub, select your development branch, and click the pull request button. If you need to make any adjustments to your pull request, just push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update. 131*4a64e381SAndroid Build Coastguard Worker 132*4a64e381SAndroid Build Coastguard Worker#### Checks fail 133*4a64e381SAndroid Build Coastguard Worker 134*4a64e381SAndroid Build Coastguard WorkerOnce you've submitted a pull request, all continuous-integration checks are triggered again. If some of these checks fail, it could be either problems with the pull request or an intermittent failure of some test cases. For more information on the failure, check the output and download artifacts. (After all jobs in one group are completed, an `Artifacts` button appears beside the `Re-run` jobs button.) If the failure is intermittent, the check will usually pass after rerunning once or twice. 135*4a64e381SAndroid Build Coastguard Worker 136*4a64e381SAndroid Build Coastguard WorkerWe want to eliminate intermittent failures as well, so when you experience such a failure, please log an issue and attach any relevant artifacts. If the artifacts are too big, provide the link of the failed run (do not rerun checks again, or it will be overwritten). Alternatively, upload the artifacts to a file-sharing service like Google Drive and share a link to it. 137*4a64e381SAndroid Build Coastguard Worker 138*4a64e381SAndroid Build Coastguard Worker## Contributing Documentation 139*4a64e381SAndroid Build Coastguard Worker 140*4a64e381SAndroid Build Coastguard WorkerDocumentation undergoes the same review process as code and contributions may be mirrored on our [openthread.io](https://openthread.io) website. 141*4a64e381SAndroid Build Coastguard Worker 142*4a64e381SAndroid Build Coastguard Worker### Codelabs and Guides 143*4a64e381SAndroid Build Coastguard Worker 144*4a64e381SAndroid Build Coastguard WorkerTo review and contribute to OpenThread Codelabs and Guides, refer to the following GitHub repositories: 145*4a64e381SAndroid Build Coastguard Worker 146*4a64e381SAndroid Build Coastguard Worker- [Codelabs](https://github.com/openthread/ot-docs/tree/main/site/en/codelabs) 147*4a64e381SAndroid Build Coastguard Worker- [Guides](https://github.com/openthread/ot-docs/tree/main/site/en/guides) 148*4a64e381SAndroid Build Coastguard Worker 149*4a64e381SAndroid Build Coastguard WorkerFor information on how to author and format documentation for contribution, refer to the [Documentation Style Guide](https://github.com/openthread/ot-docs/blob/main/STYLE_GUIDE.md). 150*4a64e381SAndroid Build Coastguard Worker 151*4a64e381SAndroid Build Coastguard Worker### API Reference topics 152*4a64e381SAndroid Build Coastguard Worker 153*4a64e381SAndroid Build Coastguard WorkerAPI Reference topics use [Doxygen comment blocks](https://www.doxygen.nl/manual/docblocks.html) to render the HTML output on [https://openthread.io/reference](https://openthread.io/reference). OpenThread scripts support the following Doxygen [special commands](https://www.doxygen.nl/manual/commands.html): 154*4a64e381SAndroid Build Coastguard Worker 155*4a64e381SAndroid Build Coastguard Worker- @file 156*4a64e381SAndroid Build Coastguard Worker- @brief 157*4a64e381SAndroid Build Coastguard Worker- @param 158*4a64e381SAndroid Build Coastguard Worker- @returns 159*4a64e381SAndroid Build Coastguard Worker 160*4a64e381SAndroid Build Coastguard WorkerYou can find most of these comments in the [OpenThread header files](https://github.com/openthread/openthread/tree/main/include/openthread). To review an example, refer to [`border_agent.h`](https://github.com/openthread/openthread/tree/main/include/openthread/border_agent.h). The Doxygen comments in `border_agent.h` output the [Border Agent](https://openthread.io/reference/group/api-border-agent) reference topic on openthread.io. For more information, refer to [Comments](https://github.com/openthread/openthread/blob/main/STYLE_GUIDE.md#comments) in the OpenThread Coding Conventions and Style guide. 161