Continuous Integration
Continuous Integration
1,
Which is NOT a benefit of CI ?
Productivity Increases(wrong)
no longer
2,
Release branches are created for resolving merge conflicts.
F
3,
Which is not a CI practice ?
Deploy
4,
Work Branch is also known as
none
5,
Feature branching is used to
Both(wrong)
user stories
6,
Git is a ___________________________ version control system.
Distributed
7,
Activities that are part of continuous integration
All
8,
Build can be triggered by a version control tool.
True
10,
Private builds are executed after moving the changes to version control.
False
11,
Release builds can be triggered
all(wrong)
By Polling for changes
12,
Pipeline break and build break is one and the same.
False
13,
is a measure of incoming dependencies.
Afferent
14,
is a .Net build tool.
Nant
15,
Complexity of a code is determined based on
CCN
16,
CCMetrics is used to identify
Code Complexity
17,
Efferent Coupling is a measure of
OD
18,
CI servers use the _________ expression to poll for changes.
PERL
19,
jabber is a
MP
20,
Which of these is not a valid build trigger ?
Parameterized trigger
21,
Staged builds include
Both
22,
Arrange in order- A. Running Unit Test B.Running Static Code Check C.Check for Code
Coverage D. Build Package
BACD
23,
Private builds can be triggered automatically.
False
24,
Which of these is not mandated for a CI pipeline ?
AC/FT(gave ac)
25,
It is a proven fact that reducing the CCN of code is known to reduce the number of errors or
bugs in the code.
True
26,
helps in differentiating the environments.
BS
27,
In a normal scenario, software from ____________ is deployed to production.
MB
28,
Which of the tools is not used for establishing a pipeline workflow ?
Team city
29,
What are the reasons for a build to fail ?
Build break
30,
Which is the first code analysis to be executed ?
Style Check
31,
Trunk is also known as
MainLine
32,
Team City:Build Scheduler
33,
_ is a continuous integration server.
Maven
34,
Control flow graph is used to calculate _______.
CC
35,
Which is the most important operational parameter in CI ?
36,
Commiting a code change, when the inspection fails , is perfectly fine as the code logic is
working fine anyway.
False
37,
Faster feedback can be received by
Staging Builds
38,
which of the tools is not mandated for integration in a CI pipeline ?
Chef
39,
Select a CI tool based on it's
Extendability
40,
Which of the following is an artifact repository ?
Nexus
41,
is a code coverage tool.
Cobertura
42,
Does CI pipeline need to have all the software development functionalities integrated in place ?
T
43,
code changes can be hidden,enabled or disabled using
FT
44,
Practice of developers integrating changes directly in the feature or work branches and
commiting the changes at the end to the mainline is known as
IB
45,
Functional testing can be automated using Jenkins.
F
46,
Feature toggle can be used in the following scenarios
All
47,
Component test is executed as part of _
Integration Build
48,
Capablility of your build system to handle an increase in the amount of code that it integrates
and analyzes is known as
BI
49,
How are component dependencies injected in a workflow ?
UT & BP
50,
CI pipeline consists of ______________.
Srtifacts
51,
Which is NOT true about continuous integration ?
Develop to test
52,
Select a CI tool based on it's
Extend
53,
Git, Mercurial and Subversion are centralized version control tools.
False
You can develop a good software regardless of the technology you are working on, by following
certain fundamental practices:
What is CI?
The earlier you catch defects, the cheaper they are to fix - David Farley
Continuous Integration (CI) is a software development practice, where developers will commit
(integrate) their code changes to a shared repository frequently.
Such commits must
ger automated builds and tests. Thus enabling quick verification of the changes at an early
stage of the development cycle,
rather than waiting to detect bugs after the code is completely developed.
Why CI?
Continuous Integration does not get rid of bugs, but it does make it easier to find and remove.
When developers cultivate the habit of integrating their code changes regularly:
Changes will be typically small.
Errors can be detected quickly.
Pointing out the change that introduced an error can be done quickly.
CI Services
Continuous Integration includes the following :
CI worflow
DEv team->code->VCS->build->SCAnalysis->UT->Code Coverage Analysis->build artifact->
setup text picturs->deploy to test->Functional test->publish reports to devteam
Local
Centralized
Distributed
Developers :
clone the central base in to their local machine.
create work branch from the local base.
do the changes in the work branch.
merges the changes in the work branch to local base.
synchronize the local base with the central base.
All the current existing version control tools support branches or codeline.
Branch : An independent line of work that stems out from a central code base.
Types :
Owner must define the branch policy ( when a code should be checked in ).
Mainline Branch
Mainline branch must be stable always ,so that code is in Ready to deploy state.
Ready to deploy implies, that the code has successfully passed tests like integration, regression
etc,.
Release Branch
Change done on release branch must flow back to mainline.
Release branch must be closed after a new release from the mainline.
Work Branch
Work or development branch is where the developer compiles the code , integrates and runs
tests.
What if your team is implementing multiple changes in parallel on the work branch ?
How to Handle Parallel Changes?
Publishing to mainline is easy, when only one change is implemented at a time.
Consider the scenario when 2 developers are working on the same work branch:
Either deveoper B must wait until both changes are complete and then publish to mainline.
Or prioritize the changes. Publish the top priority change first to mainline. Then merge the other
change with local version control.
Merge down the code from work branch to your development region as often as possible
Check in changes to the work branch frequently
What if, there are other teams that are working on separate work branches that ends up
publishing to the mainline ?
Team A removes the use of library and publishes the change to mainline.
Team B continues to use the library.
How to handle the merge issue in this case ?
Team that discovers the conflict is responsible to sort out the conflict.
Release Branch
A high priority bug got detected post user-release, what has to be done now ?
Create a release branch from the mainline based on the time it was released.
Merging or commiting changes frequently is a top practice, that lays as a backbone of CI.
Version control helps a developer to plan and execute changes in a seamless manner.
Uses of Branching
Branching helps in parallel development. Work can be done on 2 or more work streams
simultaneously, without affecting one another.
Uses of branching:
Branching Techniques
Next few cards will help you understand the various branching techniques that teams will adapt
based on their need.
Branch by Feature.
Branch by Release.
Branch by Team.
All the 3 types of branches, mainline, work and release discussed in the version control section
must be used at appropriate places in each of these techniques.
Branch by Feature
Branch by Team
Used in a large team that works on functionally independent areas.
Mainline must be in a releasable state.
Branch is created for every team.
Merged with mainline only when the branch is stable.
Merge done to mainline from any given branch must be published to every other branch.
Run all tests (including integration tests) on mainline every time a branch is merged with it.
Branch by Abstraction
Trunk (mainline) based development.
Mainline is always stable and ready for deployment.
Used for making large-scale changes incrementally.
How it works?
Promote the changes in your stream to the common ancestor of all the streams that needs the
change.
IBM Clearcase and AccuRev are popular stream based version control systems.
Central Repository
Loading image..
All the assets that are required to build like, library, DLLs, configuration files are centralized in to
the central repository.
To maintain central repository effectively:
use a consistent directory structure in the central repository, which enables you to retrieve only
the required files.
Create folders for design, requirement, implementation, testing etc,.
For integration build, fetch required files from implementation folder.
Build Scripts
As soon as a change is moved in to version control, it is a recommended CI practice to build
immediately.
Build is of 3 types :
Private Build
Integration Build
Release Build
Private Build
Run by the developer before commiting the code changes to the local version control or work
branch.
Integration Build
Integrates changes committed on the work branch with the mainline.
Code compilation, unit test, component test, system and performance test along with
inspections are executed as part of this build.
Release Build
Deploys code to production or end-user.
Includes extensive load and performance tests along with user acceptance tests.
Build Mechanism
On-Demand : Build initiated manually.
If the build runs for a longer duration, it may delay the reporting and fixing of errors. So stage
the builds (split builds logically).
As a recommended practice :
You might have come across this quote: A code that cannot be tested is flawed.
Testing Strategy
Categorize your tests ( unit, system, component ).
Schedule the build based on the test category. Different intervals needs to be planned for slow
running tests.
Inspection Activities
Code review plays a crucial role in maintaining overall quality of a code base. This must be part
of the build.
Leverage automated inspectors like JavaNCSS or CCMetrics to identify piece of the code that is
highly complex.
Complexity determined by Cyclomatic Complexity Number (CCN).
It is the measure of :
Assess code coverage, identify percentage of code executed on running a test ( using tools like
NCover, Cobertura, Clover ).
Determine if a package is highly dependent on other packages, measured using Afferent and
Efferent coupling.
Build Metrics
Build metrics plays a crucial role to help reduce the build duration.
Compilation time : Time taken to compile the software, compares with the past compile times.
Number of source lines of code : (SLOC) Systems size or size of what has to be compiled.
Test execution time: Time taken to perform testing at each level like unit, component and
system.
Analyze Metrics
Capture and analyze the metrics to determine what improvement must be done to reduce the
build duration.
Broken Build
If any activity that is performed as part of the build fails, then build is considered broken.
Risks addressed by CI
Following CI effectively and efficiently helps reduce the following risks :
Selecting a CI tool is highly dependent on the environment, size and functionality of the project.
CI Tools Contd.
Java build scheduler - Jenkins, Cruisecontrol
Static code analysis : SonarQube, Checkstyle, PMD
Course Summary
To summarize, we have learnt the following in this course :