Continuous Integration
Improving Software Quality And Reducing Risk
Build Software Every Change
• Build may consist of the compilation, testing,
inspection, and deployment.
• CI scenario typically go like
– Developer commits code to version control repository
– CI server detects that changes have occurred in the
version control repository, and then executes a build
script
– CI server generate feedback by e-mailing build results
to specified project member
– CI server continues to poll for changes in the version
control repository
Continuous Integration : Improve Software Quality And Reduce Risk
CI Components
• Version Control Repository
• CI Server
• Build Script
• Feedback Mechanism
• Integration
Build Machine
Continuous Integration : Improve Software Quality And Reduce Risk
Features of CI
• Source Code Compilation
• Database Integration
• Testing
• Inspection
• Deployment
• Document and Feedback
Continuous Integration : Improve Software Quality And Reduce Risk
How could you know you are doing CI correctly?
• Are you using a version control repository (or SCM tool)?
• Is your project’s build process automated and
repeatable? Does it occur entirely without intervention?
• Are you writing and running automated test?
• Is the execution of your tests a part of your build
process?
• How do you enforce coding and design standards?
• Which of your feedback mechanisms are automated?
• Are you using a separate integration machine to build
software?
Continuous Integration : Improve Software Quality And Reduce Risk
What is the value of CI?
• Reduce risks
– Defects are detected and fixed sooner
– Health of software is measurable
– Reduce assumption
• Reduce repetitive manual processes
– The process runs the same every time
– An ordered process is followed
– The processes will run every time a commit occurs in the version control
repository
• Generate deployable software at any time and at any place
• Enable better project visibility
– Effective decisions
– Noticing trends
• Establish greater confidence in the software product from the
development team
Continuous Integration : Improve Software Quality And Reduce Risk
What prevents teams from Using CI?
• Increased overhead in maintain the CI
system
• Too much change
• Too many failed builds
• Additional hardware/software cost
• Developers should be performing these
activities
Continuous Integration : Improve Software Quality And Reduce Risk
How Do I Get to “Continuous” Integration?
• Identify – Identify a process that requires
automation
• Build – Creating a build script makes the
automation repeatable and consistent
• Share – By using a version control system
• Continuous – Ensure that the automated
process is run with every change applied
Continuous Integration : Improve Software Quality And Reduce Risk
Is it Continuous Compilation or Continuous Integration?
• How much code coverage do you have
with your test?
• How long does it take to run your builds?
• What is your average code complexity?
• How much code duplication do you have?
• Are you labeling your builds in your
version control repository?
• Where do you store your deployed
software?
Continuous Integration : Improve Software Quality And Reduce Risk
How does CI complement other development practices?
• Developer testing
• Coding standard adherence
• Refactoring
• Small release
• Collective ownership
Continuous Integration : Improve Software Quality And Reduce Risk
CI and you
• Commit code frequently
• Don’t commit broken code
• Fix broken builds immediately
• Write automated developer tests
• All tests and inspections must pass
• Run private builds
• Avoid getting broken code
Continuous Integration : Improve Software Quality And Reduce Risk
Risk: Lack of Deployable Software
• Scenario: “It works on My Machine”
– Solution: Use a CI server along with an automated
build using tools such as Ant, NAnt, or Rake
• Scenario: “Synching with the Database”
– Solution: Place all database artifacts in your version
control repository
• Scenario: “The Missing Click”
– Solution: Using script to automate the deployment
process
Continuous Integration : Improve Software Quality And Reduce Risk
Risk: Late Discovery of Defects
• Scenario: Regression Testing
– Solution: Using unit test at the business, data,
and common layers and run continuously as a
port of your CI system
• Scenario: Test Coverage
– Solution: Running test coverage tool to
assess the amount of source code that is
actually executed by the tests
Continuous Integration : Improve Software Quality And Reduce Risk
Risk: Lack of Project Visibility
• Scenario: Did you Get the Memo
– Solution: Automated mechanism that sends e-
mails to affected parties when a build fails
• Scenario: Inability to Visualize software
– Solution: Automated code documentation tool
Continuous Integration : Improve Software Quality And Reduce Risk
Risk: Low-Quality Software
• Scenario: Coding standard adherence
– Solution: Using Checkstyle and PMD to report any
lines of code that were not meeting the established
standards
• Scenario: Architectural Adherence
– Solution: Using analysis tools such as JDepend or
NDepend
• Scenario: Duplicate Code
– Solution: Automated inspection tools such as PMD’s
CPD or the Simian static analysis tools
Continuous Integration : Improve Software Quality And Reduce Risk
Build Types and Mechanisms
• Build Type
– Private Build
– Integration Build
• Commit build
• Secondary build
– Release Build
• Build Mechanisms
– On demand
– Scheduled
– Poll for changes
– Event-driven
Continuous Integration : Improve Software Quality And Reduce Risk
Integration build Scalability and Performance
• Gather build metric
• Analyze build metric
• Choose and perform improvements
• Reevaluate; repeat if necessary
Continuous Integration : Improve Software Quality And Reduce Risk
Continues Database Integration
• Automate Database Integration
• Use a local database sandbox
• Use a version control repository to share
database asset
• Give developer the capacity to modify
database
• Make the DBA part of the development
team
Continuous Integration : Improve Software Quality And Reduce Risk
Automate Unit tests
• Unit test verify the behavior of small
elements in software system
• Mocks are simple object that substitute for
real, more complicated object
• The key aspect for unit test is having no
reliance on outside dependecies
Continuous Integration : Improve Software Quality And Reduce Risk
Automate Component tests
• Component or subsystem test verify
portions of a system and may require a full
installed system or same external
dependencies
• Component level test use more
dependencies than unit test but still not
necessarily as many as high level system
tests
• This type of test is also commonly refer to
as an integration test
Continuous Integration : Improve Software Quality And Reduce Risk
Automate System tests
• System test exercise a complete software
system and therefore require a full
installed system
• System test are fundamentally different
form functional test, system test much like
a client would use the system
Continuous Integration : Improve Software Quality And Reduce Risk
Automate Functional tests
• Functional tests test the functionality of an
application from the view point of a client,
known as acceptance tests
Continuous Integration : Improve Software Quality And Reduce Risk
Continuous Inspection
• Code Review can be impressively
effective; however, they are run by
humans, who tend to be emotional
• Pair Programming has also been shown to
be effective when applied correctly
• Automated static code analysis scales
more efficiently than humans for large
code bases
Continuous Integration : Improve Software Quality And Reduce Risk
What is the different between inspection and testing
• Testing is dynamic and executes the
software in order to test the functionality
• Inspection analyze the code based on a
set of predefined rules
• Example of inspection targets include
coding “grammar” standards, architectural
layering adherence, code duplication, and
so on
Continuous Integration : Improve Software Quality And Reduce Risk
Reduce Code Complexity
• Cyclomatic Complexity Number (CCN) is a plain
integer that measure complexity by coding the
number of distinct paths through a method
• Various studies with this metric over the years
have determined that methods with CCN greater
than 10 have a higher risk of defects
• The most effective way to reduce cyclomatic
complexity is to apply the extract method
technique
Continuous Integration : Improve Software Quality And Reduce Risk
Perform Design Reviews Continuously
• Afferent Coupling, Fan In, an object has
responsibility to too many other objects
(high afferent)
• Efferent Coupling, Fan Out, the object isn’t
sufficiently independent of other objects
(high efferent)
• Instability = Efferent Coupling/(Efferent
Coupling + Afferent Coupling)
Continuous Integration : Improve Software Quality And Reduce Risk
Maintain Organization Standards with Code Audits
• Coding standard facilitate a common
understanding of a code base among a diverse
group of developer
• Human code reviews and pair programming can
be effective in monitoring coding standards, they
do not scale as well as automated tools
• Popular code analysis tool for Java platform is
PMD
• Reduce Duplicate Code using PMD-CPD or
Simian
Continuous Integration : Improve Software Quality And Reduce Risk
Assess Code Coverage
• Line coverage, statement coverage, indicates
that a particular line of code was exercised
• Branch coverage measure the coverage of
decision points
• Test run slower than they do in nocoverage
scenarios; It may be appropriate to run code
coverage tools as part of a secondary, more
heavyweight build
Continuous Integration : Improve Software Quality And Reduce Risk
Continuous Deployment
• Release working software any time, any
place
• Label a repository’s assets
• Produce a clean environment
• Label each build
• Run all tests
• Create build feedback reports
• Possess capability to roll back release
Continuous Integration : Improve Software Quality And Reduce Risk
All the Right Stuff
• Send the right information to the right
people at the right time and in the right
way
Continuous Integration : Improve Software Quality And Reduce Risk
Continuous feedback mechanisms
• Email
• SMS
• Ambient Orbs
• Windows taskbar monitor
• Sound
Continuous Integration : Improve Software Quality And Reduce Risk
CI Resources
• CI Tools/Product Resources
– AnthillPro
– Apache Continuum
– Bamboo
– BuildForge
– Contiuous Integration Server Matrix
– Cruise Control/Cruise Control.NET
– Draco.NET
– Gauntlet
– LuntBuild/PMEase QuickBuild
– ParaBuild
Continuous Integration : Improve Software Quality And Reduce Risk
CI Resources
• Build Scripting Resources
– Ant
– Groovy
– Maven
– NAnt
– Rake
• Version Control Resources
– ClearCase
– Concurrent Versions System
– SubVersion
Continuous Integration : Improve Software Quality And Reduce Risk
CI Resources
• Testing Resource
– Agitator
– DbUnit
– Fit
– FitNesse
– Floyd
– HtmlUnit
– Junit
– JWebUnit
– NDBUnit
– Nunit
– Selenium
– TestNG
Continuous Integration : Improve Software Quality And Reduce Risk
CI Resources
• Automated Inspection Resources
– CheckStyle
– Clover
– Cobertura
– EMMA
– FindBugs
– FxCop
– JavaNCSS
– JDepend
– NCover
– NDepend
– PMD
– Simian
– SourceMonitor
Continuous Integration : Improve Software Quality And Reduce Risk
CI Resources
• Deployment Resources
– Capistrano
• FeedBack Resources
– Ambient Devices
– Google Talk
– Jabber
– X10
• Documentation Resources
– Doxgen
– JavaDoc
– NDoc
Continuous Integration : Improve Software Quality And Reduce Risk
Evaluating tools
• Build tools - Essential Functionality
– Code compilation
– Component packaging
– Program execution
– File manipulation
• Build tools - Extended Functionality
– Development test execution
– Version control tool integration
– Documentation generation
– Deployment functionality
– Code quality analysis
– Extensibility
– Mutiplatform builds
– Accelerated builds
Continuous Integration : Improve Software Quality And Reduce Risk
Evaluating tools
• Build Schedulers – Essential Functionality
– Build execution
– Version control integration
– Build tool integration
– Feedback
– Build labeling
• Build Schedulers – Extended Functionality
– Interproject dependencies
– User interface
– Artifact publication
– Security
Continuous Integration : Improve Software Quality And Reduce Risk
Evaluating tools
• Compatibility with your environment
– Does the tools support your current build
configuration?
– Does the tool require installation of additional
software in order to run?
– Is the tool written in the same language as
your project?
• Reliability
• Longevity
• Usability
Continuous Integration : Improve Software Quality And Reduce Risk
Continuous Integration : Improve Software Quality And Reduce Risk