Debian Codegraph @

doc/content/en/project/How to contribute/_index.md

raw
1 ---
2 title: "How to contribute"
3 linkTitle: "How to contribute"
4 weight: 5
5 ---
6
7 <!--
8
9 Licensed to the Apache Software Foundation (ASF) under one
10 or more contributor license agreements. See the NOTICE file
11 distributed with this work for additional information
12 regarding copyright ownership. The ASF licenses this file
13 to you under the Apache License, Version 2.0 (the
14 "License"); you may not use this file except in compliance
15 with the License. You may obtain a copy of the License at
16
17 https://www.apache.org/licenses/LICENSE-2.0
18
19 Unless required by applicable law or agreed to in writing,
20 software distributed under the License is distributed on an
21 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 KIND, either express or implied. See the License for the
23 specific language governing permissions and limitations
24 under the License.
25
26 -->
27
28 ## Getting the source code
29
30 First of all, you need the Avro source code.
31
32 The easiest way is to clone or fork the GitHub mirror:
33
34 ```shell
35 git clone https://github.com/apache/avro.git -o github
36 ```
37
38 ## Making Changes
39
40 Before you start, file an issue in [JIRA](https://issues.apache.org/jira/browse/AVRO) or discuss your ideas on the [Avro developer mailing list](http://avro.apache.org/mailing_lists.html). Describe your proposed changes and check that they fit in with what others are doing and have planned for the project. Be patient, it may take folks a while to understand your requirements.
41
42 Modify the source code and add some (very) nice features using your favorite IDE.
43
44 But take care about the following points
45
46 **All Languages**
47 - Contributions should pass existing unit tests.
48 - Contributions should document public facing APIs.
49 - Contributions should add new tests to demonstrate bug fixes or test new features.
50
51 **Java**
52
53 - All public classes and methods should have informative [Javadoc comments](https://www.oracle.com/fr/technical-resources/articles/java/javadoc-tool.html).
54 - Do not use @author tags.
55 - Java code should be formatted according to [Oracle's conventions](https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html), with one exception:
56 - Indent two spaces per level, not four.
57 - [JUnit](http://www.junit.org/) is our test framework:
58 - You must implement a class whose class name starts with Test.
59 - Define methods within your class and tag them with the @Test annotation. Call JUnit's many assert methods to verify conditions; these methods will be executed when you run mvn test.
60 - By default, do not let tests write any temporary files to /tmp. Instead, the tests should write to the location specified by the test.dir system property.
61 - Place your class in the src/test/java/ tree.
62 - You can run all the unit tests with the command mvn test, or you can run a specific unit test with the command mvn -Dtest=<class name, fully qualified or short name> test (for example mvn -Dtest=TestFoo test)
63
64
65 ## Code Style (Autoformatting)
66
67 For Java code we use [Spotless](https://github.com/diffplug/spotless/) to format the code to comply with Avro's code style conventions (see above). Automatic formatting relies on [Avro's Eclipse JDT formatter definition](https://github.com/apache/avro/blob/main/lang/java/eclipse-java-formatter.xml). You can use the same definition to auto format from Eclipse or from IntelliJ configuring the Eclipse formatter plugin.
68
69 If you use maven code styles issues are checked at the compile phase. If your code breaks because of bad formatting, you can format it automatically by running the command:
70 ```shell
71 mvn spotless:apply
72 ```
73
74 ## Unit Tests
75
76 Please make sure that all unit tests succeed before constructing your patch and that no new compiler warnings are introduced by your patch. Each language has its own directory and test process.
77
78 <details><summary>Java</summary>
79
80 ```shell
81 cd avro-trunk/lang/java
82 mvn clean test
83 ```
84 </details>
85
86 <details><summary>Python</summary>
87
88 ```shell
89 cd avro-trunk/lang/py
90 ./setup.py build test
91 ```
92 </details>
93
94 <details><summary><a href="https://www.rust-lang.org/">Rust</a></summary>
95
96 ```shell
97 cd avro-trunk/lang/rust
98 ./build.sh clean test
99 ```
100 </details>
101
102 <details><summary>C#</summary>
103
104 ```shell
105 cd avro-trunk/lang/csharp
106 ./build.sh clean test
107 ```
108 </details>
109
110 <details><summary>C</summary>
111
112 ```shell
113 cd avro-trunk/lang/c
114 ./build.sh clean
115 ./build.sh test
116 ```
117 </details>
118
119 <details><summary>C++</summary>
120
121 ```shell
122 cd avro-trunk/lang/c++
123 ./build.sh clean test
124 ```
125 </details>
126
127 <details><summary>Ruby</summary>
128
129 ```shell
130 cd avro-trunk/lang/ruby
131 gem install echoe
132 rake clean test
133 ```
134 </details>
135
136 <details><summary>PHP</summary>
137
138 ```shell
139 cd avro-trunk/lang/php
140 ./build.sh clean
141 ./build.sh test
142 ```
143 </details>
144
145
146 ## Contributing your code
147
148 Contribution can be made directly via github with a Pull Request, or via a patch.
149
150 **Via Github**
151
152 Method is to create a [pull request](https://help.github.com/articles/using-pull-requests/).
153
154 On your fork, create a branch named with JIRA (avro-1234_fixNpe for example)
155 On source, go to it
156 ```shell
157 git pull
158 git switch avro-1234_fixNpe
159 ```
160
161 code your changes (following preceding recommendations)
162
163 check and add updated sources
164 ```shell
165 git status
166
167 # Add any new or changed files with:
168 git add src/.../MyNewClass.java
169 git add src/.../TestMyNewClass.java
170 ```
171
172 Finally, create a commit with your changes and a good log message, and push it:
173 ```shell
174 git commit -m "AVRO-1234: Fix NPE by adding check to ..."
175 git push
176 ```
177 On your github fork site, a button will propose you to build the Pull Request.
178 Click on it, fill Conversation form, and create it.
179 Link this PR to the corresponding JIRA ticket (on JIRA ticket, add PR to "Issue Links" chapter, and add label 'pull-request-available' to it .
180
181 <!-- TODO: Fix formatting and decide whether this should be included in this section, moved to another section
182 <details><summary><b>Via Patch</b> (if you don't have github account)</summary>
183 <blockquote>
184 <details><summary><b>Clone avro repository</b></summary>
185
186 ```shell
187 git clone https://github.com/apache/avro.git -o github
188 ```
189 </details>
190 code your changes (following preceding recommendations)
191 <details><summary><b>Creating a patch</b></summary>
192
193 In order to create a patch, type:
194 git diff > AVRO-1234.patch
195
196 This will report all modifications done on Avro sources on your local disk and save them into the AVRO-1234.patch file. Read the patch file.
197 Make sure it includes ONLY the modifications required to fix a single issue.
198
199 Please do not:
200 ```
201 reformat code unrelated to the bug being fixed: formatting changes should be separate patches/commits.
202 comment out code that is now obsolete: just remove it.
203 insert comments around each change, marking the change: folks can use subversion to figure out what's changed and by whom.
204 make things public which are not required by end users.
205 ```
206 Please do:
207 ```
208 try to adhere to the coding style of files you edit;
209 comment code whose function or rationale is not obvious;
210 update documentation (e.g., package.html files, this wiki, etc.)
211 name the patch file after the JIRA – AVRO-<JIRA#>.patch
212 ```
213 </details>
214
215 <details><summary><b>Applying a patch</b></summary>
216
217 To apply a patch either you generated or found from JIRA, you can issue
218
219 patch -p0 < AVRO-<JIRA#>.patch
220
221 if you just want to check whether the patch applies you can run patch with --dry-run option
222
223 patch -p0 --dry-run < AVRO-<JIRA#>.patch
224
225 If you are an Eclipse user, you can apply a patch by:
226
227 Right click project name in Package Explorer
228 Team -> Apply Patch
229
230 Finally, patches should be ''attached'' to an issue report in JIRA via the '''Attach File''' link on the issue's Jira. Please add a comment that asks for a code review following our code review checklist.
231 </details>
232 <details><summary><b>Contributing your patch</b></summary>
233
234 When you believe that your patch is ready to be committed, select the '''Submit Patch''' link on the issue's Jira.
235
236 Folks should run tests before selecting '''Submit Patch'''. Tests should all pass. Javadoc should report '''no''' warnings or errors. Submitting patches that fail tests is frowned on (unless the failure is not actually due to the patch).
237
238 If your patch involves performance optimizations, they should be validated by benchmarks that demonstrate an improvement.
239
240 If your patch creates an incompatibility with the latest major release, then you must set the '''Incompatible change''' flag on the issue's Jira 'and' fill in the '''Release Note''' field with an explanation of the impact of the incompatibility and the necessary steps users must take.
241
242 If your patch implements a major feature or improvement, then you must fill in the '''Release Note''' field on the issue's Jira with an explanation of the feature that will be comprehensible by the end user.
243
244 Once you have submitted your patch, a committer should evaluate it within a few days and either: commit it; or reject it with an explanation.
245
246 Please be patient. Committers are busy people too. If no one responds to your patch after a few days, please make friendly reminders. Please incorporate other's suggestions into your patch if you think they're reasonable. Finally, remember that even a patch that is not committed is useful to the community.
247
248 Should your patch be rejected, select the '''Resume Progress''' on the issue's Jira, upload a new patch with necessary fixes, and then select the **Submit Patch** link again.
249
250 In many cases a patch may need to be updated based on review comments. In this case the updated patch should be re-attached to the Jira with the name name. Jira will archive the older version of the patch and make the new patch the active patch. This will enable a history of patches on the Jira. As stated above patch naming is generally AVRO-#.patch where AVRO-# is the id of the Jira issue.
251
252 Committers: for non-trivial changes, it is best to get another committer to review your patches before commit. Use Submit Patch link like other contributors, and then wait for a "+1" from another committer before committing. Please also try to frequently review things in the patch queue.
253
254 </details>
255
256 <details><summary><b>Committing Guidelines for committers</b></summary>
257
258 Apply the patch uploaded by the user or check out their pull request. Edit the CHANGES.txt file, adding a description of the change, including the bug number it fixes. Add it to the appropriate section - BUGFIXES, IMPROVEMENTS, NEW FEATURES. Please follow the format in CHANGES.txt file. While adding an entry please add it to the end of a section. Use the same entry for the first line of the git commit message.
259
260 Changes are normally committed to the main branch first, then, if they're backward-compatible, cherry-picked to a branch.
261
262 When you commit a change, resolve the issue in Jira. When resolving, always set the fix version and assign the issue. Set the fix version to either to the next minor release if the change is compatible and will be merged to that branch, or to the next major release if the change is incompatible and will only be committed to trunk. Assign the issue to the primary author of the patch. If the author is not in the list of project contributors, edit their Jira roles and make them an Avro contributor.
263 </details>
264 </blockquote>
265 </details>
266 -->
267
268 ## Jira Guidelines
269
270 Please comment on issues in [Jira](https://issues.apache.org/jira/projects/AVRO/issues), making your concerns known. Please also vote for issues that are a high priority for you.
271
272 Please refrain from editing descriptions and comments if possible, as edits spam the mailing list and clutter Jira's "All" display, which is otherwise very useful. Instead, preview descriptions and comments using the preview button (on the right) before posting them. Keep descriptions brief and save more elaborate proposals for comments, since descriptions are included in Jira's automatically sent messages. If you change your mind, note this in a new comment, rather than editing an older comment. The issue should preserve this history of the discussion.
273
274 ## Stay involved
275
276 Contributors should join the Avro mailing lists. In particular, the commit list (to see changes as they are made), the dev list (to join discussions of changes) and the user list (to help others).
277
278 ## Workflow
279
280 Building and running the site locally requires a recent extended version of Hugo. Install [Hugo](https://gohugo.io/installation/) for your environment. Once you've made your working copy of the site repo, from the repo root folder, run:
281
282 ```shell
283 hugo server --navigateToChanged
284 ```
285 Edit .md and .html files in content/ folder
286
287 Once satisfied with the changes, commit them:
288 ```shell
289 git commit -a
290 ```
291 Generate the HTML file stop hugo server --navigateToChanged (with Ctrl+C) and run
292 ```shell
293 hugo
294 ```
295 This will generate the HTMLs in public/ folder and this is actually what is being deployed
296
297 Add the modified HTML files to Git
298
299 ```shell
300 git add .
301 git rm offline-search-index.<<OLD-HASH>>.json
302 git commit -a
303 git push
304 ```
305 This way even when the PR modifies a lot of files we can review only the first commit, the meaningful one, with the modified files in content/ folder
306
307
308 ## Running a container locally
309 You can also run avro-website inside a Docker container, the container runs with a volume bound to the avro-website folder. This approach doesn't require you to install any dependencies other than Docker Desktop on Windows and Mac, and Docker Compose on Linux.
310
311 Build the docker image
312
313 ```shell
314 docker-compose build
315 ```
316 Run the built image
317 ```shell
318 docker-compose up
319 ```
320 NOTE: You can run both commands at once with docker-compose up --build.
321
322 Verify that the service is working.
323
324 Open your web browser and type http://localhost:1313 in your navigation bar, This opens a local instance of the docsy-example homepage. You can now make changes to the docsy example and those changes will immediately show up in your browser after you save.
325
326 **Cleanup**
327
328 To stop Docker Compose, on your terminal window, press Ctrl + C.
329
330 To remove the produced images run:
331 ```shell
332 docker-compose rm
333 ```
334
335 ## Troubleshooting
336 As you run the website locally, you may run into the following error:
337 ```shell
338 ➜ hugo server
339
340 INFO 2021/01/21 21:07:55 Using config file:
341 Building sites … INFO 2021/01/21 21:07:55 syncing static files to /
342 Built in 288 ms
343 Error: Error building site: TOCSS: failed to transform "scss/main.scss" (text/x-scss): resource "scss/scss/main.scss_9fadf33d895a46083cdd64396b57ef68" not found in file cache
344 ```
345 This error occurs if you have not installed the extended version of Hugo. See our user guide for instructions on how to install Hugo.
346
347 ## Edit content
348 The website content is in content/en folder. It contains .md (Markdown) and .html (HTML) files.
349
350 **Layouts**
351
352 To change the layout of any page edit layouts/<page>/**.html. If there is no layout for a given page at that location then copy the one provided by the theme and edit it:
353 ```shell
354 cp themes/docsy/layouts/<xyz> layouts/<xyz>
355 ```
356 **Avro version**
357
358 When a new version of Apache Avro is released:
359
360 Change the value of params.avroversion in config.toml
361 Add a new entry to the Releases pages in the Blog section, for example:
362 ```shell
363 cp content/en/blog/releases/avro-1.10.2-released.md content/en/blog/releases/avro-1.11.0-released.md
364 ```
365 **API documentation for C/C++/C# modules**
366
367 The API documentations for C/C++/C# are built by their respective build.sh dist implementations. The final HTML should be copied to the external folder, for example:
368 ```shell
369 cp ../avro/build/avro-doc-1.12.0-SNAPSHOT/api/c/* content/en/docs/external/c/
370 ```
371
372 ## JIRA conventions
373
374 Issue types: JIRA issues are categorized into different types such as bugs, improvements, new features, etc. Each issue type has a unique icon and a set of fields that are specific to that type.
375
376 Workflow: JIRA issues follow a predefined workflow that defines the steps that an issue goes through from creation to resolution. Each step in the workflow can have its own set of conditions and actions.
377
378 Priority: JIRA allows users to set priorities for issues to help determine the order in which they should be addressed. The priority can be set to one of five levels: Blocker, Critical, Major, Minor, and Trivial. Blocker is the highest priority and Trivial is the lowest priority.
379
380 Labels: Labels are used to tag issues with keywords or phrases that can help with searching and filtering.
381
382 Components: Components are used to group related issues together. For example, a software project might have components for the user interface, database, and networking.
383
384 ## See Also
385
386 - [Apache contributor documentation](http://www.apache.org/dev/contributors.html)
387 - [Apache voting documentation](http://www.apache.org/foundation/voting.html)
388