]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - .github/CONTRIBUTING.md
Improve tests documentation
[github/Chocobozzz/PeerTube.git] / .github / CONTRIBUTING.md
CommitLineData
7a7edb72
C
1# Welcome to the contributing guide for PeerTube
2
71607e4a 3Interested in contributing? Awesome!
7a7edb72 4
e2266e4f 5**This guide will present you the following contribution topics:**
7a7edb72 6
17b07dc5
C
7<!-- START doctoc generated TOC please keep comment here to allow auto update -->
8<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9
10
11- [Translate](#translate)
12- [Give your feedback](#give-your-feedback)
13- [Write documentation](#write-documentation)
14- [Improve the website](#improve-the-website)
15- [Develop](#develop)
16 - [Prerequisites](#prerequisites)
17 - [Online development](#online-development)
18 - [Server side](#server-side)
19 - [Client side](#client-side)
20 - [Client and server side](#client-and-server-side)
4f97f583
C
21 - [RTL layout](#rtl-layout)
22 - [Testing](#testing)
23 - [Unit tests](#unit-tests)
24 - [Testing the federation of PeerTube servers](#testing-the-federation-of-peertube-servers)
17b07dc5
C
25 - [Emails](#emails)
26- [Plugins & Themes](#plugins--themes)
27
28<!-- END doctoc generated TOC please keep comment here to allow auto update -->
7a7edb72 29
6a1787c1
C
30## Translate
31
32You can help us to translate the PeerTube interface to many languages! See [the documentation](/support/doc/translation.md) to know how.
33
34
7a7edb72
C
35## Give your feedback
36
e755a63a
BB
37You don't need to know how to code to start contributing to PeerTube! Other
38contributions are very valuable too, among which: you can test the software and
39report bugs, you can give feedback on potential bugs, features that you are
63bfad7e 40interested in, user interface, design, decentralized architecture...
7a7edb72
C
41
42
63bfad7e 43## Write documentation
7a7edb72 44
63bfad7e 45You can help to write the documentation of the REST API, code, architecture,
d59a8da8
C
46demonstrations.
47
0ceadb35 48For the REST API you can see the documentation in [/support/doc/api](https://github.com/Chocobozzz/PeerTube/tree/develop/support/doc/api) directory.
17b07dc5 49Then, you can just open the `openapi.yaml` file in a special editor like [http://editor.swagger.io/](http://editor.swagger.io/) to easily see and edit the documentation. You can also use [redoc-cli](https://github.com/Redocly/redoc/blob/master/cli/README.md) and run `redoc-cli serve --watch support/doc/api/openapi.yaml` to see the final result.
d59a8da8
C
50
51Some hints:
0ceadb35
C
52 * Routes are defined in [/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/controllers) directory
53 * Parameters validators are defined in [/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/middlewares/validators) directory
54 * Models sent/received by the controllers are defined in [/shared/models](https://github.com/Chocobozzz/PeerTube/tree/develop/shared/models) directory
d59a8da8 55
7a7edb72 56
0e62b72b
TK
57## Improve the website
58
59PeerTube's website is [joinpeertube.org](https://joinpeertube.org), where people can learn about the project and how it works – note that it is not a PeerTube instance, but rather the project's homepage.
60
61You can help us improve it too!
62
63It is not hosted on GitHub but on [Framasoft](https://framasoft.org/)'s own [GitLab](https://about.gitlab.com/) instance, [FramaGit](https://framagit.org): https://framagit.org/framasoft/peertube/joinpeertube
64
65
63bfad7e 66## Develop
7a7edb72 67
a3e6d181
RK
68Always talk about features you want to develop by creating/finding and commenting the issue tackling your problem
69before you start working on it, and inform the community that you begin coding by claiming the issue.
70
71Once you are ready to show your code to ask for feedback, submit a *draft* Pull Request.
72Once you are ready for a code review before merge, submit a Pull Request. In any case, please
73link your PR to the issues it solves by using the GitHub syntax: "fixes #issue_number".
7a7edb72 74
63bfad7e 75### Prerequisites
7a7edb72 76
a43e2182 77First, you should use a server or PC with at least 4GB of RAM. Less RAM may lead to crashes.
78
05e85b59 791) Make sure that you have followed
0cfcbae8 80[the steps](/support/doc/dependencies.md)
6676056a 81to install the dependencies.
05e85b59 821) Install [parallel](https://www.gnu.org/software/parallel/) to be able to run tests.
831) Fork the Github repository.
841) Run the following commands.
afe81767 85```
b30acc0e 86$ git clone https://github.com/Chocobozzz/PeerTube
63bfad7e 87$ cd PeerTube
b4bc269e 88$ git remote add me git@github.com:YOUR_GITHUB_USERNAME/PeerTube.git
63bfad7e
C
89$ yarn install --pure-lockfile
90```
e755a63a 91
dd07afa5
FA
92Note that development is done on the `develop` branch. If you want to hack on
93Peertube, you should switch to that branch. Also note that you have to repeat
94the `yarn install --pure-lockfile` command.
95
b30acc0e
J
96When you create a new branch you should also tell to use your repo for upload
97not default one. To do just do:
98```
99$ git push --set-upstream me <your branch name>
100```
101
e755a63a
BB
102Then, create a postgres database and user with the values set in the
103`config/default.yaml` file. For instance, if you do not change the values
104there, the following commands would create a new database called `peertube_dev`
105and a postgres user called `peertube` with password `peertube`:
106
afe81767 107```
63bfad7e
C
108# sudo -u postgres createuser -P peertube
109Enter password for new role: peertube
110# sudo -u postgres createdb -O peertube peertube_dev
e755a63a
BB
111```
112
dd07afa5
FA
113Then enable extensions PeerTube needs:
114
115```
116$ sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" peertube_dev
117$ sudo -u postgres psql -c "CREATE EXTENSION unaccent;" peertube_dev
118```
119
63bfad7e
C
120In dev mode, administrator username is **root** and password is **test**.
121
0cfcbae8
JK
122### Online development
123
124You can get a complete PeerTube development setup with Gitpod, a free one-click online IDE for GitHub:
125
126[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/Chocobozzz/PeerTube)
127
e755a63a
BB
128### Server side
129
46e9407c 130You can find a documentation of the server code/architecture [here](https://docs.joinpeertube.org/#/contribute-architecture?id=server-code).
63bfad7e 131
e755a63a
BB
132To develop on the server-side:
133
afe81767 134```
63bfad7e 135$ npm run dev:server
e755a63a
BB
136```
137
138Then, the server will listen on `localhost:9000`. When server source files
139change, these are automatically recompiled and the server will automatically
19096851 140restart.
e755a63a
BB
141
142### Client side
143
838f4a79 144You can find a documentation of the client code/architecture
46e9407c 145[here](https://docs.joinpeertube.org/#/contribute-architecture?id=client-code).
63bfad7e
C
146
147
e755a63a
BB
148To develop on the client side:
149
afe81767 150```
63bfad7e 151$ npm run dev:client
e755a63a
BB
152```
153
154The API will listen on `localhost:9000` and the frontend on `localhost:3000`.
155Client files are automatically compiled on change, and the web browser will
156reload them automatically thanks to hot module replacement.
7a7edb72 157
19096851
C
158### Client and server side
159
160The API will listen on `localhost:9000` and the frontend on `localhost:3000`.
161File changes are automatically recompiled, injected in the web browser (no need to refresh manually)
162and the web server is automatically restarted.
163
164```
165$ npm run dev
166```
167
27bc9586
C
168### RTL layout
169
170To test RTL layout using `ar` locale:
171
172```
173$ npm run dev -- --ar-locale
174```
175
a3e6d181
RK
176### Testing
177
9883e60f
C
178#### Unit/integration tests
179
a3e6d181
RK
180Your code contributions must pass the tests before they can be merged. Tests ensure most of the application behaves
181as expected and respect the syntax conventions. They will run upon PR submission as part of our CI, but running them beforehand yourself will get you faster feedback and save CI runner time for others.
182
9883e60f 183See the [dedicated documentation](/support/doc/development/tests.md) to run tests locally.
19096851 184
a3e6d181 185#### Testing the federation of PeerTube servers
19096851 186
a9ab599e
C
187Create a PostgreSQL user **with the same name as your username** in order to avoid using the *postgres* user.
188Then, we can create the databases (if they don't already exist):
a2897212
C
189
190```
a3e6d181
RK
191$ sudo -u postgres createuser you_username --createdb
192$ createdb -O peertube peertube_test{1,2,3}
a2897212
C
193```
194
a3e6d181 195Build the application and flush the old tests data:
19096851
C
196
197```
4f97f583 198$ npm run build
a3e6d181 199$ npm run clean:server:test
19096851 200```
76434ec8 201
4f97f583 202To run 3 nodes:
76434ec8
C
203
204```
4f97f583
C
205$ NODE_APP_INSTANCE=1 NODE_ENV=test npm start
206$ NODE_APP_INSTANCE=2 NODE_ENV=test npm start
207$ NODE_APP_INSTANCE=3 NODE_ENV=test npm start
76434ec8 208```
dbe868c0 209
a3e6d181
RK
210Then you will get access to the three nodes at `http://localhost:900{1,2,3}`
211with the `root` as username and `test{1,2,3}` for the password.
212
213Instance configurations are in `config/test-{1,2,3}.yaml`.
bfa1a32b 214
17b07dc5
C
215### Emails
216
217To test emails with PeerTube:
218
219 * Run [mailslurper](http://mailslurper.com/)
220 * Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=test npm start`
221
bfa1a32b
C
222## Plugins & Themes
223
224See the dedicated documentation: https://docs.joinpeertube.org/#/contribute-plugins