-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFastfile
More file actions
184 lines (144 loc) · 4.49 KB
/
Copy pathFastfile
File metadata and controls
184 lines (144 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# frozen_string_literal: true
fastlane_require 'fileutils'
require './Helpers/AppInfoProvider.rb'
import './Helpers/BaseFastfile'
opt_out_usage
default_platform :ios
platform :ios do
#########################
# Environment Variables #
#########################
project_base_name = 'MobileCI'
ENV['CACHE_PREFIX'] = project_base_name
ENV['BUILD_FOLDER'] = File.join('fastlane', 'Build')
ENV['AWS_REGION'] = 'us-east-1'
ENV['ARTIFACTS_DIR'] = './fastlane/test_output'
# Cache prefix used for Rome (e.g. carthage cache on S3).
rome_cache_prefix = ENV['CACHE_PREFIX']
# All schemes that will be run for testing. NOTE: make sure each is a shared scheme.
schemes_to_test = [
AppInfoProvider::Scheme::Development
]
##############
# Before all #
##############
before_all do
setup_defaults
end
#########
# Lanes #
#########
desc 'Setup all required environment keys'
desc ''
private_lane :setup_defaults do
Dotenv.load('.env.local', '.env.development')
ENV['IOS_APP_NAME'] = project_base_name
# Required environment variable naming for Rome plugin.
ENV['AWS_ACCESS_KEY_ID'] = ENV['S3_ACCESS_KEY']
ENV['AWS_SECRET_ACCESS_KEY'] = ENV['S3_SECRET_ACCESS_KEY']
# Export options value for key method
ENV['EXPORT_METHOD_OPTION'] = 'ad-hoc'
ENV['IPA_NAME'] = "#{ENV['IOS_APP_NAME']}-#{ci_build_number}.ipa"
end
#############################
## TESTING & CODE COVERAGE ##
#############################
desc 'Run tests using iPhone 16 Pro sim'
lane :test_iphone_15 do
run_tests_for_device(
project_base_name: project_base_name,
schemes: schemes_to_test,
device: 'iPhone 16 Pro'
)
end
desc 'Run tests using iPhone 15 Pro'
lane :test_iphone_pro do
Dotenv.load('.env.local', '.env.development') unless is_ci?
run_tests_for_device(
project_base_name: project_base_name,
schemes: schemes_to_test,
device: 'iPhone 15 Pro'
)
end
##############
## Carthage ##
##############
desc 'Runs carthage update followed by Rome upload (iOS) to update the S3 cache.'
desc ''
lane :do_cart_update do
Dotenv.load('.env.local', '.env.development') unless is_ci?
run_rome_update(cache_prefix: rome_cache_prefix)
end
desc 'Runs carthage bootstrap followed by Rome download (iOS) from our S3 cache'
desc ''
lane :carthage_bootstrap do
Dotenv.load('.env.local', '.env.development') unless is_ci?
rome(
command: 'download',
platform: 'iOS',
cacheprefix: rome_cache_prefix
)
carthage(
command: 'bootstrap',
platform: 'iOS',
cache_builds: true,
use_binaries: false
)
upload_command = rome_command('upload', rome_cache_prefix)
# # upload what is missing
sh("(cd ..; rome list --missing --platform ios | awk '{print $1}' | xargs rome #{upload_command} --platform ios)")
end
desc 'Download carthage dependencies cached in S3'
desc ''
lane :carthage_ci do |options|
Dotenv.load('.env.local', '.env.development') unless is_ci?
cache_prefix = options[:cache_prefix] || project_base_name
rome(
command: 'download',
platform: 'iOS',
cacheprefix: cache_prefix
)
end
def rome_command(command = 'download', _isSwift5 = false)
"#{command} --cache-prefix #{cache_prefix}"
end
desc 'Post a message to slack.'
desc ''
private_lane :post_to_slack do |options|
if ENV['SLACK_URL'].nil?
payload_text = options[:output] || ''
message = options[:message]
success = options[:success]
slack(
message: message + (success ? ' :sunglasses:' : ' :sob:'),
success: success,
default_payloads: %i[git_branch last_git_commit_message git_author test_result],
payload: {
'Build Date' => Time.new.to_s,
'Travis_Build' => get_current_build_number,
'Output' => "#{is_ci ? ENV['TRAVIS_BUILD_WEB_URL'] : ''} #{payload_text}"
}
)
end
end
######################
## SUCCESS HANDLING ##
######################
after_all do |lane|
UI.success "#{lane} finished successfully!"
end
######################
## FAILURE HANDLING ##
######################
error do |lane, exception|
UI.error "'#{lane}' Finished with errors #{exception.message}"
if is_ci
# Only update slack if running on travis
post_to_slack(
message: "'#{lane}' Finished with errors #{exception.message} :imp:",
success: false,
output: exception.message.to_s
)
end
end
end