xref: /aosp_15_r20/external/grpc-grpc-java/CONTRIBUTING.md (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1*e07d83d3SAndroid Build Coastguard Worker# How to contribute
2*e07d83d3SAndroid Build Coastguard Worker
3*e07d83d3SAndroid Build Coastguard WorkerWe definitely welcome your patches and contributions to gRPC! Please read the gRPC
4*e07d83d3SAndroid Build Coastguard Workerorganization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md)
5*e07d83d3SAndroid Build Coastguard Workerand [contribution guidelines](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) before proceeding.
6*e07d83d3SAndroid Build Coastguard Worker
7*e07d83d3SAndroid Build Coastguard Worker
8*e07d83d3SAndroid Build Coastguard WorkerIf you are new to github, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/)
9*e07d83d3SAndroid Build Coastguard Worker
10*e07d83d3SAndroid Build Coastguard Worker## Legal requirements
11*e07d83d3SAndroid Build Coastguard Worker
12*e07d83d3SAndroid Build Coastguard WorkerIn order to protect both you and ourselves, you will need to sign the
13*e07d83d3SAndroid Build Coastguard Worker[Contributor License Agreement](https://easycla.lfx.linuxfoundation.org/). When
14*e07d83d3SAndroid Build Coastguard Workeryou make a PR, a CLA bot will provide a link for the process.
15*e07d83d3SAndroid Build Coastguard Worker
16*e07d83d3SAndroid Build Coastguard Worker## Compiling
17*e07d83d3SAndroid Build Coastguard Worker
18*e07d83d3SAndroid Build Coastguard WorkerSee [COMPILING.md](COMPILING.md). Specifically, you'll generally want to set
19*e07d83d3SAndroid Build Coastguard Worker`skipCodegen=true` so you don't need to deal with the C++ compilation.
20*e07d83d3SAndroid Build Coastguard Worker
21*e07d83d3SAndroid Build Coastguard Worker## Code style
22*e07d83d3SAndroid Build Coastguard Worker
23*e07d83d3SAndroid Build Coastguard WorkerWe follow the [Google Java Style
24*e07d83d3SAndroid Build Coastguard WorkerGuide](https://google.github.io/styleguide/javaguide.html). Our
25*e07d83d3SAndroid Build Coastguard Workerbuild automatically will provide warnings for style issues.
26*e07d83d3SAndroid Build Coastguard Worker[Eclipse](https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml)
27*e07d83d3SAndroid Build Coastguard Workerand
28*e07d83d3SAndroid Build Coastguard Worker[IntelliJ](https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml)
29*e07d83d3SAndroid Build Coastguard Workerstyle configurations are commonly useful. For IntelliJ 14, copy the style to
30*e07d83d3SAndroid Build Coastguard Worker`~/.IdeaIC14/config/codestyles/`, start IntelliJ, go to File > Settings > Code
31*e07d83d3SAndroid Build Coastguard WorkerStyle, and set the Scheme to `GoogleStyle`.
32*e07d83d3SAndroid Build Coastguard Worker
33*e07d83d3SAndroid Build Coastguard Worker## Maintaining clean commit history
34*e07d83d3SAndroid Build Coastguard Worker
35*e07d83d3SAndroid Build Coastguard WorkerWe have few conventions for keeping history clean and making code reviews easier
36*e07d83d3SAndroid Build Coastguard Workerfor reviewers:
37*e07d83d3SAndroid Build Coastguard Worker
38*e07d83d3SAndroid Build Coastguard Worker* First line of commit messages should be in format of
39*e07d83d3SAndroid Build Coastguard Worker
40*e07d83d3SAndroid Build Coastguard Worker  `package-name: summary of change`
41*e07d83d3SAndroid Build Coastguard Worker
42*e07d83d3SAndroid Build Coastguard Worker  where the summary finishes the sentence: `This commit improves gRPC to ____________.`
43*e07d83d3SAndroid Build Coastguard Worker
44*e07d83d3SAndroid Build Coastguard Worker  for example:
45*e07d83d3SAndroid Build Coastguard Worker
46*e07d83d3SAndroid Build Coastguard Worker  `core,netty,interop-testing: add capacitive duractance to turbo encabulators`
47*e07d83d3SAndroid Build Coastguard Worker
48*e07d83d3SAndroid Build Coastguard Worker* Every time you receive a feedback on your pull request, push changes that
49*e07d83d3SAndroid Build Coastguard Worker  address it as a separate one or multiple commits with a descriptive commit
50*e07d83d3SAndroid Build Coastguard Worker  message (try avoid using vauge `addressed pr feedback` type of messages).
51*e07d83d3SAndroid Build Coastguard Worker
52*e07d83d3SAndroid Build Coastguard Worker  Project maintainers are obligated to squash those commits into one when
53*e07d83d3SAndroid Build Coastguard Worker  merging.
54*e07d83d3SAndroid Build Coastguard Worker
55*e07d83d3SAndroid Build Coastguard Worker## Running tests
56*e07d83d3SAndroid Build Coastguard Worker
57*e07d83d3SAndroid Build Coastguard Worker### Jetty ALPN setup for IntelliJ
58*e07d83d3SAndroid Build Coastguard Worker
59*e07d83d3SAndroid Build Coastguard WorkerThe tests in interop-testing project require jetty-alpn agent running in the background
60*e07d83d3SAndroid Build Coastguard Workerotherwise they'll fail. Here are instructions on how to setup IntellJ IDEA to enable running
61*e07d83d3SAndroid Build Coastguard Workerthose tests in IDE:
62*e07d83d3SAndroid Build Coastguard Worker
63*e07d83d3SAndroid Build Coastguard Worker* Settings -> Build Tools -> Gradle -> Runner -> select Gradle Test Runner
64*e07d83d3SAndroid Build Coastguard Worker* View -> Tool Windows -> Gradle -> Edit Run Configuration -> Defaults -> JUnit -> Before lauch -> + -> Run Gradle task, enter the task in the build.gradle that sets the javaagent.
65*e07d83d3SAndroid Build Coastguard Worker
66*e07d83d3SAndroid Build Coastguard WorkerStep 1 must be taken, otherwise by the default JUnit Test Runner running a single test in IDE will trigger all the tests.
67*e07d83d3SAndroid Build Coastguard Worker
68*e07d83d3SAndroid Build Coastguard Worker## Guidelines for Pull Requests
69*e07d83d3SAndroid Build Coastguard WorkerHow to get your contributions merged smoothly and quickly.
70*e07d83d3SAndroid Build Coastguard Worker
71*e07d83d3SAndroid Build Coastguard Worker- Create **small PRs** that are narrowly focused on **addressing a single concern**. We often times receive PRs that are trying to fix several things at a time, but only one fix is considered acceptable, nothing gets merged and both author's & review's time is wasted. Create more PRs to address different concerns and everyone will be happy.
72*e07d83d3SAndroid Build Coastguard Worker
73*e07d83d3SAndroid Build Coastguard Worker- For speculative changes, consider opening an issue and discussing it first. If you are suggesting a behavioral or API change, consider starting with a [gRFC proposal](https://github.com/grpc/proposal).
74*e07d83d3SAndroid Build Coastguard Worker
75*e07d83d3SAndroid Build Coastguard Worker- Provide a good **PR description** as a record of **what** change is being made and **why** it was made. Link to a github issue if it exists.
76*e07d83d3SAndroid Build Coastguard Worker
77*e07d83d3SAndroid Build Coastguard Worker- Don't fix code style and formatting unless you are already changing that line to address an issue. PRs with irrelevant changes won't be merged. If you do want to fix formatting or style, do that in a separate PR.
78*e07d83d3SAndroid Build Coastguard Worker
79*e07d83d3SAndroid Build Coastguard Worker- Unless your PR is trivial, you should expect there will be reviewer comments that you'll need to address before merging. We expect you to be reasonably responsive to those comments, otherwise the PR will be closed after 2-3 weeks of inactivity.
80*e07d83d3SAndroid Build Coastguard Worker
81*e07d83d3SAndroid Build Coastguard Worker- Maintain **clean commit history** and use **meaningful commit messages**. See [maintaining clean commit history](#maintaining-clean-commit-history) for details.
82*e07d83d3SAndroid Build Coastguard Worker
83*e07d83d3SAndroid Build Coastguard Worker- Keep your PR up to date with upstream/master (if there are merge conflicts, we can't really merge your change).
84*e07d83d3SAndroid Build Coastguard Worker
85*e07d83d3SAndroid Build Coastguard Worker- **All tests need to be passing** before your change can be merged. We recommend you **run tests locally** before creating your PR to catch breakages early on. Also, `./gradlew build` (`gradlew build` on Windows) **must not introduce any new warnings**.
86*e07d83d3SAndroid Build Coastguard Worker
87*e07d83d3SAndroid Build Coastguard Worker- Exceptions to the rules can be made if there's a compelling reason for doing so.
88