Top Banner
@xebiconfr #xebiconfr fastlane Automatisez votre vie (de dév iOS) JC Pastant
32

XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS) Par Jean-Christophe Pastant, Développeur mobile chez Xebia

Feb 16, 2017

Download

Technology

Xebia France
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

fastlaneAutomatisez votre

vie (de dév iOS)

JCPastant

Page 2: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 3: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 4: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 5: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 6: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 7: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 8: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 9: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 10: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

●●●●

Page 11: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

desc "Runs all the tests and generate reports"lane :run_tests do |options|end

desc "Builds an ipa"lane :build do |options|end

desc "Delivers a new build to appstore"lane :deploy do |options|end

Page 12: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

app_identifier "fr.xebia.xebicon" # Xebicon bundle identifier

apple_id "[email protected]" # Xebia email address on iOS Dev Center

team_id "X3B1AR0XORZ" # Xebia team id

Page 13: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

$ fastlane my_lane --env debug

$ fastlane my_lane --env preprod

$ fastlane my_lane --env appstore

Page 14: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 15: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane run_tests --env debug...Executed 83 tests, with 0 failures (0 unexpected) in 0.444 (0.509) seconds

+--------------------+-------+| Test Results |+--------------------+-------+| Number of tests | 83 || Number of failures | 0 |+--------------------+-------+

Page 16: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}”, code_coverage: true)slather(scheme: “Xebicon-#{scheme_env}”, proj: “Xebicon.xcodeproj”, html: true)

end

$ fastlane run_tests --env debug…Slathering...Successfully generated report at ‘.../reports/bdd/coverage/index.html’

Page 17: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

Page 18: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

Page 19: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 20: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizegym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.

Page 21: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizeincrement_build_number(build_number: number_of_commits)gym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.

Page 22: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizesigh(output_path: "build", provisioning_name: "Xebicon #{scheme_env}")gym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Fetching profiles...Found 1 matching profile(s)Successfully downloaded provisioning profile...Installing provisioning profile…

Signing Xebicon.ipaSuccessfully exported and signed the ipa file: Xebicon.ipa

Page 23: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 24: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|build(options)deliver(skip_metadata: true, skip_screenshots: true)

end

$ fastlane deploy --env prod...Successfully uploaded package to iTunes Connect. It might take a few minutes until it’s visible online.

Finished the upload to iTunes Connect.

Page 25: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|build(options)crashlytics(groups: options[:to])

end

$ fastlane deploy --env preprod...Uploading the build to Crashlytics Beta. Time for some ☕�Build successfully uploaded to Crashlytics Beta

fastlane.tools just saved you 17 minutes!

Page 26: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|is_prod = [:prod, :appstore].include? lane_context[SharedValues::ENVIRONMENT]

build(options)crashlytics(groups: options[:to]) if !is_proddeliver(skip_metadata: true, skip_screenshots: true) if is_prod

end

Page 27: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 28: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

// Fastfileerror do |lane, exception|

slack(message: exception.message, success: false)end

lane :run_tests do |options|...slack(message: “Runned tests”, success: true)

end

lane :deploy do |options|env = lane_context[SharedValues::ENVIRONMENT]...slack(message: “Deployed on #{env}”, success: true)

end

Page 29: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

def convention_env_valuesapp_name = ENV['APP_NAME']env = lane_context[SharedValues::ENVIRONMENT]scheme_env = env.capitalize

ENV['SCHEME'] ||= "#{app_name}-#{scheme_env}"ENV['XC_PROJECT'] ||= "#{app_name}.xcodeproj"ENV['DEPLOY_SERVICE'] ||= [:prod, :appstore].include? env ? "appstore" : "crashlytics"

ENV['SIGH_PROVISIONING_PROFILE_NAME'] ||= "#{app_name} #{scheme_env}"end

before_all doconvention_env_values()

end

Page 30: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}” ENV['SCHEME'], code_coverage: true)slather(proj: “Xebicon-#{scheme_env}” ENV["SCHEME"], scheme: “Xebicon.xcodeproj”

ENV["XC_PROJECT"], html: true)end

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizesigh(output_path: "build", provisioning_name: "Xebicon #{scheme_env}")gym(scheme: “Xebicon-#{scheme_env}” ENV['SCHEME'])

end

lane :deploy do |options|is_prod = [:prod, :appstore].include? lane_context[SharedValues::ENVIRONMENT]

build(options)crashlytics(groups: options[:to]) if ENV['DEPLOY_SERVICE'] == 'crashlytics'deliver(skip_metadata: true, skip_screenshots: true) if ENV['DEPLOY_SERVICE'] == 'appstore'

end

Page 31: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr

Page 32: XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS)  Par Jean-Christophe Pastant, Développeur mobile chez Xebia

@xebiconfr #xebiconfr