Watcher/Contributing

= Before You Begin = You will need to execute an OpenStack CLA. This is required before you can submit reviews to our Watcher Repo. For information about how prepare for contribution, please consult the How To Contribute wiki page.

Sign Up for the OpenStack Development Mailing List
Head on over to OpenStack Dev Mailing List, fill out the fields under "Subscribing to OpenStack-dev" and click Subscribe.

Learn About Gerrit
Be sure to read the Developer's Guide for information about how to submit your commit for review so it can be merged into the Watcher code base.

If you do not have a gerrit username setup or do not remember it, verify and configure it here: https://review.openstack.org/#/settings/

Keep that handy for the "git review -s" command later in the https://wiki.openstack.org/wiki/Watcher/Contributing#Setting_up_your_git_review_settings and https://wiki.openstack.org/wiki/Watcher/Contributing#Set_up_your_local_branch sections below...

You'll also need to upload an SSH public key, specifically for Gerrit: https://review.openstack.org/#/settings/ssh-keys

Setting up your git review settings
New to git? Try the 15-minute high-level interactive Git demo GitHub Demo

Need a git refresher? Download a git reference direct from the source: GitHub Git Cheat Sheet

Then:

git config --global user.name "Firstname Lastname" git config --global user.email "your_email@youremail.com"

In the event your launchpad and gerrit usernames are identical: git config --global gitreview.username "your_launchpad_username" In the event your launchpad and gerrit usernames are not identical: git config --global gitreview.username "your_gerrit_username"

To check your git configuration:

git config --list

Installing git-review
On Ubuntu, MacOSx, or most other Unix-like systems, it is as simple as: pip install git-review

There are other installation options detailed in the Developer's Guide. You can now check out the Watcher code and begin working on it:

= Blueprints =

Blueprints should be used to propose a design and get it approved.

You should link your blueprint to a specification file in Watcher-specs repository, and use the "Design" fields in the blueprint to track the spec approval.

You should follow this process:
 * Register your blueprint in Launchpad by going to the project page at launchpad.net/watcher and clicking "Register a blueprint"
 * Upload a design specification in the "specs/ " folder in watcher-specs
 * it should be based on the specs/ -template.rst, see the instructions in the template for more details
 * it should be submitted in the approved folder of the current release, for example specs/mitaka/approved
 * the filename should match the launchpad URL, for example a URL of https://blueprints.launchpad.net/watcher-specs/+spec/awesome-thing should be named awesome-thing.rst
 * get it reviewed by submitting your patch using Gerrit, in the usual way: Development Workflow
 * at the end of each release, non-completed specs will be removed
 * you need to re-submit for the following release
 * Watcher drivers will set the blueprint status as:
 * "New" - description submitted but not reviewed yet
 * "Discussion" - description has been reviewed and needs improvements
 * "Drafting" - description has been reviewed, specifications are needed and currently in review on Gerrit
 * "Approved" - specifications have been discussed and merged, implementation can start
 * Watcher drivers will also set a target milestone based on the assignee proposal
 * Assignee then keeps milestone and implementation status current to reflect progress
 * Assignee sets implementation status to "Implemented" when the work is completed

NB: an automated script will ensure that no milestone target is set on unapproved (unprioritized) blueprints.

= Your first commit =

Set up your local branch
git clone git://git.openstack.org/openstack/watcher cd watcher git checkout -b [branch name (see below...)] git review -s

Your branch name 'must' be related to a blueprint or a bug. This will be reflected in the "topic" field in Gerrit.

Please use the following convention to name your branch :
 * for a blueprint, use "bp/"
 * for a bug, use "bug/"

If you receive the following error when running the "git review -s" command: We don't know where your gerrit is. Please manually create a remote named "gerrit" and try again.

Perform the following (substituting with your specific gerrit username...): git remote add gerrit ssh:// @review.openstack.org:29418/openstack/watcher.git git review -s

If you receive the following error when running the "git review -s" command: Agent admitted failure to sign using the key

See this support page: https://help.github.com/articles/error-agent-admitted-failure-to-sign/

Write some awesome code
At this point can write your code and push it to Gerrit for review.

git add 

If you submitted a bug in the previous section, be sure to add the bug link in the commit message.

Each commit line should conform with the OpenStack message structure guidelines found at https://wiki.openstack.org/wiki/GitCommitMessages#Summary_of_Git_commit_message_structure

Highlights include:
 * There should be no whitespace at the end of the lines
 * The order of the lines is important
 * The first line of the commit message should be <=50 characters
 * The next line is blank
 * The next section is a verbose description of the commit (lines must be <= 72 characters)
 * The next line is blank
 * The next lines contain the bug number or the blueprint name and possibly other information:
 * Closes-Bug/Partial-Bug/Related-Bug: hash symbol (#) followed by a bug number (e.g. Closes-Bug: #111111)
 * Blueprint: blueprint name (e.g., "Implements: blueprint libvirt-xml-cpu-model")
 * Once the change is submitted with git review a "Change-Id:" line will be appended with an identifier generated by Gerrit

An example of a commit message: Adjust Gerrit workflow Link  The Gerrit workflow link in the previous version is no longer valid. This patch updates documentation to the current link.  Closes-Bug: # Change-Id: 

This is but one example. You can find more detailed information about commit messages at https://wiki.openstack.org/wiki/GitCommitMessages

Once you organize the above information, perform the following command to type it in: git commit -a

Then, submit the review: git review -v

By this point, your code will be reviewed by the Openstack automatic testing frameworks and, potentially, your peers on the project.

To get early feedback on a change which is not fully finished yet, you can submit it and mark it as “Work in Progress” (WIP). To do so, you should go to Gerrit, and do Code Review of your own change while setting “Workflow” vote to “-1”, which marks the change as WIP.

If you want to revise your patchset in the review system in response to feedback, first navigate back to your development area: cd ~/watcher [or wherever that is for your setup...]

Download the change. Be sure to use the review number and NOT the bug number: git review -d

Then, make your changes, and update the commit message using the aforementioned commit guidelines: git commit --amend

Then: git review -v

Upon approval of the review your code will be automatically merged.

Need somewhere to start writing code?
You can also contribute to the quality of the code by looking at the coverage of current Watcher unit tests and improving the code coverage.

You can review the code coverage of your currently checked out code with: $ tox -e cover

This will produce a cover directory that provides HTML output showing the code coverage as well as the specific lines of code that are not covered.

How to Resolve Merge Conflicts
If another patch changes the same line of code as your patch, and it gets merged before yours, your patch may get a  status in red. If that happens, here is how you can resolve it. You will need the patch number from the Gerrit URL https://review.openstack.org/NNNNN to make your rebase a revision of the previous review.

git clone https://github.com/openstack/watcher cd watcher git review -d NNNNN git rebase master

Now edit all files with merge conflicts to resolve them by making the code look the way it should both with the recently merged code, and your own. Then  each of the files you edited.

git add path/to/file/you/edited git rebase --continue git review -v

That will resubmit your patch with the original commit message, and the rebased code with your merge fix as a new patch set.

= Bugs =

Identify bugs
Observe a bug? Report it here: https://launchpad.net/watcher
 * 1) Click the Report a Bug button.
 * 2) Enter a Summary in the field and click Next. Here's an example: Stale link to Gerrit Workflow
 * 3) Review the choices you've been given. If you spot your bug, click on the bug and review its status; proceed to the awesome code section below if there's more to do..  If you do not spot your bug, proceed to the next step.
 * 4) Click the No, I need to report a new bug button.
 * 5) Type in a detailed description of the bug in the "Further information" field and click Submit bug report.

NOTE: If you are fixing something trivial, that is not actually a functional defect in the software, you can do that without filing a bug ticket, if you don't want it to be tracked when we tally this work between releases. If you do this, just mention it in the commit message that it's a trivial change that does not require a bug ticket. You can reference this guideline if it comes up in discussion during the review process. Functional defects should be tracked in bug tickets. New features should be tracked in blueprints. Trivial features may be tracked using a bug ticket marked as 'Wishlist' importance.

Pick bugs
If you would like to start working on a bug, please wait for the watcher drivers to set its status as "Triaged". Please do not assign yourself a bug with the status "New", if you just submitted the bug and you are ready to submit a fix, please tell a core contributor on our IRC channel #openstack-watcher to set it to "Triaged".

Low Hanging Fruit
Some bugs have been identified by the bug manager as appropriate for first time contributors. These bugs should require small patches, and don't require an extensive understanding of Watcher to work on. Find them tagged with the low-hanging-fruit tag in the bug system.

= Reviews =

The OpenStack CI system uses the concept of core reviewers. These are individuals who have consistently reviewed code for the project, and helped over a considerable period of time to improve the quality and consistency of what we merge into the code base. Project contributors will feel that this reviewer is a positive influence on the team and that they maintain the values and traditions of the OpenStack development community.

Policies
Existing core reviewers may nominate new ones in an ML thread. Consent among the current reviewers shall result in the declaration of the new core reviewer by the PTL. Lack of unanimous consent shall be carefully considered, and a final decision informed by input from active team members shall be made by the PTL. Core reviewers who are judged by their peers in the core review group to fall short of the expectations for contribution of a core reviewer may be nominated for return to regular reviewer status.

Patches require a core reviewer to mark a review as "Approved" before they are merged.

Code Approval for Merge

 * For Approval, at least one core reviewer shall supply a  and gate tests (Jenkins) have passed successfully.

Continuing Someone Else's Contribution

 * If a patch submitted by one contributor is picked up and completed by another contributor, special handling of the resolution should be used.

Advice for Reviewers

 * A  vote is an opportunity to make our code better before it is merged. Please do your best to make helpful, actionable -1 votes.
 * Avoid the temptation to blindly  code without reviewing it in sufficient detail to form an opinion.
 * When voting  on a patch, it means that you want the submitter to make a revision in accordance with your feedback before core reviewers should consider this code for merge.
 * If you ask a question, you should vote  unless you anticipate that the answer to that question is likely to cause you to vote against the patch without further revisions.
 * If you use a  vote for a question, and the contributor answers the question, please respond acknowledging the question. Either change your vote or follow up with additional rationale for why this should remain a   comment.
 * A  vote is a veto by a single core reviewer. It is sticky. That means that even if you revise your patch, that vote will persist. To allow your patch to merge, that same reviewer must clear the   vote first. This vote is used when you have contributed something that is not in alignment with the current project vision, or is implemented in a way that can not be accepted. For example, security concerns that a core reviewer wants to individually re-evaluate before allowing the contribution to continue. It can also be used as a way to halt further gate testing of a patch, if something is included that may break the gate. It works even after a   approval for merge, but before the patch reaches MERGED state.
 * To avoid a  vote, discuss your plans with the development team prior to writing code, and post a WIP (workflow-1) patch while you are working on it, and ask for input before you submit it for merge review.