Build Automation in Android

45
Build Automation for Mobile or How to Deliver Quality Apps Continiously Angelo Rüggeberg

description

GDG Munich 25.09.2014 Slides for my Talk about Continuous Delivery/Deployment in Android

Transcript of Build Automation in Android

  • 1. Build Automation for MobileorHow to Deliver Quality Apps ContiniouslyAngelo Rggeberg

2. 2Things to rememberPublishing your App should not bepainfullAngelo RggebergCode Quality MattersAngelo Rggeberg 3. 3Who am I? Mobile Development Android iOS Backend Cloud Infrastructurehttp://plus.google.com/+AngeloRggeberghttp://s3xy4ngyc.github.io/ s3xy4ngyc 4. 4Release ProcessCurrent Situation 5. 5Release ProcessCurrent Situation 6. 6Release Processthe futureEverything you have to do afterwards isgit push 7. 7Release Processthe future 8. 8Build AutomationWhat will we be usingjenkinsTest Driven DevelopmentGitBeta DistributionNightly VersionsGradle 9. 9Build AutomationBenefits New Features are Live ASAP As Soon As Pushed Only Stable and Tested Builds can be Pushed No more unstable Releases Less Human Testing No more Sharing of Sensitive Data Keystores Logins 10. 10Build AutomationJenkinsJenkins is an award-winning application that monitors executions of repeated jobs, such as Building/testing software projects continuously Monitoring executions of externally-run jobsGet Jenkins at: http://jenkins-ci.org/ 11. 11Build AutomationBuild Pipeline Sample Build Pipeline:compilelintTestssonarmonkeyrunnerdistribute 12. 12Build AutomationBuild Pipeline Distribution will only Happen if all Previous Steps Succeed Tests, Code Analysis, etc. can Run Parallel Step by Step enables Failing Fast Resource Hungry Jobs like Monkey Runner will be triggered only if needed 13. 13JenkinsUsefull Tipps Clone Workspace SCM Plugin Shared Workspaces may have locks https://wiki.jenkins-ci.org/display/JENKINS/Clone+Workspace+SCM+Plugin Polling Sucks use Git Hooks! Do not run on a Small Virtual Machine Android Emulator needs some Hardware Intel HAX strongly Recommended! 14. 14JenkinsBuild Monitor Plugin 15. 15JenkinsBuild Pipeline View Plugin 16. 16JenkinsMonitoring Plugins 17. 17Build Automationgradle Best of ANT / Maven / GANT / Ivy Based on Groovy Scripts Expressive DSL (Flexible) Convention over Configuration Easy to extend Make the impossible possible, make the possible easyand make the easy elegant. 18. 18gradleflavoring Staging, Dev and Live Packages On Your Test Device no Constant Uninstalling Adjustable Configurations without Code Changes Why? Reproduce able builds, easy setup 19. 19gradlesample Code 20. 20gradlesample CodeProject Setup Flavoring Same Folder Structure forevery Flavor Flavor Specific files OverwriteFiles from Main Only Overwrite What yourFlavor Needs Flavor Only Files Possible 21. 21gradlesample CodeExample Flavor Specific Manifest Only Provider defined Everything else comes from main/AndroidManifest.xml 22. 22Build Automationgit Branching Opensource Integrated and Extended Implementations 23. 23GitGit WorkflowGit Flow Branching Modelsource: www.atlassian.com 24. 24JenkinsGit Flow and Jenkins Examples Staging Hook on develop Branch Nightly Time Based Build (eg once a day at 0 AM) builds newest feature Branch Live Only Builds release Tags Release Notes are Tag Message 25. 25Beta Test Distribution 26. 26Beta Test DistributionExamples Google Play Alpha / Channel Works on every Device that has The Playstore Crashlytics Distribution Groups & User Level gradle Integration free HokeyApp Comercial 27. 27Unit TestingWHY?Testing - Do it 28. 28Unit TestingWHY? 29. 29Unit TestingWHY? Code Quality Matters! Insurance everything still works As it should be working Refactoring made easy Unittests are somehow a Functional Documentation 30. 30Unit TestingSome Tipps: Tests first! Simplest and dumbest way to implement Test Orientation Changes Test State Changes Lock Screen Incoming calls etc. Check Code Coverage 31. 31Test FrameworksUnittests Robolectric No Emulator Needed No Mocking Frameworks Needed API Level Emulation only up to 18 (currently) Robotium Silenium for Android User Scenarios Default Android Testing Framework 32. 32Test FrameworksUI Testing Espresso Ui Testing Double Espresso Espresso Gradle Port Ui Automator Android Default UI Testing Framework 33. 33Mocking 34. 34Test FrameworksDevice TestingDistributing instrumentation testshttp://square.github.io/spoon/ 35. 35Test FrameworksDevice Testing 36. 36Test FrameworksDevice Testing 37. 37Test FrameworksDevice Testing 38. 38Build AutomationMeasure Code Quality Measure Code Quality over TimeDuplicated code Coding standards Unit tests Complex code Potential bugs Comments Design and architecture 39. 39Test FrameworksCode Coverage 40. 40Test FrameworksCode Coverage 41. 41Build AutomationStatic Code Analysis 42. 42Build AutomationStatic Code Analysis Testing your Application makes your life more Stress free Code Quality Less Production Crashes Dont develop Stuff that should not go live Use Gradle Flavors! 43. 43Build AutomationFinal Thoughts Testing your Application makes your life more Stress free Code Quality Less Production Crashes Dont develop Stuff that should not go live DONE = RELEASED Use Gradle Flavors! 44. 44Release Processthe future 45. >> /etc/