Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Integration

Dal Rupnik
February 05, 2015

Continuous Integration

A talk held at first CocoaHeads in Slovenia about Continuous Integration on iOS platform.

Dal Rupnik

February 05, 2015
Tweet

More Decks by Dal Rupnik

Other Decks in Programming

Transcript

  1. CONTINUOUS INTEGRATION 2 WORKFLOW - DEVELOPMENT This is usually our

    workflow. Our project work flow consists of roughly 5 big phases.  SPECS  SETUP  CODE  TEST  PUBLISH  Feedback from Client
  2. CONTINUOUS INTEGRATION 3 TOOLS - QUITE A FEW ON THE

    MARKET EACH PLATFORM
 IS SPECIFIC  CocoaPods Gradle Homebrew Jenkins Kiwi Bundler Mina Capistrano Composer Magallanes
  3. CONTINUOUS INTEGRATION 4 OUR FOCUS - WHAT WILL WE COVER

    Strive not to be a success, but rather to be of value.bears - Albert Einstein Today we will focus on test and publish phases. What is there that could speed up those phases in our workflow?
  4. CONTINUOUS INTEGRATION 6 TESTING - WHAT TEST CASES DO WE

    COVER There are three main types of tests on iOS. Each testing type has it’s specific tools, libraries and methods to work with. Unit Tests Test small components by separating it from larger modules.  Integration Tests Integrate components into modules and test them again working in together.  UI Tests Test user interfaces and animations on different screens and orientations. 
  5. CONTINUOUS INTEGRATION 7 UNIT TESTING - EASY AND CLEAR TESTING

     Xcode   XCTest Built in Xcode Kiwi Behaviour Driven Dev Specta & Expecta R-Spec BDD / TDD
  6. CONTINUOUS INTEGRATION 8 UNIT TESTING - CHOICE OF FRAMEWORKS -

    (void)testUsernameLoad { XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async"]; [view.user loadWithCompletion:^{ XCTAssertEqual(label.text, @"Foo"); [expectation fulfill]; } [self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) { if(error) { XCTFail(@"Failed with error: %@", error); } }]; } it("equals YES", ^ { expect(view.isHidden).to.equal(YES); }); it(@"sets the user's name", ^ { [view.user load]; expect(label.text).will.equal(@"Foo"); }); From XCTests on the left to Specs on the right. Specs make really easy to read and understanding test code.
  7. CONTINUOUS INTEGRATION 9 UI TESTING - WHY DO WE NEED

    TO TEST UI Design Code  SCREENS With newest devices, we have many different device sizes and screens. USER FLOWS When we update the code, user flows still need to start and complete correctly. ANIMATIONS Are we sure the animations complete correctly on all screens and devices? Are they fluid in all cases?
  8. CONTINUOUS INTEGRATION 11 BASICS - WHAT EXACTLY IS CI 

    Build Application  Clean Solution  Reports Test results Test Run all cases Success Output Commit Input
  9. CONTINUOUS INTEGRATION 14 DISTRIBUTION - NEED AN ONLINE SERVICE Need

    to choose a distribution service. This is a place where our application files will be hosted. TestFlight Owned by Apple and integrated into iTunes, previously separate service. Crashlytics Beta Owned by Twitter, began as a crash reporting service. Supports more platforms. HockeyApp Premium service with powerful API, for multi platform deployment. DeployGate Premium app distribution with additional services such as analytics and crash reporting.
  10. CONTINUOUS INTEGRATION 15 DISTRIBUTION - A CLIENT WISHES TO SEE

    OUR WORK       Create a group Online service Invite testers Online service Add devices Apple Developer Portal Run tests Xcode Provisioning profile Apple Developer Portal Build application Xcode Download TBC Wait for registration I want to see
  11. CONTINUOUS INTEGRATION 16 DISTRIBUTION      

    Create an archive Xcode Package the archive Xcode Sign & Export Xcode .ipa file Choose testers Online Service Upload to Service Desktop app or browser Write change log Online Service Repeat for every build Provisioning profile Lets assume it is a success - A CLIENT WISHES TO SEE OUR WORK
  12. CONTINUOUS INTEGRATION 17 DISTRIBUTION - GETS VERY FRUSTRATING See where

    this is going? Yes, we hate it too. But, it does not have to be this way.
  13. CONTINUOUS INTEGRATION 18 TOOLS - HOW CAN WE SOLVE THE

    PROBLEMS GitHub Service hooks 1 Bash Command line scripts 2 Ruby Easy & useful 3 Homebrew Installing tools 4 CocoaPods Dependency manager 5 xctool Facebook’s Build Tool 6 CI Server A Mac or a service 7 Gems Existing gems 
  14. CONTINUOUS INTEGRATION 19 PROBLEMS - WHAT PROBLEMS DID WE ENCOUNTER

    1. Load UDID’s from distribution service 2. Adding devices to Apple 3. Modifying provisioning profiles 4. Installing certificates 5. Downloading profiles 6. Notifications and messaging 7. Building application 8. Running tests 9. Signing application 10. Uploading build To make it work as a system in CLI Many problems had to be tackled and many systems had to be connected.
  15. CONTINUOUS INTEGRATION 20 DISTRIBUTION SERVICES - HOW DO WE READ

    UDID’S Scraping website and calling API. Each service displays device UDID’s differently. Ruby Mechanize to the rescue. INSTALL GEM ATLANTISPRO TestFlight App Crashlytics Beta
  16. CONTINUOUS INTEGRATION 21 DEVELOPER PORTAL - DOES APPLE PROVIDE AN

    API Sadly, Apple does not care much. But developers do. Cupertino Gem comes to our help. Devices Displays registered devices on portal Profiles Edits and downloads provisioning profiles Certificates Lists and downloads certificates App IDs Lists all Application IDs and bundles
  17. CONTINUOUS INTEGRATION 22 BUILDING APP - XCODE COMMAND LINE TOOLS

    BUILD Builds in any architecture 1 TEST Tests with any SDK 2 REPORT Different outputs 3 PARALLEL Runs tests in parallel 4 xctool WRAPS XCODEBUILD
  18. CONTINUOUS INTEGRATION 23 UPLOADING BUILD - HOW DO WE UPLOAD

    A BUILD Another Gem will do the job. Gem install Shenzhen and distribute with command line. iTunes Connect Uploads a build to iTunes Connect HockeyApp Uploads an .ipa file to HockeyApp TestFlight Old TestFlight portal also supported Crashlytics Beta Sends builds to Crashlytics Beta
  19. CONTINUOUS INTEGRATION 24 SUMMARY - DISTRIBUTION PROCESS Deployment cycle Activated

    either by a CI server or command line Building Builds for all specified devices  Signing Signs with correct code identity  Distribute Deploys to specific service    Provisioning Downloads the new provisioning profile  New devices Add devices to Apple Developer Portal  Git Push Starts the process CLI interface Easy to use on client or CI server 
  20. CONTINUOUS INTEGRATION 25 ALL TOGETHER - AN UNIFIED PROCESS dominus

    integrate Will do this entire process for you automatically. Any server Also works on Travis CI server Little setup Almost no configuration needed Uses Git Deploy can be hooked to a specific branch Notifications Fully integrated HipChat D
  21. CONTINUOUS INTEGRATION 27 LINKS - EVERYTHING WE TALKED ABOUT If

    you are interested in tools, here are the links. Of course, many other tools exist, that we did not mention. Do not be afraid to try those out. Specta & Expecta - https://github.com/specta/expecta Atlantis - https://github.com/Legoless/Atlantis Cupertino - https://github.com/nomad/cupertino Shenzhen - https://github.com/nomad/shenzhen Dominus - https://github.com/Legoless/Dominus Fastlane - https://github.com/KrauseFx/fastlane  TOOLS FOR CONTINUOUS INTEGRATION Some tools mentioned in this talk.
  22. CONTINUOUS INTEGRATION 29 SOCIAL NETWORKS - IF YOU WANT TO

    GET IN CONTACT THANK YOU! Have a great meetup, guys!  /Legoless  @thelegoless  arvystate.net  /dalrupnik /Legoless