continuous integration by rémy virin

48
CONTINUOUS INTEGRATION FROM UNIT TESTS TO HARDWARE Rémy Virin Cocoaheads @remyvirin

Upload: cocoaheads-france

Post on 09-May-2015

3.204 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Continuous integration by Rémy Virin

CONTINUOUS INTEGRATION

FROM UNIT TESTS TO HARDWARE

Rémy VirinCocoaheads@remyvirin

Page 2: Continuous integration by Rémy Virin

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

Page 3: Continuous integration by Rémy Virin

BEFORE, 10 YEARS AGO

One deviceOne User One Memory

Page 4: Continuous integration by Rémy Virin

TODAY, MULTIPLE DEVICES, MULTIPLE MEMORIES

Multiple devices

One User Divided memories

Page 5: Continuous integration by Rémy Virin

TODAY, CLOUD SOLUTION IS JUST A PATCH

Multiple devices

One User Divided memories

Page 6: Continuous integration by Rémy Virin

TODAY, CLOUD SOLUTION IS JUST A PATCH

One User One Unified Memory

Page 7: Continuous integration by Rémy Virin

CONTINUOUS INTEGRATION

FROM UNIT TESTS TO HARDWARE

Page 8: Continuous integration by Rémy Virin

WHY ?

Page 9: Continuous integration by Rémy Virin
Page 10: Continuous integration by Rémy Virin

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

Page 11: Continuous integration by Rémy Virin

MEASURE QUALITY

• Photo quality

Page 12: Continuous integration by Rémy Virin

HOW ?

Page 13: Continuous integration by Rémy Virin

C.I. BASICS

Fetch sources

Execute unit tests

Publish app to mktg

Generate metrics

Generate Documentati

on

Execute functional tests

Workstations

ContinuousIntegration

Page 14: Continuous integration by Rémy Virin

SAS vs LOCAL

Page 15: Continuous integration by Rémy Virin

JENKINS

Page 16: Continuous integration by Rémy Virin

ABOUT JENKINS

• Open Source

• Easy to install

• Best known CI solution

Page 17: Continuous integration by Rémy Virin

INSTALL JENKINS

Page 18: Continuous integration by Rémy Virin

ADD PLUGINS

Page 19: Continuous integration by Rémy Virin

ADD PLUGINS

Page 20: Continuous integration by Rémy Virin

CREATE A JOB

CREATE A JOB

Page 21: Continuous integration by Rémy Virin

CREATE A JOB

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

mac is a node of Jenkins.

Page 22: Continuous integration by Rémy Virin

CREATE A JOB WITH PLUGINS

Page 23: Continuous integration by Rémy Virin

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

Page 24: Continuous integration by Rémy Virin

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

Page 25: Continuous integration by Rémy Virin

THAT’S IT, YOU CAN ENJOY NOW…

Page 26: Continuous integration by Rémy Virin

AND ONE DAY, THE BUILD FAIL !

Page 27: Continuous integration by Rémy Virin

WE NEED TO KNOW WHEN BUILD FAILED

• Basic Alert : Email

• Growl Notification : Hudson-on-cocoa

• Or you can connect Jenkins to your real life…

Page 28: Continuous integration by Rémy Virin

YOU’LL NEVER BROKE THE BUILD AGAIN !

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

Page 29: Continuous integration by Rémy Virin

BOTS ON iOS

Page 30: Continuous integration by Rémy Virin

SETUP - REQUIREMENTS

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

Page 31: Continuous integration by Rémy Virin

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

Page 32: Continuous integration by Rémy Virin

ERRORS DURING SETUP

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

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

Page 33: Continuous integration by Rémy Virin

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)

Page 34: Continuous integration by Rémy Virin

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

Page 36: Continuous integration by Rémy Virin

PODS IN XCODE

Page 37: Continuous integration by Rémy Virin

PODS IN XCODE

Page 38: Continuous integration by Rémy Virin

COOL THINGS ON BOTS

• Bots Can be created and monitored from Xcode.

• Integrate with Xcode

• UI and UX rocks.

Page 39: Continuous integration by Rémy Virin

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

Page 40: Continuous integration by Rémy Virin

SONARAn open source platform for

Continuous Inspection of code quality

Page 41: Continuous integration by Rémy Virin

SONARQUBE

Page 42: Continuous integration by Rémy Virin

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

Page 43: Continuous integration by Rémy Virin

NEXT STEP : HARDWARENEXT STEP : HARDWARE

Page 44: Continuous integration by Rémy Virin

CONCLUSION

Page 45: Continuous integration by Rémy Virin

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

Page 46: Continuous integration by Rémy Virin

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)

Page 47: Continuous integration by Rémy Virin

COST : 8 to 10 % of the project time

Page 48: Continuous integration by Rémy Virin

THANKS !