xref: /openbmc/docs/CONTRIBUTING.md (revision 80f55a589d474e40cef0f9b6ee728098b8da159d)
1f4febd00SPatrick Williams# Contributing to OpenBMC
21a8a4383SAlexander Amelkin
3f16116beSEmily ShafferFirst off, thanks for taking the time to contribute! The following is a set of
4f16116beSEmily Shafferguidelines for contributing to an OpenBMC repository which are hosted in the
5f16116beSEmily Shaffer[OpenBMC Organization](https://github.com/openbmc) on GitHub. Feel free to
6f16116beSEmily Shafferpropose changes to this document.
7f16116beSEmily Shaffer
8f16116beSEmily Shaffer## Code of Conduct
9f16116beSEmily Shaffer
10f16116beSEmily ShafferWe enthusiastically adhere to our
11f16116beSEmily Shaffer[Code of Conduct](https://github.com/openbmc/docs/blob/master/code-of-conduct.md).
12f16116beSEmily ShafferIf you have any concerns, please check that document for guidelines on who can
13f16116beSEmily Shafferhelp you resolve them.
141a8a4383SAlexander Amelkin
157df8a841SBrad Bishop## Inclusive Naming
167df8a841SBrad Bishop
177df8a841SBrad BishopOpenBMC relies on the Open Compute Project to provide guidelines on inclusive
187df8a841SBrad Bishopnaming. The OCP guidelines can be found here:
197df8a841SBrad Bishop
207df8a841SBrad Bishophttps://www.opencompute.org/documents/ocp-terminology-guidelines-for-inclusion-and-openness
217df8a841SBrad Bishop
22f4febd00SPatrick Williams## Structure
231a8a4383SAlexander Amelkin
241a8a4383SAlexander AmelkinOpenBMC has quite a modular structure, consisting of small daemons with a
251a8a4383SAlexander Amelkinlimited set of responsibilities. These communicate over D-Bus with other
261a8a4383SAlexander Amelkincomponents, to implement the complete BMC system.
271a8a4383SAlexander Amelkin
281a8a4383SAlexander AmelkinThe BMC's interfaces to the external world are typically through a separate
291a8a4383SAlexander Amelkindaemon, which then translates those requests to D-Bus messages.
301a8a4383SAlexander Amelkin
31f4febd00SPatrick WilliamsThese separate projects are then compiled into the final system by the overall
32f4febd00SPatrick Williams'openbmc' build infrastructure.
331a8a4383SAlexander Amelkin
341a8a4383SAlexander AmelkinFor future development, keep this design in mind. Components' functionality
35f4febd00SPatrick Williamsshould be logically grouped, and keep related parts together where it makes
36f4febd00SPatrick Williamssense.
371a8a4383SAlexander Amelkin
38f4febd00SPatrick Williams## Starting out
391a8a4383SAlexander Amelkin
40ce0a0c64SKurt TaylorBefore you make a contribution, execute one of the OpenBMC Contributor License
41ce0a0c64SKurt TaylorAgreements, _One time only_:
42ce0a0c64SKurt Taylor
43f4febd00SPatrick Williams- [Individual CLA](https://drive.google.com/file/d/1k3fc7JPgzKdItEfyIoLxMCVbPUhTwooY)
44f4febd00SPatrick Williams- [Corporate CLA](https://drive.google.com/file/d/1d-2M8ng_Dl2j1odsvZ8o1QHAdHB-pNSH)
45ce0a0c64SKurt Taylor
46f4febd00SPatrick WilliamsIf you work for someone, consider asking them to execute the corporate CLA. This
47f4febd00SPatrick Williamsallows other contributors that work for your employer to skip the CLA signing
48f4febd00SPatrick Williamsprocess, they can just be added to the existing CCLA Schedule A.
49ce0a0c64SKurt Taylor
50ce0a0c64SKurt TaylorAfter signing a CLA, send it to manager@lfprojects.org.
51ce0a0c64SKurt Taylor
52ce0a0c64SKurt TaylorIf you're looking for a place to get started with OpenBMC, you may want to take
53ce0a0c64SKurt Taylora look at the issues tagged with 'bitesize'. These are fixes or enhancements
54ce0a0c64SKurt Taylorthat don't require extensive knowledge of the OpenBMC codebase, and are easier
55ce0a0c64SKurt Taylorfor a newcomer to start working with.
561a8a4383SAlexander Amelkin
571a8a4383SAlexander AmelkinCheck out that list here:
581a8a4383SAlexander Amelkin
591a8a4383SAlexander Amelkinhttps://github.com/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+user%3Aopenbmc+label%3Abitesize
601a8a4383SAlexander Amelkin
611a8a4383SAlexander AmelkinIf you need further details on any of these issues, feel free to add comments.
621a8a4383SAlexander Amelkin
6394b94e50SJoseph ReynoldsPerforming code reviews is another good way to get started. Go to
64f4febd00SPatrick Williamshttps://gerrit.openbmc.org and click on the "all" and "open" menu items, or if
65f4febd00SPatrick Williamsyou are interested in a particular repository - for example, "bmcweb" - type
66f4febd00SPatrick Williams"status:open project:openbmc/bmcweb" into the search bar and press the "search"
67f4febd00SPatrick Williamsbutton. Then select a review. Remember to be positive and add value with every
68f4febd00SPatrick Williamsreview comment.
6994b94e50SJoseph Reynolds
70f4febd00SPatrick Williams## Coding style
711a8a4383SAlexander Amelkin
72f4febd00SPatrick WilliamsComponents of the OpenBMC sources should have a consistent style. If the source
73f4febd00SPatrick Williamsis coming from another project, we choose to follow the existing style of the
74f4febd00SPatrick Williamsupstream project. Otherwise, conventions are chosen based on the language.
751a8a4383SAlexander Amelkin
761a8a4383SAlexander Amelkin### Python
771a8a4383SAlexander Amelkin
78f4febd00SPatrick WilliamsPython source should all conform to PEP8. This style is well established within
79f4febd00SPatrick Williamsthe Python community and can be verified with the 'pycodestyle' tool.
801a8a4383SAlexander Amelkin
811a8a4383SAlexander Amelkinhttps://www.python.org/dev/peps/pep-0008/
821a8a4383SAlexander Amelkin
831a8a4383SAlexander Amelkin### Python Formatting
841a8a4383SAlexander Amelkin
85f4febd00SPatrick WilliamsIf a repository has a setup.cfg file present in its root directory, then CI will
86f4febd00SPatrick Williamsautomatically verify the Python code meets the
87f4febd00SPatrick Williams[pycodestyle](http://pycodestyle.pycqa.org/en/latest/intro.html) requirements.
88f4febd00SPatrick WilliamsThis enforces PEP 8 standards on all Python code.
891a8a4383SAlexander Amelkin
901a8a4383SAlexander AmelkinOpenBMC standards for Python match with PEP 8 so in general, a blank setup.cfg
91f4febd00SPatrick Williamsfile is all that's needed. If so desired, enforcement of 80 (vs. the default 79)
92f4febd00SPatrick Williamschars is fine as well:
93f4febd00SPatrick Williams
941a8a4383SAlexander Amelkin```
951a8a4383SAlexander Amelkin[pycodestyle]
961a8a4383SAlexander Amelkinmax-line-length = 80
971a8a4383SAlexander Amelkin```
98f4febd00SPatrick Williams
991a8a4383SAlexander AmelkinBy default, pycodestyle does not enforce the following rules: E121, E123, E126,
1001a8a4383SAlexander AmelkinE133, E226, E241, E242, E704, W503, and W504. These rules are ignored because
1011a8a4383SAlexander Amelkinthey are not unanimously accepted and PEP 8 does not enforce them. It is at the
1021a8a4383SAlexander Amelkinrepository maintainer's discretion as to whether to enforce the aforementioned
1031a8a4383SAlexander Amelkinrules. These rules can be enforced by adding the following to the setup.cfg:
104f4febd00SPatrick Williams
1051a8a4383SAlexander Amelkin```
1061a8a4383SAlexander Amelkin[pycodestyle]
1071a8a4383SAlexander Amelkinignore= NONE
1081a8a4383SAlexander Amelkin```
1091a8a4383SAlexander Amelkin
110cf8b012cSGunnar Mills### JavaScript
111cf8b012cSGunnar Mills
11273aa4ef1SGunnar MillsWe follow the
11373aa4ef1SGunnar Mills[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html).
11473aa4ef1SGunnar Mills
1150dcc430aSPatrick Venture[Example .clang-format](https://www.github.com/openbmc/docs/blob/master/style/javascript/.clang-format)
116cf8b012cSGunnar Mills
1171d97520fSGunnar Mills### HTML/CSS
1181d97520fSGunnar Mills
1191d97520fSGunnar MillsWe follow the
1201d97520fSGunnar Mills[Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html).
1211d97520fSGunnar Mills
1221a8a4383SAlexander Amelkin### C
1231a8a4383SAlexander Amelkin
1241a8a4383SAlexander AmelkinFor C code, we typically use the Linux coding style, which is documented at:
1251a8a4383SAlexander Amelkin
1261a8a4383SAlexander Amelkinhttp://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst
1271a8a4383SAlexander Amelkin
1281a8a4383SAlexander AmelkinIn short:
1291a8a4383SAlexander Amelkin
1301a8a4383SAlexander Amelkin- Indent with tabs instead of spaces, set at 8 columns
1311a8a4383SAlexander Amelkin
1321a8a4383SAlexander Amelkin- 80-column lines
1331a8a4383SAlexander Amelkin
1341a8a4383SAlexander Amelkin- Opening braces on the end of a line, except for functions
1351a8a4383SAlexander Amelkin
1361a8a4383SAlexander AmelkinThis style can mostly be verified with 'astyle' as follows:
1371a8a4383SAlexander Amelkin
1381a8a4383SAlexander Amelkin    astyle --style=linux --indent=tab=8 --indent=force-tab=8
1391a8a4383SAlexander Amelkin
1401a8a4383SAlexander Amelkin### C++
1411a8a4383SAlexander Amelkin
1421a8a4383SAlexander AmelkinSee [C++ Style and Conventions](./cpp-style-and-conventions.md).
1431a8a4383SAlexander Amelkin
144f4febd00SPatrick Williams## Planning changes
14594b94e50SJoseph Reynolds
146f4febd00SPatrick WilliamsIf you are making a nontrivial change, you should plan how to introduce it to
147f4febd00SPatrick Williamsthe OpenBMC development community.
14894b94e50SJoseph Reynolds
149f4febd00SPatrick WilliamsIf you are planning a new function, you should get agreement that your change
150f4febd00SPatrick Williamswill be accepted. As early as you can, introduce the change via the OpenBMC
151f4febd00SPatrick WilliamsDiscord server or email list to start the discussion. You may find a better way
152f4febd00SPatrick Williamsto do what you need.
15394b94e50SJoseph Reynolds
154f4febd00SPatrick WilliamsIf the feedback seems favorable or requests more details, continue by submitting
155f4febd00SPatrick Williamsthe design to gerrit starting with a copy of the
15609d1bd49SDeepak Kodihalli[design_template](https://github.com/openbmc/docs/blob/master/designs/design-template.md).
157a64a8979SMilton Miller
158f4febd00SPatrick Williams## Submitting changes
159f16116beSEmily Shaffer
160f16116beSEmily ShafferWe use git for almost everything. Most projects in OpenBMC use Gerrit to review
161f16116beSEmily Shafferpatches. Changes to an upstream project (e.g. Yocto Project, systemd, or the
162f16116beSEmily ShafferLinux kernel) might need to be sent as patches or a git pull request.
163f16116beSEmily Shaffer
164f16116beSEmily Shaffer### Organizing Commits
165f16116beSEmily Shaffer
166f16116beSEmily ShafferA good commit does exactly one thing. We prefer many small, atomic commits to
167f16116beSEmily Shafferone large commit which makes many functional changes.
168f4febd00SPatrick Williams
169f16116beSEmily Shaffer- Too large: "convert foo to new API; also fix CVE 1234 in bar"
170f16116beSEmily Shaffer- Too small: "move abc.h to top of include list" and "move xyz.h to bottom of
171f16116beSEmily Shaffer  include list"
172f16116beSEmily Shaffer- Just right: "convert foo to new API" and "convert foo from tab to space"
173f16116beSEmily Shaffer
174f16116beSEmily ShafferOther commit tips:
175f4febd00SPatrick Williams
176f4febd00SPatrick Williams- If your change has a specification, sketch out your ideas first and work to
177f4febd00SPatrick Williams  get that accepted before completing the details.
17894b94e50SJoseph Reynolds- Work at most a few days before seeking review.
17994b94e50SJoseph Reynolds- Commit and review header files before writing code.
18094b94e50SJoseph Reynolds- Commit and review each implementation module separately.
18194b94e50SJoseph Reynolds
182f16116beSEmily ShafferOften, creating small commits this way results in many commits that are
183f16116beSEmily Shafferdependent on prior commits; Gerrit handles this situation well, so feel free to
184f16116beSEmily Shafferpush commits which are based on your change still in review. However, when
185f16116beSEmily Shafferpossible, your commit should stand alone on top of master - "Fix whitespace in
186f16116beSEmily Shafferbar()" does not need to depend on "refactor foo()". Said differently, ensure
187f4febd00SPatrick Williamsthat topics that are not related to each other semantically are also not related
188f4febd00SPatrick Williamsto each other in Git until they are merged into master.
18994b94e50SJoseph Reynolds
190f16116beSEmily ShafferWhen pushing a stack of patches, these commits will show up with that same
191f16116beSEmily Shafferrelationship in Gerrit. This means that each patch must be merged in order of
192f16116beSEmily Shafferthat relationship. So if one of the patches in the middle needs to be changed,
193f16116beSEmily Shafferall the patches from that point on would need to be pushed to maintain the
194f4febd00SPatrick Williamsrelationship. This will effectively rebase the unchanged patches, which would in
195f4febd00SPatrick Williamsturn trigger a new CI build. Ideally, changes from the entire patchset could be
196f4febd00SPatrick Williamsdone all in one go to reduce unnecessary rebasing.
1971a8a4383SAlexander Amelkin
198f16116beSEmily ShafferWhen someone makes a comment on your commit in Gerrit, modify that commit and
199f16116beSEmily Shaffersend it again to Gerrit. This typically involves `git rebase --interactive` or
200f16116beSEmily Shaffer`git commit --amend`, for which there are many guides online. As mentioned in
201f16116beSEmily Shafferthe paragraph above, when possible you should make changes to multiple patches
202f16116beSEmily Shafferin the same stack before you push, in order to minimize CI and notification
203f16116beSEmily Shafferchurn from the rebase operations.
2041a8a4383SAlexander Amelkin
205f16116beSEmily ShafferCommits which include changes that can be tested by a unit test should also
206f16116beSEmily Shafferinclude a unit test to exercise that change, within the same commit. Unit tests
207f16116beSEmily Shaffershould be clearly written - even more so than production code, unit tests are
208f16116beSEmily Shaffermeant primarily to be read by humans - and should test both good and bad
209f16116beSEmily Shafferbehaviors. Refer to the
210f16116beSEmily Shaffer[testing documentation](https://github.com/openbmc/docs/blob/master/testing/local-ci-build.md)
211f16116beSEmily Shafferfor help writing tests, as well as best practices.
212f16116beSEmily Shaffer
213f4febd00SPatrick WilliamsEnsure that your patch doesn't change unrelated areas. Be careful of accidental
214f4febd00SPatrick Williamswhitespace changes - this makes review unnecessarily difficult.
215f16116beSEmily Shaffer
216f16116beSEmily Shaffer### Formatting Commit Messages
217f16116beSEmily Shaffer
218f16116beSEmily ShafferYour commit message should explain:
219f16116beSEmily Shaffer
220f4febd00SPatrick Williams- Concisely, _what_ change are you making? e.g. "libpldm: Add APIs to enable
221f16116beSEmily Shaffer  PLDM Requester" This first line of your commit message is the subject line.
222f4febd00SPatrick Williams- Comprehensively, _why_ are you making that change? In some cases, like a small
223f4febd00SPatrick Williams  refactor, the why is fairly obvious. But in cases like the inclusion of a new
224f4febd00SPatrick Williams  feature, you should explain why the feature is needed.
225f4febd00SPatrick Williams- Concisely, _how_ did you test? (see below).
226f16116beSEmily Shaffer
227f16116beSEmily ShafferTry to include the component you are changing at the front of your subject line;
228f16116beSEmily Shafferthis typically comes in the form of the class, module, handler, or directory you
229f16116beSEmily Shafferare modifying. e.g. "apphandler: refactor foo to new API"
230f16116beSEmily Shaffer
2313f84e953SEd TanousCommit messages should follow the 50/72 rule: the subject line should not exceed
2323f84e953SEd Tanous50 characters and the body should not exceed 72 characters. This is common
2333f84e953SEd Tanouspractice in many projects which use Git.
2343f84e953SEd Tanous
2353f84e953SEd TanousExceptions to this are allowed in the form of links, which can be represented in
2363f84e953SEd Tanousthe form of:
2373f84e953SEd Tanous
238f4febd00SPatrick Williams''' This implements [1]
2393f84e953SEd Tanous
2403f84e953SEd Tanous....
2413f84e953SEd Tanous
242f4febd00SPatrick Williams[1] https://openbmc.org/myverylongurl. '''
243f16116beSEmily Shaffer
244f16116beSEmily ShafferAll commit messages must include a "Signed-off-by" line, which indicates that
245f4febd00SPatrick Williamsyou the contributor have agreed to the Developer Certificate of Origin (see
246f4febd00SPatrick Williamsbelow). This line must include the full name you commonly use, often a given
247f4febd00SPatrick Williamsname and a family name or surname. (ok: Sam Samuelsson, Robert A. Heinlein; not
248f4febd00SPatrick Williamsok: xXthorXx, Sam, RAH)
249f16116beSEmily Shaffer
250f16116beSEmily Shaffer### Testing
2511a8a4383SAlexander Amelkin
2521a8a4383SAlexander AmelkinEach commit is expected to be tested. The expectation of testing may vary from
2531a8a4383SAlexander Amelkinsubproject to subproject, but will typically include running all applicable
2541a8a4383SAlexander Amelkinautomated tests and performing manual testing. Each commit should be tested
255f4febd00SPatrick Williamsseparately, even if they are submitted together (an exception is when commits to
256f4febd00SPatrick Williamsdifferent projects depend on each other).
2571a8a4383SAlexander Amelkin
2581a8a4383SAlexander AmelkinCommit messages should include a "Tested" field describing how you tested the
2591a8a4383SAlexander Amelkincode changes in the patch. Example:
260f4febd00SPatrick Williams
2611a8a4383SAlexander Amelkin```
2621a8a4383SAlexander Amelkin    Tested: I ran unit tests with "make check" (added 2 new tests) and manually
2631a8a4383SAlexander Amelkin    tested on Witherspoon that Foo daemon no longer crashes at boot.
2641a8a4383SAlexander Amelkin```
2651a8a4383SAlexander Amelkin
266f16116beSEmily ShafferIf the change required manual testing, describe what you did and what happened;
267f16116beSEmily Shafferif it used to do something else before your change, describe that too. If the
268f16116beSEmily Shafferchange can be validated entirely by running unit tests, say so in the "Tested:"
269f16116beSEmily Shafferfield.
270f16116beSEmily Shaffer
271f16116beSEmily Shaffer### Linux Kernel
2721a8a4383SAlexander Amelkin
2731a8a4383SAlexander AmelkinThe guidelines in the Linux kernel are very useful:
2741a8a4383SAlexander Amelkin
2751a8a4383SAlexander Amelkinhttps://www.kernel.org/doc/html/latest/process/submitting-patches.html
2761a8a4383SAlexander Amelkin
2771a8a4383SAlexander Amelkinhttps://www.kernel.org/doc/html/latest/process/submit-checklist.html
2781a8a4383SAlexander Amelkin
2791a8a4383SAlexander AmelkinYour contribution will generally need to be reviewed before being accepted.
2801a8a4383SAlexander Amelkin
281f4febd00SPatrick Williams## Submitting changes via Gerrit server to OpenBMC
2821a8a4383SAlexander Amelkin
2831a8a4383SAlexander AmelkinThe OpenBMC Gerrit server supports GitHub credentials, its link is:
2841a8a4383SAlexander Amelkin
2850ee8da09SNodeMan97https://gerrit.openbmc.org/#/q/status:open
2861a8a4383SAlexander Amelkin
2871a8a4383SAlexander Amelkin_One time setup_: Login to the WebUI with your GitHub credentials and verify on
28831f9f661SGunnar Millsyour Account Settings that your SSH keys were imported:
2891a8a4383SAlexander Amelkin
2900ee8da09SNodeMan97https://gerrit.openbmc.org/#/settings/
2911a8a4383SAlexander Amelkin
2921a8a4383SAlexander AmelkinMost repositories are supported by the Gerrit server, the current list can be
2931a8a4383SAlexander Amelkinfound under Projects -> List:
2941a8a4383SAlexander Amelkin
2950ee8da09SNodeMan97https://gerrit.openbmc.org/#/admin/projects/
2961a8a4383SAlexander Amelkin
2971a8a4383SAlexander AmelkinIf you're going to be working with Gerrit often, it's useful to create an SSH
2981a8a4383SAlexander Amelkinhost block in ~/.ssh/config. Ex:
299f4febd00SPatrick Williams
3001a8a4383SAlexander Amelkin```
3011a8a4383SAlexander AmelkinHost openbmc.gerrit
3020ee8da09SNodeMan97        Hostname gerrit.openbmc.org
3031a8a4383SAlexander Amelkin        Port 29418
3041a8a4383SAlexander Amelkin        User your_github_id
3051a8a4383SAlexander Amelkin```
3061a8a4383SAlexander Amelkin
3071a8a4383SAlexander AmelkinFrom your OpenBMC git repository, add a remote to the Gerrit server, where
3081a8a4383SAlexander Amelkin'openbmc_repo' is the current git repository you're working on, such as
3092c4da27fSGunnar Millsphosphor-state-manager, and 'openbmc.gerrit' is the name of the Host previously
3102c4da27fSGunnar Millsadded:
3111a8a4383SAlexander Amelkin
3121a8a4383SAlexander Amelkin`git remote add gerrit ssh://openbmc.gerrit/openbmc/openbmc_repo`
3131a8a4383SAlexander Amelkin
314fb532ca7SPaul FertserAlternatively, you can encode all the data in the URL:
315fb532ca7SPaul Fertser
3160ee8da09SNodeMan97`git remote add gerrit ssh://your_github_id@gerrit.openbmc.org:29418/openbmc/openbmc_repo`
317fb532ca7SPaul Fertser
318fb532ca7SPaul FertserThen add the default branch for pushes to this remote:
319fb532ca7SPaul Fertser
320fb532ca7SPaul Fertser`git config remote.gerrit.push HEAD:refs/for/master`
321fb532ca7SPaul Fertser
322f4febd00SPatrick WilliamsGerrit uses
323f4febd00SPatrick Williams[Change-Ids](https://gerrit-review.googlesource.com/Documentation/user-changeid.html)
324f4febd00SPatrick Williamsto identify commits that belong to the same review. Configure your git
325f4febd00SPatrick Williamsrepository to automatically add a Change-Id to your commit messages. The steps
326f4febd00SPatrick Williamsare:
3271a8a4383SAlexander Amelkin
328*80f55a58SAmithash Prasasd```
329*80f55a58SAmithash Prasasdgitdir=$(git rev-parse --git-dir)
330*80f55a58SAmithash Prasasdcurl https://gerrit.openbmc.org/tools/hooks/commit-msg -o ${gitdir}/hooks/commit-msg
331*80f55a58SAmithash Prasasdchmod +x ${gitdir}/hooks/commit-msg`
332*80f55a58SAmithash Prasasd```
3331a8a4383SAlexander Amelkin
3341a8a4383SAlexander AmelkinTo submit a change set, commit your changes, and push to the Gerrit server,
3351a8a4383SAlexander Amelkinwhere 'gerrit' is the name of the remote added with the git remote add command:
3361a8a4383SAlexander Amelkin
337fb532ca7SPaul Fertser`git push gerrit`
338fb532ca7SPaul Fertser
339f4febd00SPatrick WilliamsSometimes you need to specify a topic (especially when working on a feature that
340f4febd00SPatrick Williamsspans across few projects) or (un)mark the change as Work-in-Progress. For that
341f4febd00SPatrick Williamsrefer to
342f4febd00SPatrick Williams[Gerrit documentation](https://gerrit-review.googlesource.com/Documentation/intro-user.html#topics).
3431a8a4383SAlexander Amelkin
344f4febd00SPatrick WilliamsGerrit will show you the URL link to your review. You can also find your reviews
345f4febd00SPatrick Williamsfrom the [OpenBMC Gerrit server](https://gerrit.openbmc.org) search bar or menu
346f4febd00SPatrick Williams(All > Open, or My > Changes).
34794b94e50SJoseph Reynolds
348f4febd00SPatrick WilliamsInvite reviewers to review your changes. Each OpenBMC repository has an `OWNERS`
349f4febd00SPatrick Williamsfile that lists required reviewers who are subject matter experts. Those
350f4febd00SPatrick Williamsreviewers may add additional reviewers. To add reviewers from the Gerrit web
351f4febd00SPatrick Williamspage, click the "add reviewers" icon by the list of reviewers.
35294b94e50SJoseph Reynolds
353f4febd00SPatrick WilliamsYou are expected to respond to all comments. And remember to use the "reply"
354f4febd00SPatrick Williamsbutton to publish your replies for others to see.
35594b94e50SJoseph Reynolds
356f4febd00SPatrick WilliamsThe review results in the proposed change being accepted, rejected for rework,
357f4febd00SPatrick Williamsor abandoned. When you re-work your change, remember to use `git commit --amend`
358f4febd00SPatrick Williamsso Gerrit handles the update as a new patch of the same review.
35994b94e50SJoseph Reynolds
360f4febd00SPatrick WilliamsEach repository is governed by a small group of maintainers who are leaders with
361f4febd00SPatrick Williamsexpertise in their area. They are responsible for reviewing changes and
362f4febd00SPatrick Williamsmaintaining the quality of the code. You'll need a maintainer to accept your
363f4febd00SPatrick Williamschange, and they will look to the other reviewers for guidance. When accepted,
364f4febd00SPatrick Williamsyour change will merge into the OpenBMC project.
36594b94e50SJoseph Reynolds
366f4febd00SPatrick Williams## References to non-public resources
3671a8a4383SAlexander Amelkin
368f4febd00SPatrick WilliamsCode and commit messages shall not refer to companies' internal documents or
369f4febd00SPatrick Williamssystems (including bug trackers). Other developers may not have access to these,
370f4febd00SPatrick Williamsmaking future maintenance difficult.
3711a8a4383SAlexander Amelkin
372f4febd00SPatrick WilliamsCode contributed to OpenBMC must build from the publicly available sources, with
373f4febd00SPatrick Williamsno dependencies on non-public resources (URLs, repositories, etc).
3741a8a4383SAlexander Amelkin
375f4febd00SPatrick Williams## Best practices for D-Bus interfaces
3761a8a4383SAlexander Amelkin
377f4febd00SPatrick Williams- New D-Bus interfaces should be reusable
3781a8a4383SAlexander Amelkin
379f4febd00SPatrick Williams- Type signatures should and use the simplest types possible, appropriate for
380f4febd00SPatrick Williams  the data passed. For example, don't pass numbers as ASCII strings.
3811a8a4383SAlexander Amelkin
382f4febd00SPatrick Williams- D-Bus interfaces are defined in the `phosphor-dbus-interfaces` repository at:
3831a8a4383SAlexander Amelkin
3844571e0cfSGunnar Mills  https://github.com/openbmc/phosphor-dbus-interfaces
3851a8a4383SAlexander Amelkin
3864571e0cfSGunnar MillsSee: http://dbus.freedesktop.org/doc/dbus-api-design.html
3871a8a4383SAlexander Amelkin
388f4febd00SPatrick Williams## Best practices for C
3891a8a4383SAlexander Amelkin
3901a8a4383SAlexander AmelkinThere are numerous resources available elsewhere, but a few items that are
3911a8a4383SAlexander Amelkinrelevant to OpenBMC work:
3921a8a4383SAlexander Amelkin
393f4febd00SPatrick Williams- Do not use `system(<some shell pipeline>)`. Reading and writing from files
394f4febd00SPatrick Williams  should be done with the appropriate system calls.
3951a8a4383SAlexander Amelkin
396f4febd00SPatrick Williams  Generally, it's much better to use `fork(); execve()` if you do need to spawn
397f4febd00SPatrick Williams  a process, especially if you need to provide variable arguments.
3981a8a4383SAlexander Amelkin
399f4febd00SPatrick Williams- Use the `stdint` types (eg, `uint32_t`, `int8_t`) for data that needs to be a
400f4febd00SPatrick Williams  certain size. Use the `PRIxx` macros for printf, if necessary.
4011a8a4383SAlexander Amelkin
402f4febd00SPatrick Williams- Don't assume that `char` is signed or unsigned.
4031a8a4383SAlexander Amelkin
404f4febd00SPatrick Williams- Beware of endian considerations when reading to & writing from C types
4051a8a4383SAlexander Amelkin
406f4febd00SPatrick Williams- Declare internal-only functions as `static`, declare read-only data as `const`
407f4febd00SPatrick Williams  where possible.
4081a8a4383SAlexander Amelkin
409f4febd00SPatrick Williams- Ensure that your code compiles without warnings, especially for changes to the
410f4febd00SPatrick Williams  kernel.
4111a8a4383SAlexander Amelkin
41243421bddSAndrew Geissler## Best practices for Systemd usage
41343421bddSAndrew Geissler
41443421bddSAndrew Geissler- Systemd services should be contained within the OpenBMC repository they are
41543421bddSAndrew Geissler  associated with
41643421bddSAndrew Geissler
41743421bddSAndrew Geissler- Systemd services should list their dependencies using Wants/After to ensure
41843421bddSAndrew Geissler  required service are started
41943421bddSAndrew Geissler
42043421bddSAndrew Geissler- If your repository provides a shared library, it should appropriately handle
42143421bddSAndrew Geissler  any D-Bus dependencies it has
42243421bddSAndrew Geissler
42343421bddSAndrew Geissler  This may be clear documentation on what type of error or exception is returned
42443421bddSAndrew Geissler  or it may be ensuring the required D-Bus service is automatically activated
42543421bddSAndrew Geissler  upon calling it.
42643421bddSAndrew Geissler
42743421bddSAndrew Geissler- See this
42843421bddSAndrew Geissler  [doc](https://github.com/openbmc/docs/blob/master/architecture/openbmc-systemd.md)
42943421bddSAndrew Geissler  for more information on OpenBMC and its use of Systemd
43043421bddSAndrew Geissler
431f16116beSEmily Shaffer## Pace of Review
432f16116beSEmily Shaffer
433f16116beSEmily ShafferContributors who are used to code reviews by their team internal to their own
434f16116beSEmily Shaffercompany, or who are not used to code reviews at all, are sometimes surprised by
435f16116beSEmily Shafferthe pace of code reviews in open source projects. Try to keep in mind that those
436f16116beSEmily Shafferreviewing your patch may be contributing to OpenBMC in a volunteer or
437f4febd00SPatrick Williamspartial-time capacity, may be in a timezone far from your own, and may have very
438f4febd00SPatrick Williamsdeep review queues already of patches which have been waiting longer than yours.
439f4febd00SPatrick WilliamsDo everything you can to make it easy for the reviewer to review your
440f4febd00SPatrick Williamscontribution.
441f16116beSEmily Shaffer
442f4febd00SPatrick WilliamsIf you feel your patch has been missed entirely, of course, it's alright to
443f4febd00SPatrick Williamsemail the maintainers (addresses available in OWNERS file) or ping them on
444f4febd00SPatrick WilliamsDiscord - but a reasonable timeframe to do so is on the order of a week, not on
445f4febd00SPatrick Williamsthe order of hours.
446f16116beSEmily Shaffer
447f16116beSEmily ShafferThe maintainers' job is to ensure that incoming patches are as correct and easy
448f16116beSEmily Shafferto maintain as possible. Part of the nature of open source is attrition -
449f16116beSEmily Shaffercontributors can come and go easily - so maintainers tend not to put stock in
450f16116beSEmily Shafferpromises such as "I will add unit tests in a later patch" or "I will be
451f16116beSEmily Shafferimplementing this proposal by the end of next month." This often manifests as
452f16116beSEmily Shafferreviews which may seem harsh or exacting; please keep in mind that the community
453f16116beSEmily Shafferis trying to collaborate with you to build a patch that will benefit the project
454f16116beSEmily Shafferon its own.
4551a8a4383SAlexander Amelkin
456f4febd00SPatrick Williams## Developer's Certificate of Origin 1.1
4571a8a4383SAlexander Amelkin
4581a8a4383SAlexander Amelkin    By making a contribution to this project, I certify that:
4591a8a4383SAlexander Amelkin
4601a8a4383SAlexander Amelkin    (a) The contribution was created in whole or in part by me and I
4611a8a4383SAlexander Amelkin        have the right to submit it under the open source license
4621a8a4383SAlexander Amelkin        indicated in the file; or
4631a8a4383SAlexander Amelkin
4641a8a4383SAlexander Amelkin    (b) The contribution is based upon previous work that, to the best
4651a8a4383SAlexander Amelkin        of my knowledge, is covered under an appropriate open source
4661a8a4383SAlexander Amelkin        license and I have the right under that license to submit that
4671a8a4383SAlexander Amelkin        work with modifications, whether created in whole or in part
4681a8a4383SAlexander Amelkin        by me, under the same open source license (unless I am
4691a8a4383SAlexander Amelkin        permitted to submit under a different license), as indicated
4701a8a4383SAlexander Amelkin        in the file; or
4711a8a4383SAlexander Amelkin
4721a8a4383SAlexander Amelkin    (c) The contribution was provided directly to me by some other
4731a8a4383SAlexander Amelkin        person who certified (a), (b) or (c) and I have not modified
4741a8a4383SAlexander Amelkin        it.
4751a8a4383SAlexander Amelkin
4761a8a4383SAlexander Amelkin    (d) I understand and agree that this project and the contribution
4771a8a4383SAlexander Amelkin        are public and that a record of the contribution (including all
4781a8a4383SAlexander Amelkin        personal information I submit with it, including my sign-off) is
4791a8a4383SAlexander Amelkin        maintained indefinitely and may be redistributed consistent with
4801a8a4383SAlexander Amelkin        this project or the open source license(s) involved.
481