Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

36
1 Assign, Commit, and Review A developer’s guide to OpenStack contribution Luo, Zhongyue OpenStack APAC Conference, Shanghai August 11, 2012

Transcript of Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

Page 1: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

1

Assign, Commit, and Review

A developer’s guide to OpenStack contribution

Luo, Zhongyue

OpenStack APAC Conference, Shanghai August 11, 2012

Page 2: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

2

TODO

Why contribute?

Terminologies

Overview

Prerequisites

Assign

Commit

Review

Summary

Page 3: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

3

Why contribute?

Tons of new requirements everyday when operating an IaaS

• New customers, competitors, regulations, and technology

Always short of skill, budget, and time

• Need help from community

Obvious requirements are to be contributed

• Someone is always smarter than you in someway

Contribute and gain respect

• Have others pay attention to what you say

Page 4: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

4

Terminologies

Git

• github.com: Code repository

• git-review: The tool to submit code patches

• git commit message: Description of code change

Launchpad (https://launchpad.net)

• Bug tracker for OpenStack projects

• Blueprint/Bug report: Description of a requirement/problem

Gerrit (https://review.openstack.org)

• Standalone patch review server for git projects

Jenkins (https://jenkins.openstack.org)

• Continuous integration system

Page 5: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

5

Overview

git clone

e.g) git://github.com/openstack/nova git://github.com/openstack/quantum git://github.com/openstack/cinder git://github.com/openstack/${project_name}

Your development environment

Your code patch

Page 6: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

6

Overview

openstack-ci

ZUUL

git review

Your development environment

Your code patch

updates

gets aggregated

runs tests

1

2

3

4

5

reports

(link)

Page 7: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

Prerequisites http://wiki.openstack.org/HowToContribute#If_you.27re_a_developer.2C_start_here:

Page 8: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

8

Create Launchpad account

https://launchpad.net/+login

Also enables access to mailing list, wiki, gerrit, and jenkins

Page 9: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

9

Sign your CLA

Mandatory

• Individual Contributor License Agreement

Optional – done by your company

• Corporate Contributor License Agreement

• Update the list of authorized employees

For more details

• http://wiki.openstack.org/CLA

Page 10: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

10

Add your name to contributors wiki

1

2

http://wiki.openstack.org/Contributors

(Individual CLA) EchoSign transaction number

Page 11: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

11

Add your name to contributors wiki

1

2

|| ${your_name} || ${launchpad_id} || [[https://rackspace.echosign.com/verifier?tx=${EchoSign_transaction_number} | ${EchoSign_transaction_number}]] || ${company_name} ||

3

Page 12: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

12

Join the openstack-cla team

https://launchpad.net/~openstack-cla/+join

Page 13: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

13

Add SSH public key to Gerrit

https://review.openstack.org

1

Page 15: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

15

Install git-review

$ sudo pip install git-review

Page 16: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

Assign

Page 17: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

17

Key takeaway

Ways to assign yourself work

1. Attend IRC meetings

2. Find bug reports on Launchpad

3. Hack the source code

How to write a blueprint

• What is the current status?

• How will your blueprint improve this situation?

• What is the follow up?

How to write a bug description

• Write about WHAT the problem is

Page 18: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

18

Find out what others are having problems with

Start with low-hanging-fruit, Triaged

http://bugs.launchpad.net/${project_name}

Page 19: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

19

How to assign yourself a bug report

Find a unassigned one

1

Page 20: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

20

How to assign yourself a bug report

Not so simple with blueprints…

2

Page 21: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

21

Get involved in the community

Attend weekly IRC meetings

• Fastest way to find work

• Most effective way to have presence

• #openstack-meeting on irc.freenode.net

• http://wiki.openstack.org/Meetings

Subscribe to the mailing lists

• Find out the current issues in OpenStack

• http://wiki.openstack.org/MailingLists

Page 22: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

22

Write blueprint/bug reports of your own

http://blueprints.launchpad.net/${project_name}

Report new features/requirements you need

Page 23: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

Commit http://wiki.openstack.org/GerritWorkflow

Page 24: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

24

Key takeaway

One code patch should

• be on one git branch

• be about one blueprint/bug report

• have a decent git commit message

Git commit message should

• consist of title, [blueprint/bug link], description

• align with the blueprint/bug description

• align with fixes done on your code patch

How to write a git commit message

• Write about HOW and WHY you fixed the source code

Code patches must be submitted by git-review

Page 25: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

25

Git commit message example

Remove DB access from compute

Implements bp no-db-compute

The description of a blue print should be placed here

Fixes console/vmrc_manager.py import error

Fixes bug #1028748

The description of a bugfix should be placed here

Less than 50 char

Page 26: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

26

Send your code patch for review

Update the master branch and rebase your branch to master

• git checkout master

• git fetch origin

• git pull origin master

• git checkout ${your_branch}

• git rebase –i master

You absolutely must run unittests before submission!

• Run “./run_tests.py”

Use git-review to submit code patch

• git checkout ${your_branch}

• git review

Page 27: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

27

Some tips for using Git

Git commands

• Everyday GIT With 20 Commands Or So

git-review options and functionalities

• git review –-help

More details about git

• man git

Page 28: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

28

Some tips for writing Python code

Best Python tutorials – read every page

• http://docs.python.org/tutorial/index.html

• http://docs.python.org/library/index.html

PEP8

• Read it once everyday till you memorize all examples

HACKING.rst

• Coding conventions for OpenStack projects

• Placed in base directory of every project

• Built upon PEP8

Page 29: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

Review

Page 30: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

30

Key takeaway

Take responsibility for your submits

• Respond professionally to your comments

• Not everyone lives on the same timezone

When your not sure

• you understand a comment, ask anyone via IRC

• about your code, find help for review via IRC

How to download a patch to your local machine

$ git review –d 10774

Page 31: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

31

Replying to a comment

1

Page 32: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

32

Replying to a comment

2

3

4

Page 33: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

33

Replying to a comment

5

Page 34: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

34

Replying to a comment

7

6

Page 35: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy

35

Summary

Contribute code to have others contribute to you

Do the prerequisites

Get involved in the community and assign work to yourself

Write formal git commit message with your patch

Respond professionally to your review comments

Page 36: Assign, commit, and review - A developer’s guide to OpenStack contribution-2012osac-lzy