Added contribution guidelines.
[platform/core/csapi/opentk.git] / CONTRIBUTING.md
1 # Contribution guidelines for OpenTK
2
3 ## Preface
4 First of all, thank you for considering contributing to the OpenTK project! It's a large codebase
5 with a lot of twists and turns, and a helping hand is always welcome.
6
7 There are multiple ways to contribue to the project - creating bug reports, opening pull requests, 
8 commenting on either and engaging in discussions about other contributions to name a few. This
9 document is intented as a set of guidelines to help your contribution get accepted faster, maintain
10 a high standard, and to help us (the maintainers) set a few ground rules for working with us.
11
12 If you have any questions about the contents of this document, the code, or how to contribute, please
13 drop us a line on [Gitter](https://gitter.im/opentk/opentk). We'll be happy to answer as best we can.
14
15 #### Table of Contents
16 1. [Things to keep in mind](#things-to-keep-in-mind)
17 2. [Setting Up](#setting-up)
18 3. [Pull Requests](#pull-requests)
19         1. [Bug Fixes](#bug-fixes)
20         2. [New Features](#new-features)
21         3. [Cosmetic & Stylistic Changes](#cosmetic-&-stylistic-changes)
22         4. [Breaking Changes](#breaking-changes)
23 4. [Bug Reports](#bug-reports)
24 5. [Discussions & Suggestions](#discussions-&-suggestions)
25
26
27 ## Things to keep in mind
28 Like a lot of other modern projects, OpenTK is written for multiple platforms and operating systems.
29 Therefore, it's important to keep this in mind when contributing to the project - otherwise, it may 
30 make accepting your contribution much more difficult. You'll want to consider that the bug you're 
31 experiencing might not be present on other platforms or system configurations, or that your pull
32 request doesn't take all platforms into account. Sometimes this important, sometimes it's not.
33
34 OpenTK is also (as previously mentioned) a very large codebase which has seen a lot of people and a 
35 lot of styles over the years. This is reflected in the deeper, darker parts of the codebase where
36 mixed styles, weird naming, bizarre code and eldritch sorcery abound. What may seem like a small change
37 on the surface could lead you down on a path of unraveling one thread after another, and what started
38 off as a simple bug fix could transform into a lot of headscratching.
39
40 To make this at least somewhat easier, here's a few concrete general tips which you should stick to:
41
42 * Always consider cross-platform gotchas.
43 * Always work in small, iterative chunks which you can easily describe.
44 * Avoid cosmetic or visual changes, unless your contribution is strictly focused on that.
45 * Don't be afraid to ask, especially before diving in. There might be someone else working on the very
46 same thing already!
47 * Consider how your contribution might affect other contributions. Sometimes one change will break another
48 if you're not careful.
49
50 In terms of these guidelines, the terminology is as follows:
51 * Must: If your contribution does not follow this rule, it will not be accepted.
52 * Should: If your contribution does not follow this rule, it has a lower chance of being accepted.
53 * May: If your contribution does not follow this rule, it's probably not going to matter that much. 
54 It'd be a nice touch, though.
55
56 With that in mind, check the following sections for more concrete and direct guidelines.
57
58 ## Setting Up
59 For first-time contributors, there are a few steps that you'll need to go through in order
60 to start contributing.
61
62 #### 1. Get a copy of the code
63 First, fork OpenTK to your own profile and clone a local copy.
64
65 ```bash
66 $ git clone git@github.com:username/opentk.git
67 $ cd opentk
68 $ git remote add upstream https://github.com/opentk/opentk.git
69 ```
70
71 #### 2. Create a working branch
72 Development is done against the `develop` branch - this is where all the magic happens. Your
73 changes should always be based on this branch, so in order to start working, create a new branch
74 with an appropriate name and base it on `develop`.
75
76 ```bash
77 $ git checkout -b my-branch -t origin/develop
78 ```
79
80 #### 3. Let git know who you are
81 In order to better track changes and who does what, it's a good practice to give git some information
82 about yourself.
83
84 ```bash
85 $ git config --global user.name "John Doe"
86 $ git config --global user.email "john.doe@example.com"
87 ```
88
89 Optionally, you can also add your public GPG key and sign your commits - that way, there is no question
90 that it's definitely you that's created the commit. GitHub has some excellent information on how to do
91 this and why it's a good idea - [Signing Commits With GPG](https://help.github.com/articles/signing-commits-with-gpg/).
92
93 ```bash
94 $ git config --global user.signingkey QF3G6A39
95 $ git config --global commit.gpgsign true
96 ```
97
98 #### 4. Commit changes
99 Once you've finished up a change, it's time to commit it. In doing so, you'll be writing some sort of 
100 commit message, and there are some guidelines for how this should be formatted. Primarily, 
101
102 * Keep the first line of the commit message 50 characters or less
103 * If you need a longer description, keep the second line blank, and keep all subsequent more descriptive
104 lines at 72 characters or less.
105
106 The first line is what will be visible on the commit lists on GitHub, so make sure it's as descriptive as 
107 you can make it.
108
109 #### 5. Synchronizing your changes
110 Sometimes, pull requests and code changes take time, and other contributions are accepted in the meantime.
111 When this happens, you'll need to synchronize your changes with what's in the main repository. This should
112 be done using `rebase`, not `merge`, to keep the commit history from being cluttered with merge commits.
113
114 If you've not pushed your changes anywhere yet, it's sufficient to simply run (when on your branch)
115
116 ```bash
117 $ git fetch upstream
118 $ git rebase upstream/develop
119 ```
120
121 to fetch the latest code and replay your work on it. However, if you've already pushed it, you might run
122 into some issues when pushing to your fork after rebasing. To get around this, you'll have to forcibly push 
123 your changes to overwrite what's in your repository.
124
125 ```bash
126 $ git fetch --all
127 $ git rebase upstream/develop
128 $ git push --force-with-lease origin my-branch
129 ```
130
131 #### 6. Opening a pull request
132 When you feel that you're all done and you've pushed your changes to git, it's time to open a pull request
133 and have your changes reviewed. Before doing so, run a final test by executing the build script in the 
134 base directory of the codebase. 
135
136 ```bash
137 $ ./build.sh
138 ```
139
140 If it executes without any problems, you're good to go and ready to move on to creating your [Pull Request](#pull-requests).  
141
142 ## Pull Requests
143 Pull requests are without a doubt one of the more involved contribution types. Primarily, in order for a
144 pull request to be accepted, it must maintain a high quality, be well tested, and not have any major 
145 breaking changes (unless absolutely neccesary). There's going to be a lot of stuff dumped on you in the
146 next few paragraphs, but keep in mind that most are *guidelines*, not hard rules. Stick to them as best
147 you can, and when in doubt - just ask.
148
149 All pull requests must have or do the following:
150
151 * A clear, concise and descriptive title. As a rule of thumb, don't make it longer than twelve words or 
152 72 characters.
153 * A clear and detailed description of what the pull request has changed. This includes how the behaviour
154 of the library will change if the pull request is accepted - a maintainer should be able to read your 
155 description and fully understand what accepting it would mean without having to dive into the code.
156 * Be based on the `develop` branch of the main OpenTK repository.
157
158 All pull requests should have the following: 
159 * If applicable, a compilable example which demonstrates the changes. A git repository is preferred, and
160 your changed branch should be included as a submodule.
161
162 A pull requests may have the following:
163 * A short explanation of why you think these changes are neccesary, if it is not readily apparent from 
164 the rest of the pull request.
165
166 All code changes must follow these rules:
167
168 * The [Style Guide](https://www.PLACE.HOLDER/style-guide) should be adhered to religiously. In general, this is 
169 the same as following the MSDN and CoreFX guidelines with some changes.
170 * All new methods, fields, properties, events, classes, structures and enumerations must have appropriate
171 XML documentation comments wherein their behaviour is explained. These comments will be visible to the end
172 user, and should (in combination with the naming of the element) be sufficient to fully understand what 
173 the element does.
174 * XML comments on methods must describe each parameter (if any).
175 * Changes to existing access modifiers should be avoided if at all possible.
176
177 Furthermore, your pull request should: 
178 * Be tested on all applicable platforms. If you do not have access to a platform (not owning a Windows license, 
179 not having a Mac on hand, not having Linux installed, etc), ask for help testing your fix in Gitter or in your
180 pull request.
181
182 ### Bug Fixes
183 Bug fixes should resolve a single reported issue, or a collection of issues which fall under a single common 
184 meta-issue. 
185
186 Your bug fix must:
187
188 * Fix the issue on all supported platforms, or, if not applicable (such as a platform-specific or 
189 platform-agnostic bug), make it clear that the other platforms will not have the same issue.
190 * Refer to the issue number using github's pound syntax - for instance , "This PR resolves issue #1".
191
192 ### New Features
193 New features should introduce a single feature, capability, or functionality to the library which was not previously
194 present. No more than one feature may be introduced in any one pull request. 
195
196 Your feature addition must:
197
198 * Implement the feature on all supported platforms. If the feature cannot be implemented on one platform for some
199 reason, this must be clearly explained in the pull request and documented in the source code.
200
201 Your feature addition should, if applicable and possible:
202 * Implement a set of unit tests which test the entirety of the added public API surface. These tests must pass
203 on the CI service (Travis).
204
205 Furthermore, if your new feature replaces or makes an existing feature obsolete, this must be clearly stated.
206 This may prevent your pull request from being accepted in the current development cycle, or it may fast-track 
207 it depending on the changes.
208
209 ### Cosmetic & Stylistic Changes
210 Cosmetic and stylistic changes are those changes which do not affect executing code - that is, the library 
211 operates exactly the same way before and after change, but the code might look nicer or follow the style guide 
212 better.
213
214 These types of pull requests are given less priority than others, and may have to wait some time.
215
216 A cosmetic pull request must:
217
218 * Not break any outstanding pull request, or, if both would modify the same code, be prepared to wait 
219 until the other contribution is accepted or rejected before being considered.
220 * Change an affected file in its entirety to match the style guide standard that the contribution is using. 
221 Mixed styles are not permitted. As an example, if the pull request adds an XML comment to a method, it 
222 should also comment all other code elements which do not have XML documentation in that file.
223
224 Cosmetic contributions are not required to change everything in a file. Single atomic cosmetic changes 
225 (such as applying a single rule from the style guide) is permitted.
226
227 ### Breaking Changes
228 A pull request is considered to have introduced a breaking change if it does or wants to do one of 
229 the following:
230
231 * Removes one or more public method, field, property, event, class, structure or enumeration.
232 * Renames one or more public method, field, property, event, class, structure or enumeration.
233 * Alters the public behaviour of an existing method or property without fixing a bug or correcting the
234 behaviour to an expected result.
235 * Changes the accessibility of a previously public API to a more restrictive accessibility.
236 * Changes the method signature of a public method (renaming a parameter does not constitute a breaking 
237 change, and is a cosmetic change).
238
239 These types of pull requests are difficult to handle, and are only accepted as part of an active development
240 cycle. Their contributions will not make it into regular point releases, but can be merged into the next major 
241 release.
242
243 In general, if your pull request introduces a breaking change, you should follow this rule:
244
245 * No public-facing API should be deleted or made inaccessible. Instead, you should introduce an alternate method,
246 field or property and mark the previous one with an `[Obsolete("Use XXX instead.")]` attribute. Code marked obsolete 
247 in the previous development cycle is deleted when a new cycle begins.
248
249 ## Bug Reports
250 Every bug report must follow the [Issue Template](https://github.com/opentk/opentk/blob/develop/.github/ISSUE_TEMPLATE.md). 
251 Reports which do not follow this template will be closed.
252
253 If you can include a compilable example which demonstrates the issue you're having, the chances
254 that the bug will be fixed increase substantially. It's a lot faster to work with a problem
255 if you have something that quickly shows you what's going wrong. As with pull requests, a git repository 
256 is preferred. The latest OpenTK version from NuGet should be included as a package reference.
257
258 One important thing - make sure that the problem is actually an issue with OpenTK before opening a bug.
259 It may be a driver issue if it's graphical, or a library problem if it's input-related. It may be
260 a problem with your code, or it might be an issue in a library you use. As with most things, asking for
261 help on Gitter or other related forums will help you solve your problem faster and prevent invalid bug 
262 reports from being opened.
263
264 ## Discussions & Suggestions
265 We're always open to suggestions and discussions about current and future features and goals of the library. 
266 Most of these discussions take place on Gitter, but for larger projects and goals it might be a good idea
267 to create a github project tracker together with the maintainers. If you think the discussion warrants a 
268 more permanent forum, talk to us :)