CONTRIBUTING.asciidoc 11 KB

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