implementing continuous integration in .net for cheapskates
TRANSCRIPT
Implementing Continuous Integration in .NET for cheapskates
Matt Henroid@mhenroidNovember 13, 2015
3
• Intro to Continuous Integration• Environment Setup• Source Control• Automated Build• Build Server• Automated Testing• Automated Deployment
Agenda
4
cheapskateA stingy person. Somebody who buys cheap in favor of higher quality or better stuff. Even though they might be able to afford better…by verseguru August 20, 2004http://urbandictionary.com
What is a cheapskate?
5
frugal developerA developer who encourages• Saving money by favoring free, open source or
inexpensive but high quality tools whenever possible
• Saving time by automating processes as much as possible
• Saving yourself from disaster by mitigating the inevitable risk that comes with continuous changes to software projects.
What is a cheapskate?
6
• Code new features• Build, Test and Deploy* automatically• Repeat
* Deploy to test environment, not to production (i.e. continuous delivery)
What is Continuous Integration?
7
• Reduces integration problems• Reduce mistakes from manual processes• Promotes rapid feedback• Promotes testable software
Benefits of Continuous Integration
8
CI - It’s Not Rocket Science
9
• Practices– Things you and your team should do
• Automation– Eliminate repetitive boring work– Reduces human errors– Reproducible every time
• Tools– Numerous free / open source tools available
CI = Practices + Automation + Tools
10
• Purpose– Enable testing in multiple staged environments
• Practices– Create multiple environments
• Small project – DEV, INTG, PROD• Medium project – DEV, INTG, QA, PROD• Large project – DEV, INTG, QA, UAT, PROD
– Keep all environments similar– Automate server setup– Support data replication
Environment Setup
11
• Purpose– Keep track of all source code changes
• Practices– Store all artifacts required to build project– Fresh checkout should always be buildable– Avoid storing unnecessary artifacts
• Use ignore file / feature– Use package management to store
dependencies– Define branching / merging strategy– Commit early and often (daily, hourly)
Source Control
12
Source Control - Demo
https://github.com/mhenroid/CIDemo
13
• Purpose– Ensure build can be done without human
interaction• Practices
– Automate the entire build process– Use a build server to build on every commit– Keep the build fast– Don’t break the build– Fix broken builds immediately
Automated Build
PowerShell MSBuild
14
• Purpose– Watch for changes to source control– Perform build / test / deployment automatically
• Benefits– Provide stable, reproducible environment for
builds– Ensure no check-in breaks the build– Easily determine who broke the build– Reporting
Build Server
15
• NAnt / MSBuild• Cruise Control
Automated Build - Demo
16
• Purpose– Test your code continuously and automatically– Test conditions that may be difficult to
reproduce from UI• Practices
– Unit test – class / method level– Integration test – test multiple classes together– Enable tests to execute on build server– Use Code Coverage to verify test coverage– All tests should pass
Automated Testing
17
• Test Framework– MSTest
• Mock Framework– Moq
• Code Coverage– Open Cover
Automated Testing - Demo
18
• Purpose– Package project artifacts and deploy to
environment– Enables immediate testing on non-developer
machine• Benefits
– Reproducible– Deploy automatically– Testers can provide feedback more quickly– First step towards Continuous Delivery
Automated Deployment
19
Automated Deployment - Demo
20
Questions???