Continuous Integration and development environment approach

64
Continuous Integration and Engineering Environment approach Aleksandr Tsertkov

Transcript of Continuous Integration and development environment approach

Page 1: Continuous Integration and development environment approach

Continuous Integration and Engineering Environment approach

Aleksandr Tsertkov

Page 2: Continuous Integration and development environment approach

CONTINUOUS INTEGRATIONContinuous Integration provides quick feedback on recent code changes

Page 3: Continuous Integration and development environment approach

Continuous Integration

• Software engineering practice, where project is build frequently

• Emerged in the Extreme Programming (XP) community

Page 4: Continuous Integration and development environment approach

Continuous Integration

• Build is made by automated build tools like: make, Ant, Maven, etc.

• Automated tests results and software metrics are collected for each build

• Build process is executed and results published on CI server

Page 5: Continuous Integration and development environment approach

Build

CI server executes build scripts regularly:

– Predefined delay is used to execute build scripts. Every one hour for example

– CI server regularly checks SCM system and in case of changes made since last build time a new build is made

Page 6: Continuous Integration and development environment approach

Build status

• Each build has a status: successful or failed

• Build is considered as successful if all build tasks were executed without errors and failed otherwise

• Automated tests are executed as build tasks

Page 7: Continuous Integration and development environment approach

Build status

• Build status may be reported by email, IM, SMS, etc.

Page 8: Continuous Integration and development environment approach

Build artifacts

• Each build receives unique number. Build artifacts are published with this number.

Page 9: Continuous Integration and development environment approach

Build artifacts

• Build artifacts are different from project to project but usually they include:

– Binaries: installation package, application files, …– Generated documentation: API, end-user

documentation, …– Unit test results: time taken, code coverage, …– Software metrics: LOC changes, PMD, CRAP index,

coding standards violations, …

Page 10: Continuous Integration and development environment approach

Binary packages

Binary packages produced by build process may include:

– Installation packages– Executable binaries– Etc.

Page 11: Continuous Integration and development environment approach

Documentation

• Usually API documentation is compiled during build and is published within other artifacts

• End-user documentation also may be compiled and published accordingly to project needs

Page 12: Continuous Integration and development environment approach

API Documentation

Page 13: Continuous Integration and development environment approach

Code coverage

• Code coverage used to show which lines of source code has been tested with unit tests

• 100% code coverage is a required but not a sufficient criteria for measuring test quality

Page 14: Continuous Integration and development environment approach

Code coverage

Page 15: Continuous Integration and development environment approach

Code coverage

Page 16: Continuous Integration and development environment approach

Coding standards violations

• Strict coding standards in a project help to improve reading and understanding of code and raise maintainability

• With help of specialized tools coding standards may be checked as part of build process

Page 17: Continuous Integration and development environment approach

Software metrics

A software metric is a measure of some property of a piece of software or its specifications.

– LOC - Lines Of Code– PMD – Project Mess Detector– C.R.A.P. – Change Risk Analysis and Predictions– Code coverage

Page 18: Continuous Integration and development environment approach

Advantages

• Early notification about integration errors• Early warning about broken code• Immediate unit testing of all changes• Constant availability of build packages

including: testing, demo, beta, etc.• Collected software metrics focus developers

on producing high quality code

Page 19: Continuous Integration and development environment approach

Software

• A wide range of CI software is available providing different notification medias, SCM systems, build tools support and IDE integration:

– CruiseControl– Bamboo– Hudson– BuildBot– Etc.

Page 20: Continuous Integration and development environment approach

CruiseControl

CruiseControl is an extensible framework for creating continuous build process:

– It includes dozens of plugins for a variety of source controls, build technologies, and notifications schemes including email and instant messaging

– A web interface to view details and access artifacts of builds

Page 21: Continuous Integration and development environment approach

CruiseControl

CruiseControl is written in Java but is used on a wide variety of projects thanks to different build tools supported:

– Ant, NAnt, Maven, Phing, Rake, Xcode– “exec” builder which can be used with any

command-line tool or script

Page 22: Continuous Integration and development environment approach

CruiseControl

• May be used with C/C++ since build tasks can be wrapped into Ant tasks

• CppUnit or CxxTest can be used as unit testing framework

Page 23: Continuous Integration and development environment approach

Generic Visual C++.NET Ant target

Page 24: Continuous Integration and development environment approach

CruiseControl

Page 25: Continuous Integration and development environment approach

phpUnderControl

phpUnderControl is customization of CruiseControl that brings functionality needed for PHP projects:

– PHPUnit– PHPDocumentor– PHP_CodeSniffer– …

Page 26: Continuous Integration and development environment approach

phpUnderControl

Page 27: Continuous Integration and development environment approach

phpUnderControl

Page 28: Continuous Integration and development environment approach

phpUnderControl

Page 29: Continuous Integration and development environment approach

phpUnderControl

Page 30: Continuous Integration and development environment approach

phpUnderControl

Page 31: Continuous Integration and development environment approach

PEER CODE REVIEWImproves code quality and aids software developers professional growth

Page 32: Continuous Integration and development environment approach

Code review

• Code review is a process of checking programming code for common mistakes, vulnerabilities, bugs and errors.

• Code might be reviewed by author, team members or 3rd party company providing code review service.

Page 33: Continuous Integration and development environment approach

Code review

Several common types of code review:– Formal inspection – code is reviewed on a

projector by a team of reviewers– Over-the-shoulder review where author walks the

reviewer though a set of code changes– E-mail pass-around – whole files or changes are

packed up by the author and sent to reviewers via email

– Tool assisted – specialized code review tools are used

Page 34: Continuous Integration and development environment approach

Peer code review

• Systematic examination of code individually by each reviewer.

• Usually developers are able to review each other code in a small team, but it’s better to set rules for handling review process roles.

Page 35: Continuous Integration and development environment approach

Peer code review best practices

• Review fewer than 200-400 lines of code at a time

• Take enough time for a proper, slow review, but not more than 60-90 minutes

• Verify that defects are actually fixed

Page 36: Continuous Integration and development environment approach

Advantages

• Helps to identify bugs early• Encourages collaboration and builds a team• Helps in keeping code maintainable• Improves code quality• Improves cross team know-how• Shares experience within a team• Improves developers professional skills

Page 37: Continuous Integration and development environment approach

Peer code review software

• Reviewboardhttp://code.google.com/p/reviewboard/

• Cruciblehttp://www.atlassian.com/software/crucible/

• CodeCollaborator http://smartbear.com/

Page 38: Continuous Integration and development environment approach

Reviewboard

Page 39: Continuous Integration and development environment approach

CodeCollaborator

Page 40: Continuous Integration and development environment approach

Crucible

• Web based peer code review tool• Simplified workflow• Integrates with Fisheye and JIRA since it is

ATLASSIAN’s product• Pre and post commit reviews are supported• Integration into Eclipse & IntelliJ IDEA

Page 41: Continuous Integration and development environment approach

Crucible

To start a new review Crucible allows:

– Selecting concrete revision, for example the most recent commit in Subversion or revision identified by number or date

– Selecting individual files and folders (even from different revisions)

Page 42: Continuous Integration and development environment approach

Crucible

Supports email notification of:

– Review requests– Review comments– Review actions (close, etc.)

Page 43: Continuous Integration and development environment approach

Crucible

Page 44: Continuous Integration and development environment approach

Crucible

Page 45: Continuous Integration and development environment approach

ENGINEERING ENVIRONMENT

Page 46: Continuous Integration and development environment approach

Engineering environment

Our engineering environment approach was specially designed for web development though some subsystems may be utilized for non-web development as well.

Environment is based on dedicated server where project code is developed and tested – remote environment.

Page 47: Continuous Integration and development environment approach

Environment components

• CI: CruiseControl + phpUnderControl• Peer code review: Crucible• SCM system: Subversion• Development web servers• Database, memcached, etc.• Development tools

PhpMyAdmin, PHPUnit, PHPDocumentor

Page 48: Continuous Integration and development environment approach

Environment components

• Each component is highly tuned to simplify it’s use and speed up development

• Subversion hooks are used to apply validation rules on committed code and send on-commit notifications to the team

• Web server components are configured accordingly to project requirements

Page 49: Continuous Integration and development environment approach

Remote environment

• Code is developed, tested and stored on a remote dedicated server

• Each developer has isolated environment where he has good control over his vhosts configuration

Page 50: Continuous Integration and development environment approach

Key points

• Environment similar to production (server OS, cron jobs, tools and software)

• Abstracts developers from occasional need in environment reconfiguration since this is made only once by server admin

• Possibility to send links to development/current/demonstration version of project

Page 51: Continuous Integration and development environment approach

Key points

• Build automation, continuous integration

• Engineering tools suite: debugging tools, common frameworks and libraries, unit testing suite, build tools, database management tools

• Centralized backup

Page 52: Continuous Integration and development environment approach

Subversion

Subversion is used as Version Control System and provides following benefits:

– IDE integration– Access over WebDav (web browser)– Hooks system

Page 53: Continuous Integration and development environment approach

Subversion over WebDav

Page 54: Continuous Integration and development environment approach

Subversion Hooks

• Subversion hooks system allows to execute custom program on some repository event.

• With post-commit hooks we send on-commit emails notifying team about changed made in the repository.

• Pre-commit hooks are used to validate coding standards and apply other rules.

Page 55: Continuous Integration and development environment approach

Subversion on-commit email

Page 56: Continuous Integration and development environment approach

Subversion pre-commit script

Page 57: Continuous Integration and development environment approach

Remote development

• Every developer has a separate account on development server with access over SSH

• Remote files might be accessed via:– SFTP/SCP– FTP/FTPS– Samba (Windows network share)

Page 58: Continuous Integration and development environment approach

Samba share mounted

Page 59: Continuous Integration and development environment approach

Private namespace (subdomains)

• Every developer has full control over subdomains of USERNAMENAME.dev.gface.de

• Subfolders in ~/vhosts/are automatically mapped to domain names:

Document root Domain name~USERNAME/vhosts/PREFIX.htdocs/~smith/vhosts/htdocs/ ~smith/vhosts/cms.htdocs/~smith/vhosts/v2.cms.htdocs/

PREFIX.USERNAME.dev.example.comsmith.dev.example.com cms.smith.dev.example.com v2.cms.smith.dev.example.com

Page 60: Continuous Integration and development environment approach

Development web servers

• Several development web servers with different configurations and- or modules may run on dev server.

• With help of reverse proxy it is possible to switch between servers by simply prefixing domain name with server identificator.

Page 61: Continuous Integration and development environment approach

Development web servers

Page 62: Continuous Integration and development environment approach

Development web servers

Three web servers are running on one machine with different versions of PHP installed

Hostname Proxied tosmith.dev.example.comphp52.smith.dev.example.comphp53.smith.dev.example.comphp6.smith.dev.example.com

smith.dev.example.com:8081smith.dev.example.com:8081smith.dev.example.com:8082smith.dev.example.com:8083

Web server Port Domain name prefixPHP-5.2 (default)PHP-5.3PHP-6

808180828083

php52.php53.php6.

Page 63: Continuous Integration and development environment approach

Questions?

Page 64: Continuous Integration and development environment approach

Thank You!