CONTRIBUTING.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. = Contributing
  2. This document is a guide on how to best contribute to this project.
  3. == Definitions
  4. *SHOULD* describes optional steps. *MUST* describes mandatory steps.
  5. *SHOULD NOT* and *MUST NOT* describes pitfalls to avoid.
  6. _Your local copy_ refers to the copy of the repository that you have
  7. on your computer. _origin_ refers to your fork of the project. _upstream_
  8. refers to the official repository for this project.
  9. == Discussions
  10. For general discussion about this project, please open a ticket.
  11. Feedback is always welcome and may transform in tasks to improve
  12. the project, so having the discussion start there is a plus.
  13. Alternatively you may try the #ninenines IRC channel on Freenode,
  14. or, if you need the discussion to stay private, you can send an
  15. email at contact@ninenines.eu.
  16. == Support
  17. Free support is generally not available. The rule is that free
  18. support is only given if doing so benefits most users. In practice
  19. this means that free support will only be given if the issues are
  20. due to a fault in the project itself or its documentation.
  21. Paid support is available for all price ranges. Please send an
  22. email to contact@ninenines.eu for more information.
  23. == Bug reports
  24. You *SHOULD* open a ticket for every bug you encounter, regardless
  25. of the version you use. A ticket not only helps the project ensure
  26. that bugs are squashed, it also helps other users who later run
  27. into this issue. You *SHOULD* give as much information as possible
  28. including what commit/branch, what OS/version and so on.
  29. You *SHOULD NOT* open a ticket if another already exists for the
  30. same issue. You *SHOULD* instead either add more information by
  31. commenting on it, or simply comment to inform the maintainer that
  32. you are also affected. The maintainer *SHOULD* reply to every
  33. new ticket when they are opened. If the maintainer didn't say
  34. anything after a few days, you *SHOULD* write a new comment asking
  35. for more information.
  36. When you have a fix ready, you *SHOULD* open a pull request,
  37. even if the code does not fit the requirements discussed below.
  38. Providing a fix, even a dirty one, can help other users and/or
  39. at least get the maintainer on the right tracks.
  40. == Security reports
  41. You *SHOULD* open a ticket when you identify a DoS vulnerability
  42. in this project. You *SHOULD* include the resources needed to
  43. DoS the project; every project can be brought down if you have
  44. the necessary resources.
  45. You *SHOULD* send an email to contact@ninenines.eu when you
  46. identify a security vulnerability. If the vulnerability originates
  47. from code inside Erlang/OTP itself, you *SHOULD* also consult
  48. with OTP Team directly to get the problem fixed upstream.
  49. == Feature requests
  50. Feature requests are always welcome. To be accepted, however, they
  51. must be well defined, make sense in the context of the project and
  52. benefit most users.
  53. Feature requests not benefiting most users may only be accepted
  54. when accompanied with a proper pull request.
  55. You *MUST* open a ticket to explain what the new feature is, even
  56. if you are going to submit a pull request for it.
  57. All these conditions are meant to ensure that the project stays
  58. lightweight and maintainable.
  59. == Documentation submissions
  60. You *SHOULD* follow the code submission guidelines to submit
  61. documentation.
  62. The documentation is available in the 'doc/src/' directory. There
  63. are three kinds of documentation: manual, guide and tutorials. The
  64. format for the documentation is Asciidoc.
  65. You *SHOULD* follow the same style as the surrounding documentation
  66. when editing existing files.
  67. You *MUST* include the source when providing media.
  68. == Examples submissions
  69. You *SHOULD* follow the code submission guidelines to submit examples.
  70. The examples are available in the 'examples/' directory.
  71. You *SHOULD* focus on exactly one thing per example.
  72. == Code submissions
  73. You *SHOULD* open a pull request to submit code.
  74. You *SHOULD* open a ticket to discuss backward incompatible changes
  75. before you submit code. This step ensures that you do not work on
  76. a large change that will then be rejected.
  77. You *SHOULD* send your code submission using a pull request on GitHub.
  78. If you can't, please send an email to contact@ninenines.eu with your
  79. patch.
  80. The following sections explain the normal GitHub workflow.
  81. === Cloning
  82. You *MUST* fork the project's repository on GitHub by clicking on the
  83. _Fork_ button.
  84. On the right page of your fork's page is a field named _SSH clone URL_.
  85. Its contents will be identified as `$ORIGIN_URL` in the following snippet.
  86. On the right side of the project's repository page is a similar field.
  87. Its contents will be identified as `$UPSTREAM_URL`.
  88. Finally, `$PROJECT` is the name of this project.
  89. To setup your clone and be able to rebase when requested, run the
  90. following commands:
  91. [source,bash]
  92. $ git clone $ORIGIN_URL
  93. $ cd $PROJECT
  94. $ git remote add upstream $UPSTREAM_URL
  95. === Branching
  96. You *SHOULD* base your branch on _master_, unless your patch applies
  97. to a stable release, in which case you need to base your branch on
  98. the stable branch, for example _1.0.x_.
  99. The first step is therefore to checkout the branch in question:
  100. [source,bash]
  101. $ git checkout 1.0.x
  102. The next step is to update the branch to the current version from
  103. _upstream_. In the following snippet, replace _1.0.x_ by _master_
  104. if you are patching _master_.
  105. [source,bash]
  106. $ git fetch upstream
  107. $ git rebase upstream/1.0.x
  108. This last command may fail and ask you to stash your changes. When
  109. that happens, run the following sequence of commands:
  110. [source,bash]
  111. $ git stash
  112. $ git rebase upstream/1.0.x
  113. $ git stash pop
  114. The final step is to create a new branch you can work in. The name
  115. of the new branch is up to you, there is no particular requirement.
  116. Replace `$BRANCH` with the branch name you came up with:
  117. [source,bash]
  118. $ git checkout -b $BRANCH
  119. _Your local copy_ is now ready.
  120. === Source editing
  121. There are very few rules with regard to source code editing.
  122. You *MUST* use horizontal tabs for indentation. Use one tab
  123. per indentation level.
  124. You *MUST NOT* align code. You can only add or remove one
  125. indentation level compared to the previous line.
  126. You *SHOULD NOT* write lines more than about a hundred
  127. characters. There is no hard limit, just try to keep it
  128. as readable as possible.
  129. You *SHOULD* write small functions when possible.
  130. You *SHOULD* avoid a too big hierarchy of case clauses inside
  131. a single function.
  132. You *SHOULD* add tests to make sure your code works.
  133. === Committing
  134. You *SHOULD* run Dialyzer and the test suite while working on
  135. your patch, and you *SHOULD* ensure that no additional tests
  136. fail when you finish.
  137. You can use the following command to run Dialyzer:
  138. [source,bash]
  139. $ make dialyze
  140. You have two options to run tests. You can either run tests
  141. across all supported Erlang versions, or just on the version
  142. you are currently using.
  143. To test across all supported Erlang versions:
  144. [source,bash]
  145. $ make -k ci
  146. To test using the current version:
  147. [source,bash]
  148. $ make tests
  149. You can then open Common Test logs in 'logs/all_runs.html'.
  150. Once all tests pass (or at least, no new tests are failing),
  151. you can commit your changes.
  152. First you need to add your changes:
  153. [source,bash]
  154. $ git add src/file_you_edited.erl
  155. If you want an interactive session, allowing you to filter
  156. out changes that have nothing to do with this commit:
  157. [source,bash]
  158. $ git add -p
  159. You *MUST* put all related changes inside a single commit. The
  160. general rule is that all commits must pass tests. Fix one bug
  161. per commit. Add one feature per commit. Separate features in
  162. multiple commits only if smaller parts of the feature make
  163. sense on their own.
  164. Finally once all changes are added you can commit. This
  165. command will open the editor of your choice where you can
  166. put a proper commit title and message.
  167. [source,bash]
  168. $ git commit
  169. Do not use the `-m` option as it makes it easy to break the
  170. following rules:
  171. You *MUST* write a proper commit title and message. The commit
  172. title is the first line and *MUST* be at most 72 characters.
  173. The second line *MUST* be left blank. Everything after that is
  174. the commit message. You *SHOULD* write a detailed commit
  175. message. The lines of the message *MUST* be at most 80 characters.
  176. You *SHOULD* explain what the commit does, what references you
  177. used and any other information that helps understanding why
  178. this commit exists. You *MUST NOT* include commands to close
  179. GitHub tickets automatically.
  180. === Cleaning the commit history
  181. If you create a new commit every time you make a change, however
  182. insignificant, you *MUST* consolidate those commits before
  183. sending the pull request.
  184. This is done through _rebasing_. The easiest way to do so is
  185. to use interactive rebasing, which allows you to choose which
  186. commits to keep, squash, edit and so on. To rebase, you need
  187. to give the original commit before you made your changes. If
  188. you only did two changes, you can use the shortcut form `HEAD^^`:
  189. [source,bash]
  190. $ git rebase -i HEAD^^
  191. === Submitting the pull request
  192. You *MUST* push your branch to your fork on GitHub. Replace
  193. `$BRANCH` with your branch name:
  194. [source,bash]
  195. $ git push origin $BRANCH
  196. You can then submit the pull request using the GitHub interface.
  197. You *SHOULD* provide an explanatory message and refer to any
  198. previous ticket related to this patch. You *MUST NOT* include
  199. commands to close other tickets automatically.
  200. === Updating the pull request
  201. Sometimes the maintainer will ask you to change a few things.
  202. Other times you will notice problems with your submission and
  203. want to fix them on your own.
  204. In either case you do not need to close the pull request. You
  205. can just push your changes again and, if needed, force them.
  206. This will update the pull request automatically.
  207. [source,bash]
  208. $ git push -f origin $BRANCH
  209. === Merging
  210. This is an open source project maintained by independent developers.
  211. Please be patient when your changes aren't merged immediately.
  212. All pull requests run through a Continuous Integration service
  213. to ensure nothing gets broken by the changes submitted.
  214. Bug fixes will be merged immediately when all tests pass.
  215. The maintainer may do style changes in the merge commit if
  216. the submitter is not available. The maintainer *MUST* open
  217. a new ticket if the solution could still be improved.
  218. New features and backward incompatible changes will be merged
  219. when all tests pass and all other requirements are fulfilled.