Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
fastlaneとBitriseで構築するiOSのCI/CDレシピ / iOS CI/CD R...
Search
rockname
February 21, 2019
Programming
3.6k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
fastlaneとBitriseで構築するiOSのCI/CDレシピ / iOS CI/CD Recipe Constructed with fastlane and Bitrise
rockname
February 21, 2019
More Decks by rockname
See All by rockname
AIを活用したレシート読み取り機能の開発から得られた実践知 / AI Receipt Scan Practice
rockname
2
4.8k
Unlock the Potential of Swift Code Generation
rockname
0
580
生成AIを活用したレシート読み取り機能のアプリ開発の裏側 / AI Receipt Scan App Development
rockname
0
150
ゼロから理解するDependency Injection / Understanding Dependency Injection from the Ground Up
rockname
2
4.5k
サブスクリプション機能制御の設計における勘所
rockname
0
1.3k
Anatomy of Dynamic color
rockname
1
1.3k
キャッシュによる状態管理のアーキテクチャ / Cache-based state management architecture
rockname
10
21k
Optimistic Updatesで UXを向上させる / Improve UX with Optimistic Updates
rockname
2
1.6k
モバイルアプリのリストUIにおける 理想的なState表示について / The ideal state display in a mobile app list UI
rockname
6
2.2k
Other Decks in Programming
See All in Programming
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
390
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
AIエージェントで 変わるAndroid開発環境
takahirom
2
630
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
210
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
2
1.3k
初めてのKubernetes 本番運用でハマった話
oku053
0
120
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
500
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
130
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
140
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
えっ!!コードを読まずに開発を!?
hananouchi
0
200
Featured
See All Featured
Designing for Performance
lara
611
70k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Faster Mobile Websites
deanohume
310
32k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
420
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
150
Designing for humans not robots
tammielis
254
26k
Transcript
fastlaneͱBitriseͰߏங͢Δ iOSͷCI/CDϨγϐ CI/CD Test Night #3 2019/02/21 גࣜձࣾϛΫγΟ ΈͯͶࣄۀ෦ ϩΫωϜ@rockname
ϩΫωϜ@rockname • גࣜձࣾϛΫγΟ 2018৽ଔೖࣾ • ՈΞϧόϜΈͯͶ • ΞϓϦ։ൃάϧʔϓ iOS(Swift,
objc) > Android(Kotlin, Java) == Rails(ruby) ࣗݾհ
ΞδΣϯμ ʲ͢͜ͱʳ • Bitriseಋೖ·ͰͷྲྀΕ • BitriseͷWorkflowͷΈํɾछྨ • fastlaneʹ͓͚ΔlaneͷΈํɾछྨ ʲ͞ͳ͍͜ͱʳ •
Bitriseͷૢ࡞ํ๏ • fastlaneͷ༻ํ๏
BitriseಋೖҎલͷCI/CDࣄ • ࣾmacminiͰJenkinsͱhubot͕ಈ͍͍ͯͨ
Jenkins • GitHubͷWebhookͰPRʹίϛοτ͕ੵ·ΕΔͨͼʹςετ ͕Δ PR commits Test result Testing
hubot • Slack͔ΒίϚϯυΛड͚͚ͭͯDeployGate, AppStore৴ Building Request Deploy
ਏ͔ͬͨ͜ͱ • macminiΛ୭͔͕ϝϯςͯ͋͛͠Δඞཁ͕͋Δ • Xcode10ରԠͷࡍ͜͜ͷลΓͰ͍ͩͿർฐͨ͠ • ࣾmacminiࣾ֎͔ΒͷΞΫηεΛ͍͍ͯΔͷͰɺϦϞʔτ ͰCIͷ݁ՌΛݟΕͳ͍ (VPNΛܨ͛ݟΕΔ͕…)
Jenkins͔ΒBitriseʹ…ʂ!!
Bitriseͱʁ • ϞόΠϧʹಛԽͨ͠CI/CDͷαʔϏε • ରԠ: iOS/Android/Xamarin/ ReactNative/Flutter… • GUIʹΑΔࢹ֮తͳૢ࡞Ͱ WorkflowΛ؆୯ʹΊΔ
ͳͥBitriseʹͨ͠ͷʁ • ଞͷΫϥυCIαʔϏεͱൺͯ֨ஈʹ͍҆ • ৽όʔδϣϯͷXcodeରԠ͕ૣ͍ • νʔϜʹBitriseϢʔβʔ͕͢ͰʹԿ໊͔͍ͨ • ྲྀߦ͍ͬͯͨ
Ͳ͏ͬͯҠߦ͍ͯ͘͠
ݱঢ়ͷmacminiͰͷϏϧυ • Test • JenkinsͰPRͷίϛοτΛϑοΫ • deploygateͷ৴ • inhouse •
ࣾ༻ (Enterprise) • staging • QA༻ • AppStoreͷΞοϓϩʔυ(fastlane/deliver)
ݒ೦ • ҰؾʹBitriseʹҾͬӽ͢ͷා͍ • ϏϧυεΫϦϓτ͕187ߦ͋Δ • BitriseͰ࡞ΔWorkflowͷόʔδϣϯཧ͕Ͱ͖ͳ͍ • (Ͱ͖Δ͕GUIͰࢹೝͰ͖ͳ͘ͳΔ)
ݒ೦ • ҰؾʹBitriseʹҾͬӽ͢ͷා͍ • ϏϧυεΫϦϓτ͕187ߦ͋Δ • BitriseͰ࡞ΔWorkflowͷόʔδϣϯཧ͕Ͱ͖ͳ͍ • (Ͱ͖Δ͕GUIͰࢹೝͰ͖ͳ͘ͳΔ)
fastlaneͱʁ • ओʹiOS/AndroidΞϓϦͷϏϧυ, ςετ, σϓϩΠΛߦ͏ͨΊͷRubyλε Ϋϥϯφʔ • iOSͰ • gym:
ΞϓϦͷϏϧυ • deliver: AppStoreConnectͷ Ξοϓϩʔυ • scan: ςετͷ࣮ߦ • …
ํ • Step1: fastlaneʹεΫϦϓτΛدͤΔ • Step2: BitriseʹશҠߦ => Ұؾʹmacmini͔ΒҠߦ͠ͳͯ͘ࡁΉ͔Β҆৺ =>
gitཧ͍ͨ͠ϨγϐfastlaneͰ
201812݄த०ʹ ແࣄʹҠߦྃ
None
None
inhouse/staging/release • inhouse: • deploygate৴ • ࣾ༻ (Enterprise) • staging:
• Deploygate৴ • QA༻ • release • AppStoreConnectΞοϓϩʔυ
Fastfile: inhouse/staging lane :inhouse do |options| gym upload_to_deploygate(config: "Inhouse") end
lane :staging do |options| gym upload_to_deploygate(config: "Staging") end
Fastfile: inhouse/staging lane :inhouse do |options| gym upload_to_deploygate(config: "Inhouse") end
lane :staging do |options| gym upload_to_deploygate(config: "Staging") end gymͰipaੜ
Fastfile: inhouse/staging lane :inhouse do |options| gym upload_to_deploygate(config: "Inhouse") end
lane :staging do |options| gym upload_to_deploygate(config: "Staging") end private_laneͰDeploygate৴
Fastfile: release lane :release do |options| gym deliver( ipa: “Mitene.ipa",
submit_for_review: false, force: true ) upload_to_github_release( github_api_token: ENV["GITHUB_API_TOKEN"], tag_name: options[:tag_name] ) end
Fastfile: release lane :release do |options| gym deliver( ipa: “Mitene.ipa",
submit_for_review: false, force: true ) upload_to_github_release( github_api_token: ENV["GITHUB_API_TOKEN"], tag_name: options[:tag_name] ) end gymͰipaੜ
Fastfile: release lane :release do |options| gym deliver( ipa: “Mitene.ipa",
submit_for_review: false, force: true ) upload_to_github_release( github_api_token: ENV["GITHUB_API_TOKEN"], tag_name: options[:tag_name] ) end deliverͰAppStoreConnectΞοϓϩʔυ
Fastfile: release lane :release do |options| gym deliver( ipa: “Mitene.ipa",
submit_for_review: false, force: true ) upload_to_github_release( github_api_token: ENV["GITHUB_API_TOKEN"], tag_name: options[:tag_name] ) end private_laneͰGithub ReleaseΛ࡞
ʲTipsʳGymfileʹfor_laneͰ lane͝ͱͷϏϧυύϥϝʔλΛ͢ for_lane :inhouse do ɾɾɾ end for_lane :staging do
ɾɾɾ end for_lane :release do ɾɾɾ end ࢀߟIUUQTTQFBLFSEFDLDPNHJHJOFUYJBOHKJFGBTUpMF
Workflow • fastlaneͷstepͰlaneΛ ࢦఆ͢Δ͚ͩ
Trigger • masterʹpush͞Εͨͱ͖ʹinhouseͰ৴
slack • hubotܦ༝ͰϏϧυΛ࣮ߦ
Build Trigger API • slack͔Βhubotܦ༝ͰϏϧυΛ࣮ߦ hook_info="\"hook_info\":{ \"type\":\"bitrise\", \"build_trigger_token\":\"${BUILD_TRIGGER_TOKEN}\" }" build_params="\"build_params\":{
\"branch\":\"${branch}\", \"workflow_id\":\"${workflow}\" }" json="{${hook_info},${build_params},\"triggered_by\":\"curl\"}" curl https://app.bitrise.io/app/${APP_SLUG}/build/start.json —data "${json}"
None
update-libraries • CarthageͷoutdatedͳϥΠϒϥϦΛΞοϓσʔτͯ͠PRΛ࡞ ˞@hiragram͞ΜͷԼهࣄΛ͔ͳΓࢀߟʹ͍͖ͤͯͨͩ͞·ͨ͠ “TravisCIͰiOSͷґଘϥΠϒϥϦͷߋ৽ΛࣗಈԽ͢Δ” https://tech.speee.jp/entry/2016/12/01/100253
Scheduled Build • ຖि༵ۚͷਂ3࣌ʹఆظ࣮ߦ
PR͕ࣗಈੜ
PR͕ࣗಈੜ
PR͕ࣗಈੜ
PR͕ࣗಈੜ
Fastfile • laneΛ࡞Δ lane :update_carthage_libraries
Fastfile • outdatedͳϥΠϒϥϦΛग़͢ outdateds = "" Dir.chdir ".." do outdateds
+= sh("carthage", "outdated") end
Fastfile • ݱࡏͷϒϥϯνΛୀආ͠ɺϥΠϒϥϦΛਖ਼نදݱͰ̍ߦͣͭநग़ current_branch = git_branch outdateds.each_line do |line| if
outdated = line.match( /^(.+?) "(.+?)\.(.+?)\.(.+?)" -> “(.+?)\.(.+?)\.(.+?)"/ ) then lib = outdated[1] old_major = outdated[2] old_minor = outdated[3] old_patch = outdated[4] new_major = outdated[5] new_minor = outdated[6] new_patch = outdated[7]
Fastfile • όʔδϣϯ͕ҧ͏ͳΒ৽͍͠branchΛͬͯ carthage update if old_major == new_major &&
(old_minor != new_minor || old_patch ! = new_patch) then ɹɹBRANCH_NAME = ɹɹɹ“update-library-#{lib}-"+Time.now.strftime("%Y%m%d%H%M") ɹɹsh("git", "checkout", "-b", BRANCH_NAME) ɹɹcarthage( ɹɹɹcommand: "update", ɹɹɹdependencies: [lib], ɹɹɹplatform: “ios" ɹɹ) ɹɹgit_add(path: ".") ɹɹgit_commit(path: ".", message: "Update Library #{lib}.”)
Fastfile • PRͷbodyΛੜ version = line.match(/"(.*?)" -> "(.*?)"/) old_version =
version[1] new_version = version[2] diff = sh("git", "diff", "--", "../Cartfile.resolved") repo = diff.match(/-github "(.+?)"/)[1] body = "## #{repo}\n” body += "#{old_version} -> [#{new_version}] (https://github.com/#{repo}/releases/tag/#{new_version})\n" body += “[compare](https://github.com/#{repo}/compare/ #{old_version}...#{new_version})\n"
Fastfile • PRΛ࡞͠ɺϒϥϯνΛmasterʹͯ࣍͠ͷfor_loop ɹɹsh("git", "push", "origin", BRANCH_NAME) ɹɹcreate_pull_request( ɹɹɹɹapi_token: ENV["GITHUB_API_TOKEN"],
ɹɹɹɹrepo: "maychannel-dev/iOS", ɹɹɹɹtitle: "[Auto generated] Update library #{lib}", ɹɹɹɹbody: body ɹɹ) ɹɹsh("git", "checkout", current_branch) end
update_carthage_libraries • gistʹ্͛ͨͷͰΑ͚Εࢀߟʹ͍ͯͩ͘͠͞ https://gist.github.com/rockname/ d30829947f9d00bee2b8be61ab70f6db
None
check-release-build • productionڥͰຖਂʹϏϧυ͍ͯ͠Δ • `#if RELEASE` ͰམͪΔ͜ͱʹϦϦʔεલͰؾ͍ͮͨମݧ͔Β…
None
update-metadata • ৹ࠪͰϦδΣΫτ͞Εͨࡍʹɺϝλσʔλ͚ͩFastlaneͷ deliverͰAppStoreConnectʹΞοϓϩʔυ͍ͨ͠ͱ͖ʹ༻
None
measure-build-time/measure-coverage • Ϗϧυ࣌ؒͱςετΧόϨοδΛຖਂʹܭଌ
measure-build-time • xcodebuild -showBuildTimingSummary Ͱܭଌ͢Δ͜ͱʹ • Xcode 10 ͔ΒՃ͞ΕͨɺΑΓৄࡉͳϏϧυ࣌ؒܭଌํ๏
Workflow
Workflow touch buildtime.txt xcodebuild \ -showBuildTimingSummary \ … \ clean
build test | grep -E \ ’.* \| .*(seconds)$' >> buildtime.txt mv buildtime.txt $BITRISE_DEPLOY_DIR
Workflow
measure-coverage • ΧόϨοδऩूํ๏৭ʑ͋Δ͕ɺstarͳͲΛݟͯ slather ͰΧόϨοδΛऩू͢Δ͜ͱʹ • Fastlaneͷlane͋Δ
Gemfile + gem 'slather'
Scanfile scheme("Mitene") workspace(“Mitene.xcworkspace") device("iPhone 6s Plus") clean(true) code_coverage(true) skip_slack(true) configuration("Testing")
Scanfile scheme("Mitene") workspace(“Mitene.xcworkspace") device("iPhone 6s Plus") clean(true) code_coverage(true) skip_slack(true) configuration("Testing")
CodeCoverageΛON
Fastfile lane :coverage do |options| scan slather( proj: "Mitene.xcodeproj", workspace:
"Mitene.xcworkspace", scheme: “Mitene", configuration: "Testing", html: true, output_directory: ENV["BITRISE_DEPLOY_DIR"], ignore: ["Carthage/Checkouts/*", "Pods/*"] ) end
Fastfile lane :coverage do |options| scan slather( proj: "Mitene.xcodeproj", workspace:
"Mitene.xcworkspace", scheme: “Mitene", configuration: "Testing", html: true, output_directory: ENV["BITRISE_DEPLOY_DIR"], ignore: ["Carthage/Checkouts/*", "Pods/*"] ) end ґଘϥΠϒϥϦΛignoreʹࢦఆ
Artifact
Artifact CSS͕ޮ͍ͨViewݟΕͳ͍
Feature Request IUUQTEJTDVTTCJUSJTFJPUBSUJGBDUTNBLFJUQPTTJCMFUPWJFXIUNMpMFT XJUISFMBUJWFMJOLTDTTFUDSFGT
None
test • PRʹίϛοτ͞ΕΔʹtest͕Δ
Pull Request • Dangerܦ༝ͰswiftlintͷϝοηʔδCoverage͕දࣔ͞ΕΔ
Fastfile lane :test do |options| scan danger end
Gemfile + gem 'danger-slather'
Dangerfile slather.configure( "Mitene.xcodeproj", "Mitene", options: { workspace: “Mitene.xcworkspace", configuration: "Testing",
ignore_list: ["Carthage/Checkouts/*", "Pods/*"] } ) slather.show_coverage
ʲTipsʳAuto-cancel builds • طʹbuild͕͍ͬͯΔ߹cancelͯ͘͠ΕΔ IUUQTCMPHCJUSJTFJPBVUPDBODFMCVJMETBOELFFQSPMMJOH
·ͱΊ • BitriseΛಋೖͨ͜͠ͱͰ • macminiͷ໘ΛݟΔඞཁ͕ͳ͘ͳͬͨ • ϦϞʔτ͔ΒؾܰʹϏϧυ݁ՌΛݟΕΔΑ͏ʹͳͬͨ • GUIͰΆͪΆͪ࡞ΕΔͷͰWorkflow͕ͲΜͲΜ૿͑ɺ ॳݟʹ༏͍͠
• όʔδϣϯཧ͍ͨ͠ϑϩʔfastlaneʹدͤΔͱྑͦ͞͏ • ͱ͍͑ɺFastflieͷଐਓԽʹཁҙ
Thank you!!!