0
AMIR BARYLKO                                 EASY                            AUTOMATION                             FOR EV...
WHO AM I?    • Quality               Expert    • Architect    • Developer    • Mentor    • Great             cook    • The...
RESOURCES    • Email: amir@barylko.com    • Twitter: @abarylko    • Blog: http://www.orthocoders.com    • Materials: http:...
WHO NEEDS                            AUTOMATION?Amir Barylko - CodeCamp 2011              MavenThought Inc.Sunday, Februar...
EVERY DAY PROJECT SETUP    • Repetitive              task (project structure, scripts, etc)    • Source                con...
MANUAL SETUP    • Get          the last project, copy, paste & delete    • Use          documentation and follow instructi...
WHAT’S WRONG?    • Lengthy               process (waste)       • Very   hard to maintain    • Hard            to reproduce...
WHAT TO DO?    • Avoid  It works on my                        • Scripts   for every task!        computer!                ...
ONE STEP AT A TIME                                   Project skeleton                                  Build Automation   ...
PROJECT SKELETONAmir Barylko - CodeCamp 2011                   MavenThought Inc.Sunday, February 27, 2011
FOLDER STRUCTURE    •   MediaLibrary        --- MavenThought.MediaLibrary.sln : Main solution file        --- Rakefile: Ma...
BUILD AUTOMATIONAmir Barylko - CodeCamp 2011               MavenThought Inc.Sunday, February 27, 2011
BUILD TOOLS    •Batch files    • MSBuild (XML)    • NAnt (better XML)    • FinalBuilder (Visual)    • VisualBuild (Visual) ...
ARE YOU NUTS? RUBY?    • The          best tool for the job    • What              does it mean to be a developer?    • Ru...
RAKE    • Domain                Specific Language    • Great, great, great           .... grandchild of make    • Is     ju...
ALBACORE    • Basic           functionality for .NET projects    • OpenSource    • Active                Development    • ...
BASIC RAKEFILE    require rubygems    require albacore    require rake/clean    include FileUtils    solution_file = FileL...
BASIC RAKEFILE II    desc Default build    task :default => ["build:all"]    namespace :build do         desc "Build the p...
SETUP DEPENDENCIESAmir Barylko - CodeCamp 2011                 MavenThought Inc.Sunday, February 27, 2011
MANY OPTIONS    • Store            dependencies in source control (not recommended)    • Use          Nuget and then store...
BUNDLER    • Define                 Gemfile with dependencies    • Run “bundle                install”    • Create          ...
GEMFILE    source :rubygems    group         :setup do      gem         albacore      gem         git      gem         noo...
COPY LOCAL                            DEPENDENCIES    desc Setup requirements to build and deploy    task :setup => ["setu...
TEST AUTOMATIONAmir Barylko - CodeCamp 2011                  MavenThought Inc.Sunday, February 27, 2011
UNIT TESTS    • Each           project has a separate testing project    • Clear            naming convention (MavenThough...
RUN TESTS    desc "Run all tests"    task :test => ["test:all"]    namespace :test do         desc Run all tests         t...
CI SETUPAmir Barylko - CodeCamp 2011              MavenThought Inc.Sunday, February 27, 2011
BENEFITS OF CI    • Integrate              code frequently    • Trigger               events (deployment, etc)    • Valida...
MANY OPTIONS          TeamCity      •Team System Build server      •Hudson      •CruiseControl.NETAmir Barylko - CodeCamp ...
TEAM CITY    • Very           easy to use    • Free           for 20 projects & 3 agents    • Web             Based    • A...
PUSH CHANGESAmir Barylko - CodeCamp 2011               MavenThought Inc.Sunday, February 27, 2011
CLEAR PROCESS    • Branch                per feature    • Commit                 often    • Merge                 changes ...
GOING ALL THE WAY                                   Static Analysis Tools                                      Deployment ...
TOOLSAmir Barylko - CodeCamp 2011           MavenThought Inc.Sunday, February 27, 2011
STATIC ANALYSIS    • StyleCop    • FxCop    • Code              Coverage    • Dependencies    • SimianAmir Barylko - CodeC...
STYLECOP    namespace :tools do        desc "Runs stylecop and generates a report on the Output folder"        task :style...
DEPLOYMENTAmir Barylko - CodeCamp 2011                MavenThought Inc.Sunday, February 27, 2011
ASSEMBLY VERSION    • Use          SVN revision    • Combine                 Major.Minor.Build.Revision    • Update Assemb...
ACCEPTANCE TESTSAmir Barylko - CodeCamp 2011                   MavenThought Inc.Sunday, February 27, 2011
RUNNING CUCUMBER    • Start           the server    • Setup             database    • Run           the scenario    • Stop...
QUESTIONS?Amir Barylko - CodeCamp 2011                MavenThought Inc.Sunday, February 27, 2011
RESOURCES    • Email: amir@barylko.com    • Twitter: @abarylko    • Presentation: http://www.orthocoders.com/presentations...
RESOURCES II    •Ruby Installer: http://www.ruby-lang.org/en/downloads/    •Rake: http://rake.rubyforge.org/    •Albacore:...
RESOURCES III    •MSBuild :http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx    •NAnt :http://nant.sourceforge.net/   ...
Upcoming SlideShare
Loading in...5
×

every-day-automation

464

Published on

Presentation done at CodeCamp Winnipeg

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
464
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "every-day-automation"

  1. 1. AMIR BARYLKO EASY AUTOMATION FOR EVERY DAY PROJECTS WINNIPEG CODE CAMP FEB 2011Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  2. 2. WHO AM I? • Quality Expert • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  3. 3. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentationsAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  4. 4. WHO NEEDS AUTOMATION?Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  5. 5. EVERY DAY PROJECT SETUP • Repetitive task (project structure, scripts, etc) • Source control setup • Testing setup • Database setup • Deployment setupAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  6. 6. MANUAL SETUP • Get the last project, copy, paste & delete • Use documentation and follow instructions (ha! good one!) • Use the IDE to build • Copy the assemblies, etc to where • Database connection centralized or hardcodedAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  7. 7. WHAT’S WRONG? • Lengthy process (waste) • Very hard to maintain • Hard to reproduce • Complex for larger teams • Usually no documented • Hard to deploy • The architect just moved to • High dependency with the another country IDE • Coupled to the environmentAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  8. 8. WHAT TO DO? • Avoid It works on my • Scripts for every task! computer! • Continuous integration • Use application skeletons • TDD & BDD • End to end setup from day one! • Clear feature development process • Always in deliverable stateAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  9. 9. ONE STEP AT A TIME Project skeleton Build Automation Test Automation CI setup Push Changes (commit)Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  10. 10. PROJECT SKELETONAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  11. 11. FOLDER STRUCTURE • MediaLibrary --- MavenThought.MediaLibrary.sln : Main solution file --- Rakefile: Main rake file to launch build, test, etc. +-- main: Project files (sources) +-- test: Test project files +-- features: Features used by Capybara + Cucumber +-- lib2: Dependencies that cant be installed with bundler +-- tools: Tools used to run tests, xslt, etc.Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  12. 12. BUILD AUTOMATIONAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  13. 13. BUILD TOOLS •Batch files • MSBuild (XML) • NAnt (better XML) • FinalBuilder (Visual) • VisualBuild (Visual) • Rake (Ruby) • BooBS (Boo Build System) • Psake(Powershell)Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  14. 14. ARE YOU NUTS? RUBY? • The best tool for the job • What does it mean to be a developer? • Ruby is a great scripting language • Need something? There is a gem for that....Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  15. 15. RAKE • Domain Specific Language • Great, great, great .... grandchild of make • Is just Ruby • Lots of gems (libraries) availableAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  16. 16. ALBACORE • Basic functionality for .NET projects • OpenSource • Active Development • Very easy to useAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  17. 17. BASIC RAKEFILE require rubygems require albacore require rake/clean include FileUtils solution_file = FileList["*.sln"].first project_name = "MavenThought.MovieLibrary" CLEAN.include("main/**/bin", "main/**/obj", "test/**/obj", "test/**/bin") CLOBBER.include("**/_*", "lib/*", "**/*.user", "**/*.cache", "**/*.suo")Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  18. 18. BASIC RAKEFILE II desc Default build task :default => ["build:all"] namespace :build do desc "Build the project" msbuild :all, :config do |msb, args| msb.properties :configuration => args[:config] || :Debug msb.targets :Build msb.solution = solution_file end desc "Rebuild the project" task :re => ["clean", "build:all"] endAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  19. 19. SETUP DEPENDENCIESAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  20. 20. MANY OPTIONS • Store dependencies in source control (not recommended) • Use Nuget and then store them in SC • Use openwrap • Use gems + bundlerAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  21. 21. BUNDLER • Define Gemfile with dependencies • Run “bundle install” • Create task to setup .NET dependencies under libAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  22. 22. GEMFILE source :rubygems group :setup do gem albacore gem git gem noodle end group :dev do gem sharptestsex gem gallio, ~> 3.2 gem rhino.mocks, ~> 3.6 gem structuremap.automocking, ~> 2.6.1.1 gem maventhought.testing gem maventhought.commons endAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  23. 23. COPY LOCAL DEPENDENCIES desc Setup requirements to build and deploy task :setup => ["setup:dep:local"] namespace :setup do namespace :dep do Noodle::Rake::NoodleTask.new :local do |n| n.groups << :runtime n.groups << :dev end end endAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  24. 24. TEST AUTOMATIONAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  25. 25. UNIT TESTS • Each project has a separate testing project • Clear naming convention (MavenThought.Core.Tests) • Enforce TDD when possible • Automate since day one (even with empty tests)Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  26. 26. RUN TESTS desc "Run all tests" task :test => ["test:all"] namespace :test do desc Run all tests task :all => [:default] do tests = FileList["test/**/bin/debug/**/*.Tests.dll"].join " " system "./tools/gallio/bin/gallio.echo.exe #{tests}" end endAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  27. 27. CI SETUPAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  28. 28. BENEFITS OF CI • Integrate code frequently • Trigger events (deployment, etc) • Validate build • Regression tests (unit, integration, acceptance)Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  29. 29. MANY OPTIONS TeamCity •Team System Build server •Hudson •CruiseControl.NETAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  30. 30. TEAM CITY • Very easy to use • Free for 20 projects & 3 agents • Web Based • Awesome UI • Supports: Rake, MsBuild, Nant, etc....Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  31. 31. PUSH CHANGESAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  32. 32. CLEAR PROCESS • Branch per feature • Commit often • Merge changes from trunk often • Automate commit (to avoid mistakes)Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  33. 33. GOING ALL THE WAY Static Analysis Tools Deployment Acceptance Tests AutomationAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  34. 34. TOOLSAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  35. 35. STATIC ANALYSIS • StyleCop • FxCop • Code Coverage • Dependencies • SimianAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  36. 36. STYLECOP namespace :tools do desc "Runs stylecop and generates a report on the Output folder" task :stylecop do mkdir "Output" unless File.directory? "Output" stylecop = "tools/stylecopcmd/StyleCopCmd" # Run the StyleCopCmd from tools sh "#{stylecop} -sf #{solution_file} -ifp AssemblyInfo.cs -of..." sh "tools/Xslt/msxsl.exe Output/stylecop.violations.xml ...." xmldoc = Document.new(File.new("Output/stylecop.violations.xml")) violations = XPath.first(xmldoc, "/StyleCopViolations/Violation") abort "Stylecop Failed!" unless violations.nil? end endAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  37. 37. DEPLOYMENTAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  38. 38. ASSEMBLY VERSION • Use SVN revision • Combine Major.Minor.Build.Revision • Update AssemblyInfo.cs • Build in release • Deploy to a folder as a zipfileAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  39. 39. ACCEPTANCE TESTSAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  40. 40. RUNNING CUCUMBER • Start the server • Setup database • Run the scenario • Stop the serverAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  41. 41. QUESTIONS?Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  42. 42. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Presentation: http://www.orthocoders.com/presentations • Source Code: https://github.com/amirci/democc_2011Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  43. 43. RESOURCES II •Ruby Installer: http://www.ruby-lang.org/en/downloads/ •Rake: http://rake.rubyforge.org/ •Albacore: https://github.com/derickbailey/Albacore •Noodle: https://github.com/spraints/noodle •MavenThought Testing: https://github.com/amirci/mt_testing • TeamCity: http://www.jetbrains.com/teamcity/download/ • Capybara: https://github.com/jnicklas/capybaraAmir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  44. 44. RESOURCES III •MSBuild :http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx •NAnt :http://nant.sourceforge.net/ •FinalBuilder: http://www.finalbuilder.com/ •VisualBuild: http://www.kinook.com/VisBuildPro/ •BooBS:http://code.google.com/p/boo-build-system/ •Psake: https://github.com/JamesKovacs/psake •Powershell: http://bit.ly/ehQcTb •TFS: http://msdn.microsoft.com/en-us/vstudio/ff637362Amir Barylko - CodeCamp 2011 MavenThought Inc.Sunday, February 27, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×