Introduction to Continuous integration

22
Continuous Integration Lior Tal Automation Developer

description

Introduction for my dev team to start practicing continuous integration.

Transcript of Introduction to Continuous integration

Page 1: Introduction to Continuous integration

Continuous Integration

Lior TalAutomation Developer

Page 2: Introduction to Continuous integration

Continuous Integration Automated Builds Tools DVCS (Git)

Agenda

Page 3: Introduction to Continuous integration

Continuous Integration

How good is our code? I think it’s pretty good…

Does the code work? I tested it, it seems to do what it should…

Does the code have bugs? I hope not…

Page 4: Introduction to Continuous integration

Continuous Integration

Need to simplify complex integration of code Need a good criteria for measuring our code

quality Need to have “Self-testing” code

Page 5: Introduction to Continuous integration

“a software development practice where members of a team integrate their work frequently, leading to multiple integrations per day.Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible.

Continuous Integration

Page 6: Introduction to Continuous integration

Developer checks in new code An automated build is kicked off with all

latest code changes Unit tests and [optional] other tools are

executed Developer receives a notification if the build

succeeded or failed [optional] Failing commits are rejected from

the source code repository

Continuous Integration

Page 7: Introduction to Continuous integration

The code should build directly from source control

The code should be built in a single automated command

This makes it easier in multiple scenarios: New developer joins the team Code is built automatically on a build server

Automated Builds

Page 8: Introduction to Continuous integration

Build script can be created using standard technologies MSBuild Batch file

Multiple build configurations should be defined “Small” build that runs on every check in

Should be very fast “Big” build that runs nightly

Can have a bigger scope (build MSI, run integration tests)

Automated Builds

Page 9: Introduction to Continuous integration

Many tools can be integrated into the build process

Some examples (.NET): Code Coverage – Coverage (in %) by unit tests. Code Duplications – find duplicated code Code Analysis

StyleCop – Find styling errors in code FXCop – Static code analysis

Tools

Page 10: Introduction to Continuous integration

Tools – Code Coverage

Page 11: Introduction to Continuous integration

Tools – Code Coverage

Page 12: Introduction to Continuous integration

Define a set of styling rules:

These can be run from the IDE or from a build script

Show warnings/errors when compiling:

Tools - StyleCop

Page 13: Introduction to Continuous integration

Many tools can be integrated into the build process

Some examples (.NET): Code Coverage – Coverage (in %) by unit tests. Code Duplications – find duplicated code Code Analysis

StyleCop – Find styling errors in code FXCop – Static code analysis

Tools – FXCop

Page 14: Introduction to Continuous integration

Older VCS tools are centralized (central server model) Subversion, ClearCase

Centralized tools suffer from a few issues: Network latency (server needed for most

operations). Submitting “half-ready” code can break other

people’s work.

DVCS (Git)

Page 15: Introduction to Continuous integration

Many modern VCS tools are distributed This means a central server is optional Each developer gets a copy of the entire

repository A central server can still be setup

Used as a sync point for team members

DVCS (Git)

Page 16: Introduction to Continuous integration

Git offers a command line tool (comes from Linux)

On Windows: Shell Extension Visual Studio integration using plugins

DVCS (Git)

Page 17: Introduction to Continuous integration

Git offers a command line tool

On Windows: Shell Extension Visual Studio integration using plugins

DVCS (Git)

Page 18: Introduction to Continuous integration

Git Workflow

Centralized Workflow

Page 19: Introduction to Continuous integration

Git Workflow

Integration-Manager

Page 20: Introduction to Continuous integration

CI Implementation #1

CI Server

Build Agent

TeamCity Source

Control (Git)

CI Build

Nightly Build

Page 21: Introduction to Continuous integration

CI Implementation #1

What we gained: Basic framework for more complicated tasks Source control contains a “clean” copy of the

code Fast notification on build issues Starting to incorporate basic unit tests Installer (.MSI) creation is automatic Using a modern source control system (Git)

Page 22: Introduction to Continuous integration

CI Implementation #2

CI Server

Build Agen

t

Git

CI Build

Nightly Build

Build Agen

t

Build Agen

t

VM Server

Win7 x64

Win7 Win XP…