CONTRIBUTING.asciidoc 10 KB

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