1# How to contribute 2 3We definitely welcome your patches and contributions to gRPC! 4 5If you are new to github, please start by reading [Pull Request 6howto](https://help.github.com/articles/about-pull-requests/) 7 8## Legal requirements 9 10In order to protect both you and ourselves, you will need to sign the 11[Contributor License 12Agreement](https://identity.linuxfoundation.org/projects/cncf). 13 14## Cloning the repository 15 16Before starting any development work you will need a local copy of the gRPC repository. 17Please follow the instructions in [Building gRPC C++: Clone the repository](BUILDING.md#clone-the-repository-including-submodules). 18 19## Building & Running tests 20 21Different languages use different build systems. To hide the complexity 22of needing to build with many different build systems, a portable python 23script that unifies the experience of building and testing gRPC in different 24languages and on different platforms is provided. 25 26To build gRPC in the language of choice (e.g. `c++`, `csharp`, `php`, `python`, `ruby`, ...) 27- Prepare your development environment based on language-specific instructions in `src/YOUR-LANGUAGE` directory. 28- The language-specific instructions might involve installing C/C++ prerequisites listed in 29 [Building gRPC C++: Prerequisites](BUILDING.md#pre-requisites). This is because gRPC implementations 30 in this repository are using the native gRPC "core" library internally. 31- Run 32 ``` 33 python tools/run_tests/run_tests.py -l YOUR_LANGUAGE --build_only 34 ``` 35- To also run all the unit tests after building 36 ``` 37 python tools/run_tests/run_tests.py -l YOUR_LANGUAGE 38 ``` 39 40You can also run `python tools/run_tests/run_tests.py --help` to discover useful command line flags supported. For more details, 41see [tools/run_tests](tools/run_tests) where you will also find guidance on how to run various other test suites (e.g. interop tests, benchmarks). 42 43## Generated project files 44 45To ease maintenance of language- and platform- specific build systems, many 46projects files are generated using templates and should not be edited by hand. 47Run `tools/buildgen/generate_projects.sh` to regenerate. See 48[templates](templates) for details. 49 50As a rule of thumb, if you see the "sanity tests" failing you've most likely 51edited generated files or you didn't regenerate the projects properly (or your 52code formatting doesn't match our code style). 53 54## Guidelines for Pull Requests 55How to get your contributions merged smoothly and quickly. 56 57- Create **small PRs** that are narrowly focused on **addressing a single 58 concern**. We often times receive PRs that are trying to fix several things 59 at a time, but only one fix is considered acceptable, nothing gets merged and 60 both author's & review's time is wasted. Create more PRs to address different 61 concerns and everyone will be happy. 62 63- For speculative changes, consider opening an issue and discussing it first. 64 If you are suggesting a behavioral or API change, consider starting with a 65 [gRFC proposal](https://github.com/grpc/proposal). 66 67- Provide a good **PR description** as a record of **what** change is being made 68 and **why** it was made. Link to a GitHub issue if it exists. 69 70- Don't fix code style and formatting unless you are already changing that line 71 to address an issue. PRs with irrelevant changes won't be merged. If you do 72 want to fix formatting or style, do that in a separate PR. 73 74- Unless your PR is trivial, you should expect there will be reviewer comments 75 that you'll need to address before merging. We expect you to be reasonably 76 responsive to those comments, otherwise the PR will be closed after 2-3 weeks 77 of inactivity. 78 79- If you have non-trivial contributions, please consider adding an entry to [the 80 AUTHORS file](https://github.com/grpc/grpc/blob/master/AUTHORS) listing the 81 copyright holder for the contribution (yourself, if you are signing the 82 individual CLA, or your company, for corporate CLAs) in the same PR as your 83 contribution. This needs to be done only once, for each company, or 84 individual. 85 86- Maintain **clean commit history** and use **meaningful commit messages**. 87 PRs with messy commit history are difficult to review and won't be merged. 88 Use `rebase -i upstream/master` to curate your commit history and/or to 89 bring in latest changes from master (but avoid rebasing in the middle of 90 a code review). 91 92- Keep your PR up to date with upstream/master (if there are merge conflicts, 93 we can't really merge your change). 94 95- If you are regenerating the projects using 96 `tools/buildgen/generate_projects.sh`, make changes to generated files a 97 separate commit with commit message `regenerate projects`. Mixing changes 98 to generated and hand-written files make your PR difficult to review. 99 Note that running this script requires the installation of Python packages 100 `pyyaml` and `mako` (typically installed using `pip`) as well as a recent 101 version of [`go`](https://golang.org/doc/install#install). 102 103- **All tests need to be passing** before your change can be merged. 104 We recommend you **run tests locally** before creating your PR to catch 105 breakages early on (see [tools/run_tests](tools/run_tests). Ultimately, the 106 green signal will be provided by our testing infrastructure. The reviewer 107 will help you if there are test failures that seem not related to the change 108 you are making. 109 110- Exceptions to the rules can be made if there's a compelling reason for doing 111 so. 112 113 114 115