Debian Codegraph @

CONTRIBUTING.asciidoc

raw
1 = Contributing
2
3 This document is a guide on how to best contribute to this project.
4
5 == Definitions
6
7 *SHOULD* describes optional steps. *MUST* describes mandatory steps.
8
9 *SHOULD NOT* and *MUST NOT* describes pitfalls to avoid.
10
11 _Your local copy_ refers to the copy of the repository that you have
12 on your computer. _origin_ refers to your fork of the project. _upstream_
13 refers to the official repository for this project.
14
15 == Discussions
16
17 For general discussion about this project, please open a ticket.
18 Feedback is always welcome and may transform in tasks to improve
19 the project, so having the discussion start there is a plus.
20
21 Alternatively you may try the https://discord.gg/x468ZsxG[Discord server]
22 or, if you need the discussion to stay private, you can send an
23 email at [email protected].
24
25 == Support
26
27 Free support is generally not available. The rule is that free
28 support is only given if doing so benefits most users. In practice
29 this means that free support will only be given if the issues are
30 due to a fault in the project itself or its documentation.
31
32 Paid support is available for all price ranges. Please send an
33 email to [email protected] for more information.
34
35 == Bug reports
36
37 You *SHOULD* open a ticket for every bug you encounter, regardless
38 of the version you use. A ticket not only helps the project ensure
39 that bugs are squashed, it also helps other users who later run
40 into this issue. You *SHOULD* give as much information as possible
41 including what commit/branch, what OS/version and so on.
42
43 You *SHOULD NOT* open a ticket if another already exists for the
44 same issue. You *SHOULD* instead either add more information by
45 commenting on it, or simply comment to inform the maintainer that
46 you are also affected. The maintainer *SHOULD* reply to every
47 new ticket when they are opened. If the maintainer didn't say
48 anything after a few days, you *SHOULD* write a new comment asking
49 for more information.
50
51 You *SHOULD* provide a reproducible test case, either in the
52 ticket or by sending a pull request and updating the test suite.
53
54 When you have a fix ready, you *SHOULD* open a pull request,
55 even if the code does not fit the requirements discussed below.
56 Providing a fix, even a dirty one, can help other users and/or
57 at least get the maintainer on the right tracks.
58
59 You *SHOULD* try to relax and be patient. Some tickets are merged
60 or fixed quickly, others aren't. There's no real rules around that.
61 You can become a paying customer if you need something fast.
62
63 == Security reports
64
65 You *SHOULD* open a ticket when you identify a DoS vulnerability
66 in this project. You *SHOULD* include the resources needed to
67 DoS the project; every project can be brought down if you have
68 the necessary resources.
69
70 You *SHOULD* send an email to [email protected] when you
71 identify a security vulnerability. If the vulnerability originates
72 from code inside Erlang/OTP itself, you *SHOULD* also consult
73 with OTP Team directly to get the problem fixed upstream.
74
75 == Feature requests
76
77 Feature requests are always welcome. To be accepted, however, they
78 must be well defined, make sense in the context of the project and
79 benefit most users.
80
81 Feature requests not benefiting most users may only be accepted
82 when accompanied with a proper pull request.
83
84 You *MUST* open a ticket to explain what the new feature is, even
85 if you are going to submit a pull request for it.
86
87 All these conditions are meant to ensure that the project stays
88 lightweight and maintainable.
89
90 == Documentation submissions
91
92 You *SHOULD* follow the code submission guidelines to submit
93 documentation.
94
95 The documentation is available in the 'doc/src/' directory. There
96 are three kinds of documentation: manual, guide and tutorials. The
97 format for the documentation is Asciidoc.
98
99 You *SHOULD* follow the same style as the surrounding documentation
100 when editing existing files.
101
102 You *MUST* include the source when providing media.
103
104 == Examples submissions
105
106 You *SHOULD* follow the code submission guidelines to submit examples.
107
108 The examples are available in the 'examples/' directory.
109
110 You *SHOULD* focus on exactly one thing per example.
111
112 == Code submissions
113
114 You *SHOULD* open a pull request to submit code.
115
116 You *SHOULD* open a ticket to discuss backward incompatible changes
117 before you submit code. This step ensures that you do not work on
118 a large change that will then be rejected.
119
120 You *SHOULD* send your code submission using a pull request on GitHub.
121 If you can't, please send an email to [email protected] with your
122 patch.
123
124 The following sections explain the normal GitHub workflow.
125
126 === Cloning
127
128 You *MUST* fork the project's repository on GitHub by clicking on the
129 _Fork_ button.
130
131 On the right page of your fork's page is a field named _SSH clone URL_.
132 Its contents will be identified as `$ORIGIN_URL` in the following snippet.
133
134 On the right side of the project's repository page is a similar field.
135 Its contents will be identified as `$UPSTREAM_URL`.
136
137 Finally, `$PROJECT` is the name of this project.
138
139 To setup your clone and be able to rebase when requested, run the
140 following commands:
141
142 [source,bash]
143 $ git clone $ORIGIN_URL
144 $ cd $PROJECT
145 $ git remote add upstream $UPSTREAM_URL
146
147 === Branching
148
149 You *SHOULD* base your branch on _master_, unless your patch applies
150 to a stable release, in which case you need to base your branch on
151 the stable branch, for example _1.0.x_.
152
153 The first step is therefore to checkout the branch in question:
154
155 [source,bash]
156 $ git checkout 1.0.x
157
158 The next step is to update the branch to the current version from
159 _upstream_. In the following snippet, replace _1.0.x_ by _master_
160 if you are patching _master_.
161
162 [source,bash]
163 $ git fetch upstream
164 $ git rebase upstream/1.0.x
165
166 This last command may fail and ask you to stash your changes. When
167 that happens, run the following sequence of commands:
168
169 [source,bash]
170 $ git stash
171 $ git rebase upstream/1.0.x
172 $ git stash pop
173
174 The final step is to create a new branch you can work in. The name
175 of the new branch is up to you, there is no particular requirement.
176 Replace `$BRANCH` with the branch name you came up with:
177
178 [source,bash]
179 $ git checkout -b $BRANCH
180
181 _Your local copy_ is now ready.
182
183 === Source editing
184
185 There are very few rules with regard to source code editing.
186
187 You *MUST* use horizontal tabs for indentation. Use one tab
188 per indentation level.
189
190 You *MUST NOT* align code. You can only add or remove one
191 indentation level compared to the previous line.
192
193 You *SHOULD NOT* write lines more than about a hundred
194 characters. There is no hard limit, just try to keep it
195 as readable as possible.
196
197 You *SHOULD* write small functions when possible.
198
199 You *SHOULD* avoid a too big hierarchy of case clauses inside
200 a single function.
201
202 You *SHOULD* add tests to make sure your code works.
203
204 === Committing
205
206 You *SHOULD* run Dialyzer and the test suite while working on
207 your patch, and you *SHOULD* ensure that no additional tests
208 fail when you finish.
209
210 You can use the following command to run Dialyzer:
211
212 [source,bash]
213 $ make dialyze
214
215 You have two options to run tests. You can either run tests
216 across all supported Erlang versions, or just on the version
217 you are currently using.
218
219 To test across all supported Erlang versions:
220
221 [source,bash]
222 $ make -k ci
223
224 To test using the current version:
225
226 [source,bash]
227 $ make tests
228
229 You can then open Common Test logs in 'logs/all_runs.html'.
230
231 By default Cowboy excludes a few test suites that take too
232 long to complete. For example all the examples are built and
233 tested, and one Websocket test suite is very extensive. In
234 order to run everything, do:
235
236 [source,bash]
237 $ make tests FULL=1
238
239 Once all tests pass (or at least, no new tests are failing),
240 you can commit your changes.
241
242 First you need to add your changes:
243
244 [source,bash]
245 $ git add src/file_you_edited.erl
246
247 If you want an interactive session, allowing you to filter
248 out changes that have nothing to do with this commit:
249
250 [source,bash]
251 $ git add -p
252
253 You *MUST* put all related changes inside a single commit. The
254 general rule is that all commits must pass tests. Fix one bug
255 per commit. Add one feature per commit. Separate features in
256 multiple commits only if smaller parts of the feature make
257 sense on their own.
258
259 Finally once all changes are added you can commit. This
260 command will open the editor of your choice where you can
261 put a proper commit title and message.
262
263 [source,bash]
264 $ git commit
265
266 Do not use the `-m` option as it makes it easy to break the
267 following rules:
268
269 You *MUST* write a proper commit title and message. The commit
270 title is the first line and *MUST* be at most 72 characters.
271 The second line *MUST* be left blank. Everything after that is
272 the commit message. You *SHOULD* write a detailed commit
273 message. The lines of the message *MUST* be at most 80 characters.
274 You *SHOULD* explain what the commit does, what references you
275 used and any other information that helps understanding why
276 this commit exists. You *MUST NOT* include commands to close
277 GitHub tickets automatically.
278
279 === Cleaning the commit history
280
281 If you create a new commit every time you make a change, however
282 insignificant, you *MUST* consolidate those commits before
283 sending the pull request.
284
285 This is done through _rebasing_. The easiest way to do so is
286 to use interactive rebasing, which allows you to choose which
287 commits to keep, squash, edit and so on. To rebase, you need
288 to give the original commit before you made your changes. If
289 you only did two changes, you can use the shortcut form `HEAD^^`:
290
291 [source,bash]
292 $ git rebase -i HEAD^^
293
294 === Submitting the pull request
295
296 You *MUST* push your branch to your fork on GitHub. Replace
297 `$BRANCH` with your branch name:
298
299 [source,bash]
300 $ git push origin $BRANCH
301
302 You can then submit the pull request using the GitHub interface.
303 You *SHOULD* provide an explanatory message and refer to any
304 previous ticket related to this patch. You *MUST NOT* include
305 commands to close other tickets automatically.
306
307 === Updating the pull request
308
309 Sometimes the maintainer will ask you to change a few things.
310 Other times you will notice problems with your submission and
311 want to fix them on your own.
312
313 In either case you do not need to close the pull request. You
314 can just push your changes again and, if needed, force them.
315 This will update the pull request automatically.
316
317 [source,bash]
318 $ git push -f origin $BRANCH
319
320 === Merging
321
322 This is an open source project maintained by independent developers.
323 Please be patient when your changes aren't merged immediately.
324
325 All pull requests run through a Continuous Integration service
326 to ensure nothing gets broken by the changes submitted.
327
328 Bug fixes will be merged immediately when all tests pass.
329 The maintainer may do style changes in the merge commit if
330 the submitter is not available. The maintainer *MUST* open
331 a new ticket if the solution could still be improved.
332
333 New features and backward incompatible changes will be merged
334 when all tests pass and all other requirements are fulfilled.