1# Contributing Guidelines 2 3This document attempts to outline some basic rules to follow when contributing 4to OpenBMC's IPMI stack. It does *not* outline coding style; we follow the 5[OpenBMC C++ style guide](https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions) 6for that. 7 8## Organizing Commits 9 10A good commit does exactly one thing. We prefer many small, atomic commits to 11one large commit which makes many functional changes. 12 - Too large: "convert foo to new API; also fix CVE 1234 in bar" 13 - Too small: "move abc.h to top of include list" and "move xyz.h to bottom of 14 include list" 15 - Just right: "convert foo to new API" and "convert foo from tab to space" 16 17Often, creating small commits this way results in a number of commits which are 18dependent on prior commits; Gerrit handles this situation well, so feel free to 19push commits which are based on your change still in review. However, when 20possible, your commit should stand alone on top of master - "Fix whitespace in 21bar()" does not need to depend on "refactor foo()". Said differently, ensure 22that topics which are not related to each other semantically are also not 23related to each other in Git until they are merged into master. 24 25When pushing a stack of patches (current branch is >1 commits ahead of 26origin/master), these commits will show up with that same relationship in 27gerrit. This means that each patch must be merged in order of that relationship. 28So if one of the patches in the middle needs to be changed, all the patches from 29that point on would need to be pushed to maintain the relationship. This will 30effectively rebase the unchanged patches, which would in turn trigger a new CI 31build. Ideally, changes from the entire patchset could be done all in one go to 32reduce unnecessary rebasing. 33 34When someone makes a comment on your commit in Gerrit, modify that commit and 35send it again to Gerrit. This typically involves `git rebase --interactive` or 36`git commit --amend`, for which there are many guides online. As mentioned in 37the paragraph above, when possible you should make changes to multiple patches 38in the same stack before you push, in order to minimize CI and notification 39churn from the rebase operations. 40 41Commits which include changes that can be tested by a unit test should also 42include a unit test to exercise that change, within the same commit. Unit tests 43should be clearly written - even moreso than production code, unit tests are 44meant primarily to be read by humans - and should test both good and bad 45behaviors. Refer to the 46[testing documentation](https://github.com/openbmc/phosphor-host-ipmid/blob/master/docs/testing.md) 47for help writing tests, as well as best practices. 48 49## Formatting Commit Messages 50 51Your commit message should explain: 52 53 - Concisely, *what* change are you making? e.g. "docs: convert from US to UK 54 spelling" This first line of your commit message is the subject line. 55 - Comprehensively, *why* are you making that change? In some cases, like a 56 small refactor, the why is fairly obvious. But in cases like the inclusion of 57 a new feature, you should explain why the feature is needed. 58 - Concisely, *how* did you test? This comes in the form of a "Tested:" footer 59 in your commit message and is required for all code changes in the IPMI 60 stack. It typically consists of copy-pasted ipmitool requests and responses. 61 When possible, use the high-level ipmitool commands (e.g. "ipmitool sensor 62 read 0x1"). In cases where that's not possible, or when testing edge or error 63 cases, it is acceptable to use "ipmitool raw" - but an explanation of your 64 output is appreciated. If the change can be validated entirely by running 65 unit tests, say so in the "Tested:" tag. 66 67Try to include the component you are changing at the front of your subject line; 68this typically comes in the form of the class, module, handler, or directory you 69are modifying. e.g. "apphandler: refactor foo to new API" 70 71Loosely, we try to follow the 50/72 rule for commit messages - that is, the 72subject line should not exceed 50 characters and the body should not exceed 72 73characters. This is common practice in many projects which use Git. 74 75All commit messages must include a Signed-off-by line, which indicates that you 76the contributor have agreed to the Developer Certificate of Origin. This line 77must include the name you commonly use, often a given name and a family name or 78surname. (ok: A. U. Thor, Sam Samuelsson, robert a. heinlein; not ok: 79xXthorXx, Sam, RAH) 80 81## Sending Patches 82 83Like most projects in OpenBMC, we use Gerrit to review patches. Please check 84the MAINTAINERS file to determine who needs to approve your review in order for 85your change to be merged. Submitters will need to manually add their reviewers 86in Gerrit; reviewers are not currently added automatically. Maintainers may not 87see the commit if they have not been added to the review! 88 89## Pace of Review 90 91Contributors who are used to code reviews by their team internal to their own 92company, or who are not used to code reviews at all, are sometimes surprised by 93the pace of code reviews in open source projects. Try to keep in mind that those 94reviewing your patch may be contributing to OpenBMC in a volunteer or 95partial-time capacity, may be in a timezone far removed from your own, and may 96have very deep review queues already of patches which have been waiting longer 97than yours. 98 99If you feel your patch has been missed entirely, of course it's 100alright to email the maintainers (addresses available in MAINTAINERS file) - but 101a reasonable timeframe to do so is on the order of a week, not on the order of 102hours. 103 104Additionally, the IPMI stack has a set of policies for when and how changes can 105be approved; please check the MAINTAINERS file for the full list ("Change 106approval rules"). 107 108The maintainers' job is to ensure that incoming patches are as correct and easy 109to maintain as possible. Part of the nature of open source is attrition - 110contributors can come and go easily - so maintainers tend not to put stock in 111promises such as "I will add unit tests in a later patch" or "I will be 112implementing this proposal by the end of next month." This often manifests as 113reviews which may seem harsh or exacting; please keep in mind that the community 114is trying to collaborate with you to build a patch that will benefit the project 115on its own. 116 117## Code of Conduct 118 119We enthusiastically adhere to the same 120[Code of Conduct](https://github.com/openbmc/docs/blob/master/code-of-conduct.md) 121as the rest of OpenBMC. If you have any concerns, please check that document for 122guidelines on who can help you resolve them. 123