Version Control and Continuous Integration

Preview:

DESCRIPTION

This is Greg Montaño's slides on "Version Control and Continuous Integration", which was presented at the Cebu StackOverflow Meetup on 26 May 2012.

Citation preview

Version Control and Continuous Integration

THE STACKOVERFLOW MEETUP – CEBUMAY 26, 2012

emxsi

Introduction

• Batch, Pascal, PERL, Javascript, C++, JAVA

• DUNE2

• Shell Scripts• Modern Conflict

• University Faculty • Employee - IT Company

• I love to visit all the nearby islands of Cebu.

Expectations

• Introduce version control and CI• Focus only on Subversion and Jenkins• Discuss about installation and getting started

with these tools.• Sharing of personal experiences pertaining to

the tools mentioned is also encouraged during the Q&A.

Version Control

• Also known as revision control.

• According to http://www.smashingmagazine.com/ the most obvious benefit of revision control is– ability to have an unlimited number of people

working on the same code base, without having to constantly send files back and forth.

Models of Version Control Software

• Local data Model

• Client-Server Model

• Distributed Model

Version Control in the Market

• Proprietary– BitKeeper– PVCS– Synergy– Perforce– ClearCase– Visual SourceSafe– Rational Team Concert

Version Control in the Market

• Open Source– Concurrent Versions System (CVS)– Subversion (SVN)– Distributed Concurrent Versions System (DCVS)– Bazaar – Mercurial– Git

Subversion

• Triggered development by CollabNet, Inc in early 2000• Took 14 months to develop• Became part of ASF's family of top-level projects on

early 2010.

• Book titled Version Control with Subversion can be found and/or downloaded at

http://svnbook.red-bean.com/• Subversion current version is 1.7

SUBVERSION'S ARCHITECTURE

Subversion repository

Repository access URLs Schema Access method

file:/// Direct repository access (on local disk)

http:// Access via WebDAV protocol to Subversion-aware Apache server

https:// Same as http://, but with SSL encryption

svn:// Access via custom protocol to an svnserve server

svn+ssh:// Same as svn://, but through an SSH tunnel

5 steps to getting started (Version Control)

1. Download and install2. Create the repository3. Set-up authentication4. Customize (e.g. pre-commit hooks)5. Perform maintenance like backups

Create the repository

• Create the directorymkdir –p /var/www/svn

• Create the repocd /var/www/svnsvnadmin create myrepo

• Access the repo via httphttp://143.143.143.143/svn/myrepo

Content of subversion.conf

LoadModule dav_svn_module modules/mod_dav_svn.so

LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/httpd/svn-users.passwd Require valid-user</Location>

Structure of SVN Repository

• trunk - directory to hold the “main line” of development;

• branches - directory to contain branch copies;• tags - directory to contain tag copies;

Customize

• Use of hooks like pre-commit• The pre-commit hook is run just before a

commit transaction is promoted to a new revision.

• Useful for freezing a release and/or requiring for log messages before revisions are committed to the repository.

• /var/www/svn/myrepo/hooks/pre-commit

Backups

• Full backupsvnadmin hotcopy /var/www/svn/myrepo ~/repo-backuptar cjvhpf repo-backup.bz2 ~/repo-backup

• Incrementalsvnadmin dump /var/www/svn/myrepo –r 143:HEAD --

incremental > `date +%s`.dump

Subversion Best Practices

1. Use a sane repository layout2. Commit logical changesets3. Use the issue-tracker wisely4. Provide meaningful log message5. Know when to branch

Continuous Integration (CI)

• implements continuous processes of applying quality control — small pieces of effort, applied frequently.

• a set of software development practices, behaviors, and principles for automating and improving how to integrate and certify software continuously.

• Started around 1999

Why use CI?

• to deliver stable, high-quality code consistently and quickly;

• detect and fix problems early;• deliver quality software; • reduce time to market of the finish product;

0% interest

Buy Now Pay Later

Principles

• Maintain a Single Source Repository• Automate the Build• Make Your Build Self-Testing• Everyone Commits To the Mainline Every Day• Every Commit Should Build the Mainline on an Integration

Machine• Keep the Build Fast• Test in a Clone of the Production Environment• Make it Easy for Anyone to Get the Latest Executable• Everyone can see what's happening• Automate Deployment

CI in the Market

• Proprietary– Build Forge– AnthillPro– BuildMaster– TeamCity

CI in the Market

• OpenSource– CruiseControl– Jenkins/Hudson

4 steps to getting started (Jenkins)

1. Download and install2. Create and configure the project/job3. Run your first build4. Customize

http://jenkins-ci.org/

Configure Jenkins

New job/project

Plug-ins

• Over 400 plug-ins• Source code management (e.g. Git, Mercurial)• Artifact uploaders (e.g. Tomcat, JBOSS,

Websphere)• Build Reports (e.g. Cobertura, Sonar, Ruby)• Authentication and user management• UI Plugins

Reasons for CI

• Reports Any Build Failures to the Team• Reduces the Risk of Integrating Code

Private builds –> integration builds –> release builds

• Establishes Greater Confidence in the Product– Incorporated automated unit test in the build

• Improves the Efficiency of the Team

MAKE LIFE EASY FOR EVERYBODY

Salamat!

Reference:

• Internet

Recommended