CONTRIBUTING.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. Contributing code to Matrix
  2. ===========================
  3. Everyone is welcome to contribute code to Matrix
  4. (https://github.com/matrix-org), provided that they are willing to license
  5. their contributions under the same license as the project itself. We follow a
  6. simple 'inbound=outbound' model for contributions: the act of submitting an
  7. 'inbound' contribution means that the contributor agrees to license the code
  8. under the same terms as the project's overall 'outbound' license - in our
  9. case, this is almost always Apache Software License v2 (see LICENSE).
  10. How to contribute
  11. ~~~~~~~~~~~~~~~~~
  12. The preferred and easiest way to contribute changes to Matrix is to fork the
  13. relevant project on github, and then create a pull request to ask us to pull
  14. your changes into our repo
  15. (https://help.github.com/articles/using-pull-requests/)
  16. **The single biggest thing you need to know is: please base your changes on
  17. the develop branch - /not/ master.**
  18. We use the master branch to track the most recent release, so that folks who
  19. blindly clone the repo and automatically check out master get something that
  20. works. Develop is the unstable branch where all the development actually
  21. happens: the workflow is that contributors should fork the develop branch to
  22. make a 'feature' branch for a particular contribution, and then make a pull
  23. request to merge this back into the matrix.org 'official' develop branch. We
  24. use github's pull request workflow to review the contribution, and either ask
  25. you to make any refinements needed or merge it and make them ourselves. The
  26. changes will then land on master when we next do a release.
  27. We use `Buildkite <https://buildkite.com/matrix-dot-org/synapse>`_ for
  28. continuous integration. Buildkite builds need to be authorised by a
  29. maintainer. If your change breaks the build, this will be shown in GitHub, so
  30. please keep an eye on the pull request for feedback.
  31. To run unit tests in a local development environment, you can use:
  32. - ``tox -e py35`` (requires tox to be installed by ``pip install tox``)
  33. for SQLite-backed Synapse on Python 3.5.
  34. - ``tox -e py36`` for SQLite-backed Synapse on Python 3.6.
  35. - ``tox -e py36-postgres`` for PostgreSQL-backed Synapse on Python 3.6
  36. (requires a running local PostgreSQL with access to create databases).
  37. - ``./test_postgresql.sh`` for PostgreSQL-backed Synapse on Python 3.5
  38. (requires Docker). Entirely self-contained, recommended if you don't want to
  39. set up PostgreSQL yourself.
  40. Docker images are available for running the integration tests (SyTest) locally,
  41. see the `documentation in the SyTest repo
  42. <https://github.com/matrix-org/sytest/blob/develop/docker/README.md>`_ for more
  43. information.
  44. Code style
  45. ~~~~~~~~~~
  46. All Matrix projects have a well-defined code-style - and sometimes we've even
  47. got as far as documenting it... For instance, synapse's code style doc lives
  48. at https://github.com/matrix-org/synapse/tree/master/docs/code_style.md.
  49. To facilitate meeting these criteria you can run ``scripts-dev/lint.sh``
  50. locally. Since this runs the tools listed in the above document, you'll need
  51. python 3.6 and to install each tool. **Note that the script does not just
  52. test/check, but also reformats code, so you may wish to ensure any new code is
  53. committed first**. By default this script checks all files and can take some
  54. time; if you alter only certain files, you might wish to specify paths as
  55. arguments to reduce the run-time.
  56. Please ensure your changes match the cosmetic style of the existing project,
  57. and **never** mix cosmetic and functional changes in the same commit, as it
  58. makes it horribly hard to review otherwise.
  59. Before doing a commit, ensure the changes you've made don't produce
  60. linting errors. You can do this by running the linters as follows. Ensure to
  61. commit any files that were corrected.
  62. ::
  63. # Install the dependencies
  64. pip install -U black flake8 isort
  65. # Run the linter script
  66. ./scripts-dev/lint.sh
  67. Changelog
  68. ~~~~~~~~~
  69. All changes, even minor ones, need a corresponding changelog / newsfragment
  70. entry. These are managed by Towncrier
  71. (https://github.com/hawkowl/towncrier).
  72. To create a changelog entry, make a new file in the ``changelog.d`` file named
  73. in the format of ``PRnumber.type``. The type can be one of the following:
  74. * ``feature``.
  75. * ``bugfix``.
  76. * ``docker`` (for updates to the Docker image).
  77. * ``doc`` (for updates to the documentation).
  78. * ``removal`` (also used for deprecations).
  79. * ``misc`` (for internal-only changes).
  80. The content of the file is your changelog entry, which should be a short
  81. description of your change in the same style as the rest of our `changelog
  82. <https://github.com/matrix-org/synapse/blob/master/CHANGES.md>`_. The file can
  83. contain Markdown formatting, and should end with a full stop ('.') for
  84. consistency.
  85. Adding credits to the changelog is encouraged, we value your
  86. contributions and would like to have you shouted out in the release notes!
  87. For example, a fix in PR #1234 would have its changelog entry in
  88. ``changelog.d/1234.bugfix``, and contain content like "The security levels of
  89. Florbs are now validated when recieved over federation. Contributed by Jane
  90. Matrix.".
  91. Debian changelog
  92. ----------------
  93. Changes which affect the debian packaging files (in ``debian``) are an
  94. exception.
  95. In this case, you will need to add an entry to the debian changelog for the
  96. next release. For this, run the following command::
  97. dch
  98. This will make up a new version number (if there isn't already an unreleased
  99. version in flight), and open an editor where you can add a new changelog entry.
  100. (Our release process will ensure that the version number and maintainer name is
  101. corrected for the release.)
  102. If your change affects both the debian packaging *and* files outside the debian
  103. directory, you will need both a regular newsfragment *and* an entry in the
  104. debian changelog. (Though typically such changes should be submitted as two
  105. separate pull requests.)
  106. Sign off
  107. ~~~~~~~~
  108. In order to have a concrete record that your contribution is intentional
  109. and you agree to license it under the same terms as the project's license, we've adopted the
  110. same lightweight approach that the Linux Kernel
  111. `submitting patches process <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin>`_, Docker
  112. (https://github.com/docker/docker/blob/master/CONTRIBUTING.md), and many other
  113. projects use: the DCO (Developer Certificate of Origin:
  114. http://developercertificate.org/). This is a simple declaration that you wrote
  115. the contribution or otherwise have the right to contribute it to Matrix::
  116. Developer Certificate of Origin
  117. Version 1.1
  118. Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
  119. 660 York Street, Suite 102,
  120. San Francisco, CA 94110 USA
  121. Everyone is permitted to copy and distribute verbatim copies of this
  122. license document, but changing it is not allowed.
  123. Developer's Certificate of Origin 1.1
  124. By making a contribution to this project, I certify that:
  125. (a) The contribution was created in whole or in part by me and I
  126. have the right to submit it under the open source license
  127. indicated in the file; or
  128. (b) The contribution is based upon previous work that, to the best
  129. of my knowledge, is covered under an appropriate open source
  130. license and I have the right under that license to submit that
  131. work with modifications, whether created in whole or in part
  132. by me, under the same open source license (unless I am
  133. permitted to submit under a different license), as indicated
  134. in the file; or
  135. (c) The contribution was provided directly to me by some other
  136. person who certified (a), (b) or (c) and I have not modified
  137. it.
  138. (d) I understand and agree that this project and the contribution
  139. are public and that a record of the contribution (including all
  140. personal information I submit with it, including my sign-off) is
  141. maintained indefinitely and may be redistributed consistent with
  142. this project or the open source license(s) involved.
  143. If you agree to this for your contribution, then all that's needed is to
  144. include the line in your commit or pull request comment::
  145. Signed-off-by: Your Name <your@email.example.org>
  146. We accept contributions under a legally identifiable name, such as
  147. your name on government documentation or common-law names (names
  148. claimed by legitimate usage or repute). Unfortunately, we cannot
  149. accept anonymous contributions at this time.
  150. Git allows you to add this signoff automatically when using the ``-s``
  151. flag to ``git commit``, which uses the name and email set in your
  152. ``user.name`` and ``user.email`` git configs.
  153. Conclusion
  154. ~~~~~~~~~~
  155. That's it! Matrix is a very open and collaborative project as you might expect
  156. given our obsession with open communication. If we're going to successfully
  157. matrix together all the fragmented communication technologies out there we are
  158. reliant on contributions and collaboration from the community to do so. So
  159. please get involved - and we hope you have as much fun hacking on Matrix as we
  160. do!