102
Core Principles of CI STPcon 1

Core Principles Of Ci

Embed Size (px)

DESCRIPTION

Slides for the CI Tutorial delivered at STPcon 2009.

Citation preview

Page 1: Core Principles Of Ci

Core Principles of CISTPcon

1

Page 2: Core Principles Of Ci

Intro

2

Page 3: Core Principles Of Ci

Who Am I?• Principal of OpenSource

Connections

• Contributer to CruiseControl and Continuum CI projects

• Member of Apache Software Foundation

• Presenter at conferences (OSCON, ApacheCON, jTDS, ExpoQA, STPcon)

• Fascinated by the art of software development

3

Page 4: Core Principles Of Ci

Author

4

Page 5: Core Principles Of Ci

Father

5

Page 6: Core Principles Of Ci

Agilista

6

Page 7: Core Principles Of Ci

Schedule

Core Principles of CI

Break

Hudson to the Rescue

Agile and CI

9 to 10:15

15 minutes

10:30 to 11:15

11:15 to 12

7

Page 8: Core Principles Of Ci

Rules of the Road

• Cell phones on Silent.

• Ask Questions!

• Feel free to get up and move around the room.

8

Page 9: Core Principles Of Ci

What is CI?

9

Page 10: Core Principles Of Ci

Conceptual

10

Page 11: Core Principles Of Ci

Definition

a fully automated and reproducible build, including testing, that runs many times a day - Martin Fowler

http://martinfowler.com/articles/continuousIntegration.html

11

Page 12: Core Principles Of Ci

Martin Fowler

• Coined the term Continuous Integration

• Chief Scientist for ThoughtWorks

• Speaks and Blogs on software:

• http://martinfowler.com/

12

Page 13: Core Principles Of Ci

Mapping

diagram credit to Brian Di Croce @ http://blog.briandicroce.com/2008/03/17/setting-up-a-continuous-integration-environment-preface/

13

Page 14: Core Principles Of Ci

Activity

Turn to the person next to you, and see how many non-obvious things you have in common.

14

Page 15: Core Principles Of Ci

Arm Bands!• Elisabeth Hendrickson is

TestObsessed.com

• Focuses on Testing in the Agile community

• Really great blogger: Specialized Test Management Systems are an Agile Impediment and Adventures with Auto-Generated Tests and RSpec are typical posts

15

Page 16: Core Principles Of Ci

CI in a nutshell

16

Page 17: Core Principles Of Ci

Demo

17

Page 18: Core Principles Of Ci

People

18

Page 19: Core Principles Of Ci

Version Control Repository

19

Page 20: Core Principles Of Ci

CI Server

20

Page 21: Core Principles Of Ci

Build Script

• Automated Script is Key!

• Needs to be robust and simple

21

Page 22: Core Principles Of Ci

Feedback Mechanism

From: [email protected] Subject: [CruiseControl] agenda_direcciones build 370 fixed Date: October 7, 2008 2:22:50 PM EDT To: [email protected]

The build has been fixed.

CHANGES-------New revision 370 detectedRevision 370 committed by epugh on 2008-10-07 18:22:03mysql esta mejor que sqlite M /branches/ERIC_EXPO_08_DEMO/agenda_direcciones/config/database.yml

See http://cruise.opensourceconnections.com:3333/builds/agenda_direcciones/370 for details.

22

Page 23: Core Principles Of Ci

photo credit to Jay Grieves @ www.bigswingingdeveloper.com

23

Page 24: Core Principles Of Ci

Aspects of CI

24

Page 25: Core Principles Of Ci

Source Code Compilation

• Eclipse “Export to War” is NOT the solution

25

Page 26: Core Principles Of Ci

Database Integration• Database is integral to

your code

• DDL, stored procedures are treated as source

• Involve your DBA in your project

• DBUnit for Java projects!

• Don’t require a multi gig database file to run tests!

• Look at techniques like fixtures or mock objects to reduce database coupling

• Developers need database sandbox

26

Page 27: Core Principles Of Ci

Testing• Testing proves the intent

of the programmer was met.

• Typically provides the “checkability” that James Bach talks about

• Multiple Levels of testing

with out testing, CI is just a glorified compiler- Eric Pugh

27

Page 28: Core Principles Of Ci

Inspection• Code Coverage

• Code Complexity

• Copy’n’pasting

• Architectural Standards

• Lint Checking

• Static Analysis

28

Page 29: Core Principles Of Ci

Deployment

• Turns what is normally a difficult process into a non event...

• ant deploy

• Simplifies standup new environments

29

Page 30: Core Principles Of Ci

Documentation

30

Page 31: Core Principles Of Ci

Feedback• Email

• IRC

• Devices

• Blog Posts

• Twitter Notifications

• Tray Icons

31

Page 32: Core Principles Of Ci

So What is the Value?

32

Page 33: Core Principles Of Ci

Life with out CI• Unstable code, integration is difficult

• Many build errors reported

• Only one person on the team can build the entire project

• Getting “test ready” product is hard

• Feedback cycle is long

• Same bug keeps coming back

Every day is a struggle to be productive33

Page 34: Core Principles Of Ci

Life with CI

• The build process is simple and repeatable

• Elimination of Human Error

• Bugs stay fixed!

• Feedback cycle is very rapid

Every day you know you can produce better software!34

Page 35: Core Principles Of Ci

Risk Reduction

• What is in the build?

• What has changed between builds?

• How do I verify functionality?

35

Page 36: Core Principles Of Ci

Reduce Human Error

36

Page 37: Core Principles Of Ci

My Ah-hah! moment

37

Page 38: Core Principles Of Ci

Reduce Repetitive Processes

• DRY: Don’t Repeat Yourself

• Script Everything!

• “ant deploy”

38

Page 39: Core Principles Of Ci

Make Painful Things Painless!

photo credit to Paul Duvall @ http://www.integratebutton.com/

39

Page 40: Core Principles Of Ci

Produce Deployable Software

• It’s what we are here to do!

• Always in a “Demo Ready” state

• No last minute administrivia tasks to get the product ready

• Installer is built

• Documentation is written

• Changelog is written

40

Page 41: Core Principles Of Ci

Enable Project Visibility41

Page 42: Core Principles Of Ci

42

Page 43: Core Principles Of Ci

Increase Project Confidence

43

Page 44: Core Principles Of Ci

44

Page 45: Core Principles Of Ci

photo credit to ThoughtWorks

45

Page 46: Core Principles Of Ci

Facilitate Communication

46

Page 47: Core Principles Of Ci

photo credit to Eric Pugh @ www.opensourceconnections.com

47

Page 48: Core Principles Of Ci

48

Page 49: Core Principles Of Ci

49

Page 50: Core Principles Of Ci

Activity

Exquisite corpse (also known as "exquisite cadaver" or "rotating corpse") is a method by which a collection of words or images is

collectively assembled, the result being known as the exquisite corpse or cadavre

exquis in French.

50

Page 51: Core Principles Of Ci

What Prevents Teams from Using CI?

51

Page 52: Core Principles Of Ci

Cultural Challenges

52

Page 53: Core Principles Of Ci

Fear of Commitment

• Developers and Testers need to commit changes frequently!

• Incremental small changes make finding integration issues simpler

drawing credit to Tom Armitage @ http://infovore.org/archives/2007/03/14/the-continuous-integration-barometer/

53

Page 54: Core Principles Of Ci

This isn’t 198454

Page 55: Core Principles Of Ci

Fear of Blame55

Page 56: Core Principles Of Ci

• CI needs a champion who acts as the ambassador to the leaders of the organization.

• Thought leaders in the organization who can help encourage team to accept the process changes that CI brings

• A very successful test case

• A greenfield project if possible

56

Page 57: Core Principles Of Ci

57

Page 58: Core Principles Of Ci

Structural Challenges

58

Page 59: Core Principles Of Ci

Testability• Modularity?

• Coupling to underlying platform?

• Requires external services to be up and available for testing?

• Perform code complexity analysis to see if some parts are more amenable to testing.

59

Page 60: Core Principles Of Ci

Tight Coupling

photo credit to Jay Grieves @ www.bigswingingdeveloper.com

60

Page 61: Core Principles Of Ci

CI Tool Stability Challenges

61

Page 62: Core Principles Of Ci

Invest in CI Server• The CI system must be as well

maintained as the Source Control system.

• The CI system performs builds very quickly.

• Who has responsibility for CI? It’s very important to have a “throat to choke”.

• No false alarms. If there are false alarms then the team loses confidence in the CI system.

X✓

62

Page 63: Core Principles Of Ci

Monkey CIphoto credit to Eric Pugh @ www.opensourceconnections.com

63

Page 64: Core Principles Of Ci

When Should You Adopt CI?

64

Page 65: Core Principles Of Ci

From good CI

to

great CI!

65

Page 66: Core Principles Of Ci

10 minute rule

photo credit to Jay Grieves @ www.bigswingingdeveloper.com

66

Page 67: Core Principles Of Ci

Multi Stage CI

• Reduce the amount of integration required

• Teams integrate as modules are marked as ready.

• Maven2 was built with this in mind!

Damon Poole @ http://damonpoole.blogspot.com/2008/01/advanced-multi-stage-continous.html

67

Page 68: Core Principles Of Ci

Break up Tests

• “preflight” or “smoke” tests

• longer integration tests

• periodic full site generation and report generation

68

Page 69: Core Principles Of Ci

Predictive Testing

• Some commercial tools support predicting which tests will fail based on previous behavior, and running those first!

69

Page 70: Core Principles Of Ci

Cup of Coffee Metric

• Builds shouldn’t take any longer!

• Getting a cup of coffee or drink of water breaks up your day

• Gives you a chance to review your work

• Requires a moduler fast build

http://pauljulius.com/blog/2009/09/14/cup-of-coffee-metric-for-continuous-integration/

What happens in the time it takes to get a cup of coffee can tell you a lot about the quality of your continuous integration system. - Paul Julius

70

Page 71: Core Principles Of Ci

Paul Julius

• co-founder of CITCON

• Original developer of CruiseControl

• Speaks and Blogs on CI extensively

• http://pauljulius.com/blog/

71

Page 72: Core Principles Of Ci

Virtuous Circle

• Metrics are hard to get

• Teams (Developers?) rebel against on high management

• Need good processes that support and encourage other good processes

72

Page 73: Core Principles Of Ci

HackyStat

73

Page 74: Core Principles Of Ci

CI isn’t one specific method

74

Page 75: Core Principles Of Ci

Enterprise CI Maturity Model

!"#$%&"!''!()*+,"$-!).$/

!"#$%&'"()*+,-'&*+.#)/"

0)*'1$#)*+,-'&*+2$1('3)

.4&'*+

.4-51)+643#54&

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

?-#4+!@)1-#)+,-'&*+.#)/"

0)/)3*)31A+:)/4"'#45A

,-'&*+6&-"#)5

643#'3-4-"+,-'&*"

95$1B'3C+!"#$%&!'(#%)*

.)1-5)+!"#$%&!'(#%)*

,-'&*+D54E+>2+.3$/"(4#"

!"#$%#&

'

!F!2!89.+;D+!89!:G:7.!+67

!"#$%&'()*&)+(&,%-$(.(/0$&12&3"-+(/-4&3)5$6&78/-$.".$(!""#$%%&&&'()"!*++#,-'.-/%!"/+%,01-2,.01%&!*"03#(#0,1

H)&/)5+.15'/#"

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

D-&&A+.15'/#)* .)&IJ.)5K'1)+9)"#+0)/&4A"

?-#4+0)/&4A+#4+;3)+!3KL

24"#&A+.#$3*$5*'M)*

G-"(J,-##43+G54*+0)/&4AE)3#

N$#)*O+?-#4E$#'1+G54E4#'43"

D-&&A+.#$3*$5*'M)*+0)/&4A"

?-#4E$#'1+G54*-1#'43+0)/&4A"

!"#$%

&'(

)

.4E)++9)"#+?-#4E$#'43

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

:)C5)""'43+9)"#"+:-3+P'#(+,-'&*

.4E)+.#$#'1+?3$&A"'"+<")*

?-#4E$#)*+D-31#'43$&+9)"#"

!@#)3"'K)+<3'#+9)"#"

!@#)3"'K)+?-#4E$#)*+D-31#'43+9)"#"

:'"BJ,$")*+2$3-$&+9)"#"

.)1-5'#A+.1$3"

QRRS+9)"#+64K)5$C)

!"#!$%

&

944&J,$")*+:)/45#"

>'"'%'&'#AT+:)/45#+:-33)5

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

.'&4)*+:)/45#'3C

G-%&'"(+F$#)"#+:)/45#"

H'"#45'1$&+:)/45#"

654""+D-31#'43+:)/45#+?11)""

,$"'1+:)/45#+?3$&A"'"

95)3*'3C

654""J.'&4?3$&A"'"

G5)*'1#'K)24*)&'3C

!"#$!%&'

(

Came out of discussions at 2009 CITcon. Developed by Eric

Minick of UrbanCode

75

Page 76: Core Principles Of Ci

!"#$%&'"()*+,-'&*+.#)/"

0)*'1$#)*+,-'&*+2$1('3)

.4&'*+

.4-51)+643#54&

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

?-#4+!@)1-#)+,-'&*+.#)/"

0)/)3*)31A+:)/4"'#45A

,-'&*+6&-"#)5

643#'3-4-"+,-'&*"

95$1B'3C+!"#$%&!'(#%)*

.)1-5)+!"#$%&!'(#%)*

,-'&*+D54E+>2+.3$/"(4#"

!"#$%#&

'

76

Page 77: Core Principles Of Ci

H)&/)5+.15'/#"

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

D-&&A+.15'/#)* .)&IJ.)5K'1)+9)"#+0)/&4A"

?-#4+0)/&4A+#4+;3)+!3KL

24"#&A+.#$3*$5*'M)*

G-"(J,-##43+G54*+0)/&4AE)3#

N$#)*O+?-#4E$#'1+G54E4#'43"

D-&&A+.#$3*$5*'M)*+0)/&4A"

?-#4E$#'1+G54*-1#'43+0)/&4A"

!"#$%

&'(

)

77

Page 78: Core Principles Of Ci

.4E)++9)"#+?-#4E$#'43

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

:)C5)""'43+9)"#"+:-3+P'#(+,-'&*

.4E)+.#$#'1+?3$&A"'"+<")*

?-#4E$#)*+D-31#'43$&+9)"#"

!@#)3"'K)+<3'#+9)"#"

!@#)3"'K)+?-#4E$#)*+D-31#'43+9)"#"

:'"BJ,$")*+2$3-$&+9)"#"

.)1-5'#A+.1$3"

QRRS+9)"#+64K)5$C)

!"#!$%

&

78

Page 79: Core Principles Of Ci

944&J,$")*+:)/45#"

>'"'%'&'#AT+:)/45#+:-33)5

789:;0<69;:= 8;>76! 789!:2!07?9! ?0>?86!0 78.?8!

.'&4)*+:)/45#'3C

G-%&'"(+F$#)"#+:)/45#"

H'"#45'1$&+:)/45#"

654""+D-31#'43+:)/45#+?11)""

,$"'1+:)/45#+?3$&A"'"

95)3*'3C

654""J.'&4?3$&A"'"

G5)*'1#'K)24*)&'3C

!"#$!%&'

(

79

Page 80: Core Principles Of Ci

What about People?

80

Page 81: Core Principles Of Ci

CI on a Dollar a Day

• Build Computer

• Ridiculous Toy

• Annoying Bell

• Automated Build

• Group Agreement

"From now on, our code in revision control will always build successfully and pass its tests.". - James Shore

http://jamesshore.com/Blog/Continuous-Integration-on-a-Dollar-a-Day.html

81

Page 82: Core Principles Of Ci

credit to Paul Julius @ http://www.anthillpro.com/blogs/anthillpro-blog/2009/09/11/enterprise_ci_cultural_maturity.html

82

Page 83: Core Principles Of Ci

Lots of advanced

techniques!

credit to Christine Mitterbauer @ Microdoc

83

Page 84: Core Principles Of Ci

Perils of CI

84

Page 85: Core Principles Of Ci

Getting too focused on Green Bar

Glare of the Green Bar in CI can obscure issues with your product- James Bach

85

Page 86: Core Principles Of Ci

Making CI the core of too many systems

86

Page 87: Core Principles Of Ci

Making decisions based on your available

tooling

87

Page 88: Core Principles Of Ci

Selecting a CI System

88

Page 89: Core Principles Of Ci

Approaches

• Big Hand Rolled System

• Cloud Based Solution

• Completely Hosted

89

Page 90: Core Principles Of Ci

Hand Rolled SystemPros Cons

Complete control of configuration

Rolling your own can take more work

Data and code inside firewall

Dealing with disparate platform elements is harder

Works with any type of system

Multiple kinds of projects can be hard to manage

CheapestMust provide Sys Admin

work

90

Page 92: Core Principles Of Ci

Cloud Based SolutionPros Cons

Very Scalable Data and Code outside firewall

Use CPU resources only when needed

Cloud computing still new

Deal well with multiple kinds of projects

GUI apps hard to test

?Must provide Sys Admin

work

92

Page 93: Core Principles Of Ci

CI in a Box

• Amazon EC2 Hosted instance

• http://www.ciinabox.com/

93

Page 94: Core Principles Of Ci

Hosted SolutionPros Cons

Very Scalable Typically limited in language support

No Sys Admin tasks data and code outside firewall

Pricing is fairly straightforward

GUI apps hard to test

? vendors are still new

94

Page 95: Core Principles Of Ci

RunCodeRun.com

95

Page 96: Core Principles Of Ci

MikeCI.com

96

Page 97: Core Principles Of Ci

Where to Next?

97

Page 98: Core Principles Of Ci

CITCON

• Open Spaces Style

• Twice a year, US and International

• Raleigh-Durham, NC, April 2010

• http://www.citconf.com/

98

Page 99: Core Principles Of Ci

99

Page 100: Core Principles Of Ci

CI Yahoo Group

http://tech.groups.yahoo.com/group/citcon/

100

Page 101: Core Principles Of Ci

The Book Continuous Integration:

Improving Software Quality and Reducing Risk

101

Page 102: Core Principles Of Ci

The CI guys http://ci-guys.com/

Free online consulting

102