Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Continuous Integration at SoundCloud iOSDevUK september 2014 ! Vincent Garrigues @garriguv

Slide 3

Slide 3 text

What is CI?

Slide 4

Slide 4 text

“Continuous integration (CI) is the practice, in software engineering, of merging all developer working copies with a shared mainline several times a day.” http://en.wikipedia.org/wiki/Continuous_integration

Slide 5

Slide 5 text

• trunk based development • lots of testing • CI pipeline

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Why CI?

Slide 16

Slide 16 text

• move fast • keep codebase healthy • ship reliable apps

Slide 17

Slide 17 text

• move fast • keep codebase healthy • ship reliable apps

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

• started from scratch • months in development • millions of users

Slide 21

Slide 21 text

iOS Crash Complaints (avg per Week) 0 35 70 105 140 April May June July August SoundCloud community team

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

How to get started?

Slide 24

Slide 24 text

Start simple and iterate

Slide 25

Slide 25 text

• run unit test suite • α and β versions • sign .app builds

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Rake

Slide 28

Slide 28 text

require 'rake' ! desc 'say Hello World!' task :hello do puts 'Hello World!' end

Slide 29

Slide 29 text

require 'rake' ! desc 'say Hello World!' task :hello do puts 'Hello World!' end

Slide 30

Slide 30 text

require 'rake' ! desc 'say Hello World!' task :hello do puts 'Hello World!' end

Slide 31

Slide 31 text

require 'rake' ! desc 'say Hello World!' task :hello do puts 'Hello World!' end

Slide 32

Slide 32 text

Running the unit tests

Slide 33

Slide 33 text

use xcodebuild or xctool

Slide 34

Slide 34 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" test

Slide 35

Slide 35 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" test

Slide 36

Slide 36 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" test

Slide 37

Slide 37 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" test

Slide 38

Slide 38 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" test

Slide 39

Slide 39 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean

Slide 40

Slide 40 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build

Slide 41

Slide 41 text

rake tasks • rake clean • rake build • rake test

Slide 42

Slide 42 text

α and β versions

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

User-defined build settings

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Override user-defined build settings when running xcodebuild

Slide 51

Slide 51 text

xcodebuild -workspace ci.xcworkspace -scheme ci -configuration Debug -sdk iphonesimulator7.1 -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)” build

Slide 52

Slide 52 text

xcodebuild (…) VG_BUNDLE_ID=com.company.app-alpha build

Slide 53

Slide 53 text

xcodebuild (…) VG_BUNDLE_ID=com.company.app-alpha VG_DISPLAY_NAME=α build

Slide 54

Slide 54 text

xcodebuild (…) VG_BUNDLE_ID=com.company.app-alpha VG_DISPLAY_NAME=α VG_CODE_SIGNING="'iPhone Distribution: Vincent Garrigues'" build

Slide 55

Slide 55 text

Where can we store those settings?

Slide 56

Slide 56 text

We use a YAML file

Slide 57

Slide 57 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 58

Slide 58 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 59

Slide 59 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 60

Slide 60 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 61

Slide 61 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 62

Slide 62 text

defaults: &DEFAULTS app: &APP_DEFAULTS workspace: ci.xcworkspace scheme: ci configuration: Release display_name: ci-test bundle_identifier: com.company.ci-test codesign: &CODESIGN_DEFAULTS signing_identity: '"iPhone Distribution: Vincent Garrigues (X73EL3QFZB)"' provisioning_profile: provisioning/app_store.mobileprovision

Slide 63

Slide 63 text

defaults: (..) ! alpha: <<: *DEFAULTS app: <<: *APP_DEFAULTS display_name: α bundle_identifier: com.company.ci-test-alpha codesign: <<: *CODESIGN_DEFAULTS provisioning_profile: provisioning/alpha.mobileprovision

Slide 64

Slide 64 text

defaults: (..) ! alpha: <<: *DEFAULTS app: <<: *APP_DEFAULTS display_name: α bundle_identifier: com.company.ci-test-alpha codesign: <<: *CODESIGN_DEFAULTS provisioning_profile: provisioning/alpha.mobileprovision

Slide 65

Slide 65 text

defaults: (..) ! alpha: <<: *DEFAULTS app: <<: *APP_DEFAULTS display_name: α bundle_identifier: com.company.ci-test-alpha codesign: <<: *CODESIGN_DEFAULTS provisioning_profile: provisioning/alpha.mobileprovision

Slide 66

Slide 66 text

rake build BUILD_ENV=alpha rake build BUILD_ENV=beta rake build BUILD_ENV=adhoc rake build BUILD_ENV=release

Slide 67

Slide 67 text

rake build BUILD_ENV=alpha rake build BUILD_ENV=beta rake build BUILD_ENV=adhoc rake build BUILD_ENV=release

Slide 68

Slide 68 text

rake build BUILD_ENV=alpha rake build BUILD_ENV=beta rake build BUILD_ENV=adhoc rake build BUILD_ENV=appstore

Slide 69

Slide 69 text

rake build creates a .app

Slide 70

Slide 70 text

We need a .ipa

Slide 71

Slide 71 text

xcrun

Slide 72

Slide 72 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 73

Slide 73 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 74

Slide 74 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 75

Slide 75 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 76

Slide 76 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 77

Slide 77 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 78

Slide 78 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 79

Slide 79 text

xcrun -v -sdk iphoneos PackageApplication ci-test-alpha.app -o ci-test-alpha.ipa --sign "iPhone Distribution: Vincent Garrigues" --embed provisioning/alpha.mobileprovision

Slide 80

Slide 80 text

rake sign

Slide 81

Slide 81 text

• rake clean • rake test • rake build • rake sign

Slide 82

Slide 82 text

How can we use those rake tasks?

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

• rake build sign BUILD_ENV=alpha • rake build sign BUILD_ENV=beta • rake build sign BUILD_ENV=adhoc

Slide 85

Slide 85 text

• rake build sign BUILD_ENV=alpha • rake build sign BUILD_ENV=beta • rake build sign BUILD_ENV=adhoc

Slide 86

Slide 86 text

• rake build sign BUILD_ENV=alpha • rake build sign BUILD_ENV=beta • rake build sign BUILD_ENV=adhoc

Slide 87

Slide 87 text

• rake build sign BUILD_ENV=alpha • rake build sign BUILD_ENV=beta • rake build sign BUILD_ENV=adhoc • rake build sign BUILD_ENV=appstore

Slide 88

Slide 88 text

Ad-Hoc and AppStore builds have the same bundle id

Slide 89

Slide 89 text

rake build BUILD_ENV=appstore ci-test-appstore.app ci-test-appstore.dSYM ci-test-appstore.dSYM.zip

Slide 90

Slide 90 text

rake build BUILD_ENV=appstore rake ipa BUILD_ENV=appstore ci-test-appstore.app ci-test-appstore.dSYM ci-test-appstore.dSYM.zip ci-test-appstore.ipa

Slide 91

Slide 91 text

rake build BUILD_ENV=appstore rake ipa BUILD_ENV=appstore rake ipa BUILD_ENV=adhoc ci-test-appstore.app ci-test-appstore.dSYM ci-test-appstore.dSYM.zip ci-test-appstore.ipa ci-test-adhoc.ipa

Slide 92

Slide 92 text

rake build BUILD_ENV=appstore rake ipa BUILD_ENV=appstore rake ipa BUILD_ENV=adhoc ci-test-appstore.app ci-test-appstore.dSYM ci-test-appstore.dSYM.zip ci-test-appstore.ipa ci-test-adhoc.ipa

Slide 93

Slide 93 text

ci-test-appstore.app ci-test-appstore.dSYM ci-test-appstore.dSYM.zip ci-test-appstore.ipa ci-test-adhoc.ipa rake build BUILD_ENV=appstore rake ipa BUILD_ENV=appstore rake ipa BUILD_ENV=adhoc

Slide 94

Slide 94 text

The same binary, signed twice

Slide 95

Slide 95 text

Sample project ! github.com/garriguv/ci-test

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

• linter (Xcode project, data model, acceptance tests, ruby, ObjC) • static analysis • unit tests (ruby and ObjC) • acceptance tests • custom app icon • deploy to HockeyApp • …

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

Thank you! http://github.com/garriguv/ci-talk ! ! Vincent Garrigues @garriguv