Skip to content

Commit 163f768

Browse files
authored
Add CONTRIBUTING.md (#24)
Closes #20
1 parent c734157 commit 163f768

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Pull Request Checklist
2+
3+
* [ ] Pull request includes a [sign off](https://github.com/matrix-org/matrix-python-common/blob/main/CONTRIBUTING.md#sign-off)

CONTRIBUTING.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Contributing code to matrix-python-common
2+
3+
Everyone is welcome to contribute code to matrix-python-common, provided you are
4+
willing to license your contributions under the same license as the project
5+
itself. In this case, the [Apache Software License v2](LICENSE).
6+
7+
## Set up your development environment
8+
9+
To contribute to matrix-python-common, ensure you have Python 3.7 and `git`
10+
available on your system. You'll need to clone the source code first:
11+
12+
```shell
13+
git clone https://github.com/matrix-org/matrix-python-common.git
14+
```
15+
16+
## Create a virtualenv
17+
18+
To contribute to matrix-python-common, ensure you have Python 3.7 or newer and
19+
then run:
20+
21+
```bash
22+
python3 -m venv .venv
23+
.venv/bin/pip install -e .[dev]
24+
```
25+
26+
This creates an isolated virtual Python environment ("virtualenv") just for
27+
use with matrix-python-common, then installs matrix-python-common along with its
28+
dependencies, and lastly installs a handful of useful tools
29+
30+
Finally, activate the virtualenv by running:
31+
32+
```bash
33+
source .venv/bin/activate
34+
```
35+
36+
Be sure to do this _every time_ you open a new terminal window for working on
37+
matrix-python-common. Activating the venv ensures that any Python commands you
38+
run (`pip`, `python`, etc.) use the versions inside your venv, and not your
39+
system Python.
40+
41+
When you're done, you can close your terminal or run `deactivate` to disable
42+
the virtualenv.
43+
44+
## Run the unit tests
45+
46+
To make sure everything is working as expected, run the unit tests:
47+
48+
```bash
49+
tox -e py
50+
```
51+
52+
If you see a message like:
53+
54+
```
55+
-------------------------------------------------------------------------------
56+
Ran 25 tests in 0.324s
57+
58+
PASSED (successes=25)
59+
```
60+
61+
Then all is well and you're ready to work!
62+
63+
## How to contribute
64+
65+
The preferred and easiest way to contribute changes is to fork the relevant
66+
project on github, and then [create a pull request](
67+
https://help.github.com/articles/using-pull-requests/) to ask us to pull your
68+
changes into our repo.
69+
70+
Some other points to follow:
71+
72+
* Please base your changes on the `main` branch.
73+
74+
* Please follow the [code style requirements](
75+
#code-style-and-continuous-integration).
76+
77+
* Please [sign off](#sign-off) your contribution.
78+
79+
* Please keep an eye on the pull request for feedback from the [continuous
80+
integration system](#code-style-and-continuous-integration) and try to fix
81+
any errors that come up.
82+
83+
* If you need to [update your PR](#updating-your-pull-request), just add new
84+
commits to your branch rather than rebasing.
85+
86+
## Code style and continuous integration
87+
88+
matrix-python-common uses `black`, `isort` and `flake8` to enforce code style.
89+
Use the following script to enforce these style guides:
90+
91+
```shell
92+
scripts-dev/lint.sh
93+
```
94+
95+
(This also runs `mypy`, our preferred typechecker.)
96+
97+
All of these checks are automatically run against any pull request via GitHub
98+
Actions. If your change breaks the build, this
99+
will be shown in GitHub, with links to the build results. If your build fails,
100+
please try to fix the errors and update your branch.
101+
102+
## Sign off
103+
104+
In order to have a concrete record that your contribution is intentional
105+
and you agree to license it under the same terms as the project's license, we've
106+
adopted the same lightweight approach that the Linux Kernel
107+
[submitting patches process](
108+
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin>),
109+
[Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md), and many
110+
other projects use: the DCO (Developer Certificate of Origin:
111+
https://developercertificate.org/). This is a simple declaration that you wrote
112+
the contribution or otherwise have the right to contribute it to Matrix:
113+
114+
```
115+
Developer Certificate of Origin
116+
Version 1.1
117+
118+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
119+
660 York Street, Suite 102,
120+
San Francisco, CA 94110 USA
121+
122+
Everyone is permitted to copy and distribute verbatim copies of this
123+
license document, but changing it is not allowed.
124+
125+
Developer's Certificate of Origin 1.1
126+
127+
By making a contribution to this project, I certify that:
128+
129+
(a) The contribution was created in whole or in part by me and I
130+
have the right to submit it under the open source license
131+
indicated in the file; or
132+
133+
(b) The contribution is based upon previous work that, to the best
134+
of my knowledge, is covered under an appropriate open source
135+
license and I have the right under that license to submit that
136+
work with modifications, whether created in whole or in part
137+
by me, under the same open source license (unless I am
138+
permitted to submit under a different license), as indicated
139+
in the file; or
140+
141+
(c) The contribution was provided directly to me by some other
142+
person who certified (a), (b) or (c) and I have not modified
143+
it.
144+
145+
(d) I understand and agree that this project and the contribution
146+
are public and that a record of the contribution (including all
147+
personal information I submit with it, including my sign-off) is
148+
maintained indefinitely and may be redistributed consistent with
149+
this project or the open source license(s) involved.
150+
```
151+
152+
If you agree to this for your contribution, then all that's needed is to
153+
include the line in your commit or pull request comment:
154+
155+
```
156+
Signed-off-by: Your Name <your@email.example.org>
157+
```
158+
159+
We accept contributions under a legally identifiable name, such as
160+
your name on government documentation or common-law names (names
161+
claimed by legitimate usage or repute). Unfortunately, we cannot
162+
accept anonymous contributions at this time.
163+
164+
Git allows you to add this signoff automatically when using the `-s`
165+
flag to `git commit`, which uses the name and email set in your
166+
`user.name` and `user.email` git configs.
167+
168+
169+
## Updating your pull request
170+
171+
If you decide to make changes to your pull request - perhaps to address issues
172+
raised in a review, or to fix problems highlighted by [continuous
173+
integration](#continuous-integration-and-testing) - just add new commits to your
174+
branch, and push to GitHub. The pull request will automatically be updated.
175+
176+
Please **avoid** rebasing your branch, especially once the PR has been
177+
reviewed: doing so makes it very difficult for a reviewer to see what has
178+
changed since a previous review.
179+
180+
## Conclusion
181+
182+
That's it! Matrix is a very open and collaborative project as you might expect
183+
given our obsession with open communication. If we're going to successfully
184+
matrix together all the fragmented communication technologies out there we are
185+
reliant on contributions and collaboration from the community to do so. So
186+
please get involved - and we hope you have as much fun hacking on Matrix as we
187+
do!

0 commit comments

Comments
 (0)