Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update doc to avoid confusions to new contributors (patch vs pull request), also updated doc on some out dates steps (e.g. we don't require regenerate doc on every pull request).

...

Good Ant tutorial: http://i-proving.com/2005/10/31/ant-tutorial

Generating a patch

Unit Tests

Please make sure that all unit tests succeed before constructing your patch and that no new javac compiler warnings are introduced by your patch.

Code Block
> cd zookeeper-trunk
> ant -Djavac.args="-Xlint -Xmaxwarns 1000" clean test tar

After a while, if you see

Code Block
BUILD SUCCESSFUL

all is ok, but if you see

Code Block
BUILD FAILED

then please examine error messages in build/test and fix things before proceeding.

Javadoc

Please also check the javadoc.

Code Block
> ant javadoc
> firefox build/docs/api/index.html

Examine all public classes you've changed to see that documentation is complete, informative, and properly formatted. Your patch must not generate any javadoc warnings.

Creating a patch

Please note that we are deprecating contribution via patch, and replacing it with github pull request. Please refer to the "Pull requests via github" section in this page for how to contribute via pull request.

Check to see what files you have modified with:

Code Block
git status

Add any new files with:

Code Block
git add src/.../MyNewClass.java
git add src/.../TestMyNewClass.java

Commit your changes, type:

Code Block
git commit -a

In the commit message should be one line of the form: JIRA: short description. For example 

ZOOKEEPER-1234: fixed the coolness factor calculation

You can then create a patch with the following command

Code Block
git show --no-prefix > ZOOKEEPER-1234.patch

This will report all modifications done on ZooKeeper sources on your local disk and save them into the ZOOKEEPER-1234.patch file. Read the patch file.
Make sure it includes ONLY the modifications required to fix a single issue.

Please do not:

  • reformat code unrelated to the bug being fixed: formatting changes should be separate patches/commits.
  • comment out code that is now obsolete: just remove it.
  • insert comments around each change, marking the change: folks can use subversion to figure out what's changed and by whom.
  • make things public which are not required by end users.

Please do:

  • try to adhere to the coding style of files you edit;
  • comment code whose function or rationale is not obvious;
  • update documentation (e.g., package.html files, this wiki, etc.)
  • name the patch file after the JIRA – ZOOKEEPER-<JIRA#>.patch

Testing your patch

Contribute Work via Github Pull Request

We accept pull requests via github against the apache/zookeeper repository. Submitting to Apache ZooKeeper via github is no different than submitting any other pull request against a github repository. The developer needs to follow the contribution guidelines to produce changes, just like with patch files, and once it is ready, the developer produces a pull request from his/her own branch. The one constraints we have is that the title of the pull request must match the paring JIRA issue. If the JIRA issue is "ZOOKEEPER-222222: My lovely bug", then the pull request issue must also match "ZOOKEEPER-222222: My lovely bug".

We currently perform QA on pull requests, although the process is still being polished. We also have not completed the JIRA workflow when the developer submits a pull request, which means that the JIRA does not transition to Patch Available when a pull request is submitted. We are currently discussing on the list how to adapt our workflow.

Example workflow

there are many ways to setup your git environment but this one example:

fork the apache github repo

go to https://github.com/apache/zookeeper and click the fork button to create your own fork.

make a local clone of your fork

on your local machine run

Code Block
languagebash
$ git clone https://github.com/<userid>/zookeeper.git my-zookeeper
add the apache github repo
Code Block
languagebash
$ git remote add apache-github https://github.com/apache/zookeeper.git
make sure you are uptodate
Code Block
languagebash
$ git pull apache-github 
create a branch named after the issue you are working on
Code Block
languagebash
$ git checkout remotes/apache-github/master
$ git checkout -B ZOOKEEPER-<jiraNumber>

<jiraNumber> is the JIRA you will be working on.

make your changes

sorry can't help you here. it's all up to you to fix the bug (smile)

commit everything

do you will want to do some combination of git add and git commit to get all your changes committed. when you run git commit, you only need a single line in the commit message it should have the form ZOOKEEPER-jiraNumber: jiraTitle.

push your change to git hub
Code Block
$ git push origin ZOOKEEPER-<jiraNumber>

generate a pull request

go to the github page that lists your branches. you will see a pull request button that you can press.

Check List for Pull Request

This is a check list of things we'd like a contributor to do before opening a pull request.

Unit Tests

Before submitting your pull requestBefore submitting your patch, you are encouraged to run the same tools that the automated Jenkins CI system will run on your patch. This enables you to fix problems with your patch pull request before you submit it. The The test Ant  Ant target will run your patch through the same checks that Jenkins currently does.

...

  • you may need to explicitly set ANT_HOME. Running Running ant -diagnostics will  will tell you the default value on your system.
  • you may need to explicitly set JAVA_HOME.

Applying a patch

To apply a patch either you generated or found from JIRA, you can issue

Code Block
patch -p0 < ZOOKEEPER-<JIRA#>.patch

if you just want to check whether the patch applies you can run patch with --dry-run option

Code Block
patch --dry-run -p0 < ZOOKEEPER-<JIRA#>.patch

If you are an Eclipse user, you can apply a patch by : # Right click project name in Package Explorer , 2. Team -> Apply Patch

Contributing your work

Please make sure that all unit tests succeed before submitting pull request and that no new javac compiler warnings are introduced by your pull request

Code Block
> cd zookeeper-trunk
> ant -Djavac.args="-Xlint -Xmaxwarns 1000" clean test tar

After a while, if you see

Code Block
BUILD SUCCESSFUL

all is ok, but if you see

Code Block
BUILD FAILED

then please examine error messages in build/test and fix things before proceeding.

Javadoc

Please also check the javadoc.

Code Block
> ant javadoc
> firefox build/docs/api/index.html

Examine all public classes you've changed to see that documentation is complete, informative, and properly formatted. Your patch must not generate any javadoc warnings.

Please don't do in pull request:

  • reformat code unrelated to the bug being fixed: formatting changes should be separate patches/commits.
  • comment out code that is now obsolete: just remove it.
  • insert comments around each change, marking the change: folks can use subversion to figure out what's changed and by whom.
  • make things public which are not required by end users.

Please do in pull request:

  • try to adhere to the coding style of files you edit;
  • comment code whose function or rationale is not obvious;

Final Checks on Pull Request

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. Please note that the attachment should be granted license to ASF for inclusion in ASF works (as per the Apache License §5).When you believe that your patch is ready to be committed, select the Submit Patch link on the issue's Jira.

Folks should run ant clean test javadoc before selecting Submit Patchsubmitting pull request. Tests should all pass. Javadoc should report no warnings or errors. Jenkin's tests are meant to double-check things, and not be used as a primary patch tester, which would create too much noise on the mailing list and in Jira. Submitting patches that fail Jenkins testing is frowned on, (unless the failure is not actually due to the patch).

If your patch PR involves performance optimizations, they should be validated by benchmarks that demonstrate an improvement.

If your patch PR 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.

If your patch PR 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.

Code Review and Accept Pull Request

Once a "+1" comment is received from the automated patch testing system and a code reviewer has set the Reviewed flag on the issue's Jira, a committer should then evaluate it within a few days and either: commit it; or reject it with an explanation.

...

Should your patch receive a "-1" from the Jenkins testing, select the Resume Progress on the issue's Jira, upload a new patch with necessary fixes, and then select the Submit Patch link again.In some 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 same 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 ZOOKEEPER-#.patch where ZOOKEEPER-# is the id of the Jiraupdate pull request with necessary fixes.

Committers: for non-trivial changes, it is best to get another committer to review your patches pull request 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.

Pull requests via github (work in progress)

We currently accept pull requests via github against the apache/zookeeper repository. Submitting to Apache ZooKeeper via github is no different than submitting any other pull request against a github repository. The developer needs to follow the contribution guidelines to produce changes, just like with patch files, and once it is ready, the developer produces a pull request from his/her own branch. The one constraints we have is that the title of the pull request must match the paring JIRA issue. If the JIRA issue is "ZOOKEEPER-222222: My lovely bug", then the pull request issue must also match "ZOOKEEPER-222222: My lovely bug".

We currently perform QA on pull requests, although the process is still being polished. We also have not completed the JIRA workflow when the developer submits a pull request, which means that the JIRA does not transition to Patch Available when a pull request is submitted. We are currently discussing on the list how to adapt our workflow.

Example workflow

there are many ways to setup your git environment but this one example:

fork the apache github repo

go to https://github.com/apache/zookeeper and click the fork button to create your own fork.

make a local clone of your fork

on your local machine run

Code Block
languagebash
$ git clone https://github.com/<userid>/zookeeper.git my-zookeeper
add the apache github repo
Code Block
languagebash
$ git remote add apache-github https://github.com/apache/zookeeper.git
make sure you are uptodate
Code Block
languagebash
$ git pull apache-github 
create a branch named after the issue you are working on
Code Block
languagebash
$ git checkout remotes/apache-github/master
$ git checkout -B ZOOKEEPER-<jiraNumber>

<jiraNumber> is the JIRA you will be working on.

make your changes

sorry can't help you here. it's all up to you to fix the bug (smile)

commit everything

do you will want to do some combination of git add and git commit to get all your changes committed. when you run git commit, you only need a single line in the commit message it should have the form ZOOKEEPER-jiraNumber: jiraTitle.

push your change to git hub
Code Block
$ git push origin ZOOKEEPER-<jiraNumber>

 

generate a pull request

go to the github page that lists your branches. you will see a pull request button that you can press.

Committing Guidelines for committers

...