Continuous integration by Rémy Virin

Post on 09-May-2015

3.202 views 0 download

Transcript of Continuous integration by Rémy Virin

CONTINUOUS INTEGRATION

FROM UNIT TESTS TO HARDWARE

Rémy VirinCocoaheads@remyvirin

WHO AM I ? LIMA ?• I’m an iOS software engineer at Forget box.

• We’re creating a new way to store your data.

• Backed on kickstarter

• 12,8K backers• $ 1,2 Millions

BEFORE, 10 YEARS AGO

One deviceOne User One Memory

TODAY, MULTIPLE DEVICES, MULTIPLE MEMORIES

Multiple devices

One User Divided memories

TODAY, CLOUD SOLUTION IS JUST A PATCH

Multiple devices

One User Divided memories

TODAY, CLOUD SOLUTION IS JUST A PATCH

One User One Unified Memory

CONTINUOUS INTEGRATION

FROM UNIT TESTS TO HARDWARE

WHY ?

SHIP, SHIP, SHIIIIP !!!SHIP, SHIP, SHIIIIP !!!

MEASURE QUALITY

• Photo quality

HOW ?

C.I. BASICS

Fetch sources

Execute unit tests

Publish app to mktg

Generate metrics

Generate Documentati

on

Execute functional tests

Workstations

ContinuousIntegration

SAS vs LOCAL

JENKINS

ABOUT JENKINS

• Open Source

• Easy to install

• Best known CI solution

INSTALL JENKINS

ADD PLUGINS

ADD PLUGINS

CREATE A JOB

CREATE A JOB

CREATE A JOB

• Set up Github url and restrict where the job should be run if your

mac is a node of Jenkins.

CREATE A JOB WITH PLUGINS

CREATE A JOB WITH A SCRIPT

Build your project, run Unit Tests, compute code coverage, package your app, deploy it etc…

$ pod install$ xcodebuild -workspace Lima.xcworkspace -scheme "Lima" -destination=build -configuration Debug_deploy -sdk iphoneos7.0 ONLY_ACTIVE_ARCH=YES clean build archive

$ xcodebuild -exportArchive -exportFormat "IPA" -archivePath "$NEW_ARCHIVE" -exportPath ./Lima.ipa -exportProvisioningProfile "Lima Adhoc Distribution"

# And then upload to testflight via curl

Full script here: https://gist.github.com/rvirin/7796647

PLUGINS vs SCRIPTS

Most of the time, plugins are easier to use. Sometimes we don’t have other choices to use plugins

Examples : • cocoapods plugin if podFile is not in root folder• run Unit tests with Xcode plugin

THAT’S IT, YOU CAN ENJOY NOW…

AND ONE DAY, THE BUILD FAIL !

WE NEED TO KNOW WHEN BUILD FAILED

• Basic Alert : Email

• Growl Notification : Hudson-on-cocoa

• Or you can connect Jenkins to your real life…

YOU’LL NEVER BROKE THE BUILD AGAIN !

Code source : https://github.com/codedance/Retaliation

BOTS ON iOS

SETUP - REQUIREMENTS

• A mac (at least 10.9)• OS X Server • Xcode

SETUP

• Install OS X Server and Xcode on your mac

• Activate Xcode as a service of your server

• Connect to remote repository• Create your first bot

ERRORS DURING SETUP

• Error on getting source code -> no error, big logs for nothing

• Add _teamserver public key to your Github repository (deploy keys)

ERRORS DURING SETUP

• CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0’ just trying to build the app !

• Get your provisionning profile on the mac server (Add your account to Xcode)

SETUP

• If you have to install your pods before building your app :

• $ sudo visudo -f /etc/sudoers

• Add this line :# Same thing without a password# %wheel ALL=(ALL) NOPASSWD: ALL%_teamsserver ALL=(ALL) NOPASSWD: ALL

PODS IN XCODE

PODS IN XCODE

COOL THINGS ON BOTS

• Bots Can be created and monitored from Xcode.

• Integrate with Xcode

• UI and UX rocks.

BAD THINGS ON BOTS

• Lots of bugs

• Fetching pods before building app is painfull

• No 3rd party integration (Testflight, hockeyapp etc…)

• Can’t Archive an app

• Need to create a specific scheme

SONARAn open source platform for

Continuous Inspection of code quality

SONARQUBE

SONARQUBE

• Issues with OCLint are powerfull

• Generate Documentation, Count lines of code, analyze code duplication and run Unit Tests !

• https://github.com/octo-technology/sonar-objective-c

NEXT STEP : HARDWARENEXT STEP : HARDWARE

CONCLUSION

IMPROVEMENTS

• « Thanks to Jenkins I’m able to test the last version of our app just by pressing a button, it’s awesome ! » Alex Product Guy at Lima

IMPROVEMENTS

• « Each day at 4pm, we get a new build of our app, it’s really efficient to reduce the amount of bugs » Tester at Meetic (Dating website)

COST : 8 to 10 % of the project time

THANKS !