Improving Software Quality with Continuous Integration Chris Farrell Quick Solutions.

Post on 23-Dec-2015

215 views 0 download

Transcript of Improving Software Quality with Continuous Integration Chris Farrell Quick Solutions.

Improving Software Quality with Continuous Integration

Chris FarrellQuick Solutions

Questions Anytime

• Ask questions whenever you want

What is CI?

• NOT a software program you install• NOT something you buy or pay for• NOT a new idea• NOT specific to .Net or Java• Is a set of process best practices applied during

development to– Reduce defects by doing QA during development– Improve productivity by automating manual tasks– Facilitate collaboration and teamwork

Who Created Continuous Integration

Why Do CI?

Source: http://www.riceconsulting.com/public_pdf/STBC-WM.pdf

Problems solved with CI

• Integration Hell• Difficult, Stressful

deployments• Human Error in Deployments• Late feedback from QA

Benefits of CI

• Reduced Cost• Improved Quality• Stable velocity• Easy, more accurate/consistent deployments• Can demo at any time• Can deploy at any time• Improved Transparency

#1 – Single Source Repository

• Everyone works from the same codebase *during* development

• Repository contains *all* needed files including SQL Scripts, Reports, Code, Dependencies, etc

• Tools: VSS, CVS, SVN, GIT, TFS,etc

#2 Automate the Build

• Make it so that anyone can build with a single command

• Build could involve multiple projects and dependencies– Multiple project build

• Automated Build should be able to build pieces AND the whole

Build Triggers

• Manual Build• Build on Check-In– CI server detects check-ins and triggers build

• Scheduled Build– Nightly Builds

#3 Make the Build Self Testing

• Does the latest version compile?• Quality Metrics – Performance, Test Coverage• Automated Tests– FX Cop Style Guidelines– UI/Functional Tests– Integration Tests– Unit Tests

#3 Tooling

• Build Tools– MS Build, Nant, Rake, Maven

• Unit Testing– Resharper, Nunit, MS Test, Gallio/MBUnit, etc

• Functional Testing– SpecFlow, Cuke4Nuke

• UI Testing– Microsoft Test Manager, WATIN, Selenium

#4 – Everyone Commits to the mainline every day

• “Mainline” does not mean prod• Typically you commit multiple times per day• Commit at least at end of day in case someone

is sick, a hard drive dies, workload shifts, etc• Anyone can get the latest code at any time• Provides support for versioning

#5 – Every Commit Should Build on an Integration Machine

• Ensures that all code to build the project has been checked in to source control

• Doesn’t need to be a high end PC. Can be a VM or an obsolete dev machine

#6 – Keep the Build Fast

• The entire point of CI is to provide fast and frequent feedback

• If the build is broken, you want to find out before someone else checks out broken code

• Short feedback cycles• For slow builds..prestage when needed

#7 – Test in a Clone of the Production Environment

• Should be a close as possible. Every difference is a risk that what works in QA will not work in Production

• Might involve testing on multiple targets• Should have similar– Database size– Quality of Test Data– Network Security Configuration– Server and Client Software

Database

Deploy to Production

Backup Database from

Prod

Copy Database to CI Server

Restore DB each build

Apply Migrations

#8 – Make it Easy for Anyone to Get the Latest Executable

• Business Analyst should be able to do Show & Tell at any time

• QA should be able to test at any time– QA can trigger builds

• Sales should be able to see current version

#9 – Everyone can see what is happening

• CI is about feedback and transparency• CI should provide visibility towards– Is the Build broken– Who checked in code, when, for what feature– Code Quality Metrics• Automated Test Results• Code Coverage• Performance Metrics

#10 Automate Deployment

• When you have to deploy at 5pm on Friday or 6am on Monday

• So your QA testers can test without asking you if the latest version is out

#10 – Automate Deployment

• CRITICAL– Deployment is a deliverable that needs to be

tested before deploying to production– Speed of Deployment– Labor Cost of Deployment– Accuracy of manual deployments– non-tech users must be able to deploy to test – target multiple environments for testing

• Greatly reduces deployment stress

#10 – Automate Deployment

• Automate *all* of deployment– Backup of Production– Database updates– Data Migrations– Code Deployment– Report Deployment

• Practice makes perfect!!!

Other Uses/Benefits

• Can use CI to automate almost anything– Data Migration Jobs– Backup local or remote data/files– Send Reports – Reset environments– Sync environments(ex move AD from Prod to Dev)

Selling CI

• Issue – Time/Cost to Setup• Issue – No access for automated deploy due to

politics/firewall• Issue – Sensitive data• Issue – Limited access to dev environment

Free VCS

• www.unfuddled.com– 200 mb free SVN & GIT

• www.gitHub.com– Free for public repositories/OSS

• www.assembla.com– Free private GIT repos(?2gb limit?)

• www.CodePlex.com– free TFS for OSS

• http://code.google.com/projecthosting/– 2gb GIT, Mercurial, SVN

• www.sourceforge.com

Popular CI Servers

– Hudson (Free)• http://hudson-ci.org

– Jenkins (Free)• http://jenkins-ci.org

– TeamCity (sort of free)• www.jetbrains.com/teamcity/• Free up to 20 build configurations/3 agents

– CruiseControl.Net (free)• http://cruisecontrol.sourceforge.net

– Team Foundation Server• Included with MSDN Pro and higher

Build Automation Tools

• MS Build– C:\

• Nant (port of Ant)– http://nant.sourceforge.net

• Rake(Ruby Make)– http://rake.rubyforge.org

Other Tooling

• SSRS Report Deployment– https://github.com/chrispfarrell/RsDeploy

• DB Comparision– Visual Studio 2010 Database Projects– RedGate SQL Compare($395)

• FluentMigrator

TFS Demo

• Work Item Tracking• Source Control• Project Mgmt Charts• CI Build– Unit Tests– Integration Tests

• Automated Deployment

Jenkins Demo

QSI is Hiring

Chris Farrell

• Website: www.chrispfarrell.com• Twitter: @chrispfarrell• Email: chrispfarrell@gmail.com