This repository has been archived by the owner on Jan 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathFastfile
236 lines (200 loc) · 7.59 KB
/
Fastfile
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
fastlane_version "2.129.0"
fastlane_require 'circleci_artifact'
default_platform :ios
# Set by build environment
# FL_HOCKEY_API_TOKEN
# MATCH_PASSWORD
# SLACK_URL - set the hook URL in the CircleCI environment
ENV['RZ_ARTIFACTS'] ||= ENV['CIRCLE_ARTIFACTS'] || './build'
ENV['RZ_TEST_REPORTS'] ||= ENV['CIRCLE_TEST_REPORTS'] || './build'
ENV['FASTLANE_XCODE_LIST_TIMEOUT'] = '120'
ENV['CI_BUILD'] = 'yes'
ENV['GYM_OUTPUT_NAME'] = 'PRODUCTNAME'
ENV['FL_HOCKEY_IPA'] = "#{ENV['RZ_ARTIFACTS']}/#{ENV['GYM_OUTPUT_NAME']}.ipa"
ENV['FL_HOCKEY_NOTIFY'] = '0'
DERIVED_DATA_PATH = "#{ENV['RZ_TEST_REPORTS']}/derived_data"
TEST_SCHEME = "debug-PRODUCTNAME"
platform :ios do
before_all do
if ENV['RZ_ARTIFACTS'] && ENV['RZ_ARTIFACTS'].length > 0
sh 'rm -rf $RZ_ARTIFACTS && mkdir $RZ_ARTIFACTS'
end
end
desc "Runs tests"
lane :test do
scan(
output_types: 'junit,html',
scheme: TEST_SCHEME,
output_directory: "#{ENV['RZ_TEST_REPORTS']}/scan",
buildlog_path: "#{ENV['RZ_ARTIFACTS']}",
code_coverage: true,
derived_data_path: DERIVED_DATA_PATH
)
if !ENV['CIRCLE_TEST_REPORTS'].nil?
# CircleCI requires the "xml" extension for test reporting
puts "Fixing JUnit report name"
sh "cp #{ENV['RZ_TEST_REPORTS']}/scan/report.junit #{ENV['RZ_TEST_REPORTS']}/scan/report.xml"
end
end
desc "Runs Code Coverage"
lane :coverage do
slather_use_coveralls = "false"
slather_use_circleci = "false"
if !ENV['CIRCLE_BUILD_NUM'].nil?
slather_use_circleci = "true"
end
# Add targets here as you create internal frameworks
xcov_targets = "debug-PRODUCTNAME.app, Services.framework"
xcov_scheme = TEST_SCHEME
xcov_workspace = "PRODUCTNAME.xcworkspace"
xcov(
workspace: xcov_workspace,
scheme: xcov_scheme,
output_directory: "#{ENV['RZ_TEST_REPORTS']}/xcov",
include_targets: xcov_targets,
derived_data_path: DERIVED_DATA_PATH
)
slather_proj = "PRODUCTNAME.xcodeproj"
slather_workspace = xcov_workspace
slather_scheme = TEST_SCHEME
# Add binaries here as you create internal frameworks
slather_binaries = ['debug-PRODUCTNAME', 'Services']
slather_output_directory = "#{ENV['RZ_TEST_REPORTS']}/slather"
# html and cobertura_xml output must be run separately
slather(
proj: slather_proj,
workspace: slather_workspace,
scheme: slather_scheme,
binary_basename: slather_binaries,
output_directory: slather_output_directory,
html: "true",
build_directory: DERIVED_DATA_PATH
)
# Using Cobertura XML allows us to upload to Codecov.io
# Uploading to codecov is handled separately in the .circleci/config.yml
slather(
proj: slather_proj,
workspace: slather_workspace,
scheme: slather_scheme,
binary_basename: slather_binaries,
output_directory: slather_output_directory,
circleci: slather_use_circleci,
coveralls: slather_use_coveralls,
cobertura_xml: "true",
build_directory: DERIVED_DATA_PATH
)
end
desc "Posts screenshots to Slack"
lane :slackshots do
# Getting artifact URLs from CircleCI
# You must set up the CIRCLE_API_TOKEN manually using these instructions
# https://github.com/Rightpoint/ios-template#danger
token = ENV['CIRCLE_API_TOKEN']
# These are already in the Circle environment
# https://circleci.com/docs/2.0/env-vars/#build-specific-environment-variables
username = ENV['CIRCLE_PROJECT_USERNAME']
reponame = ENV['CIRCLE_PROJECT_REPONAME']
build = ENV['CIRCLE_BUILD_NUM']
if !(token.nil? or username.nil? or reponame.nil? or build.nil?)
fetcher = CircleciArtifact::Fetcher.new(token: token, username: username, reponame: reponame, build: build)
screenshots = CircleciArtifact::Query.new(url_substring: 'screenshots/screenshots.html')
queries = [screenshots]
results = fetcher.fetch_queries(queries)
screenshots_url = results.url_for_query(screenshots)
if !screenshots_url.nil?
slack(message: "[Screenshots](#{screenshots_url})", success: true)
else
slack(message: "Screenshots are missing!", success: false)
end
else
slack(message: "Missing CircleCI artifacts. Most likely the [CIRCLE_API_TOKEN](https://github.com/Rightpoint/circleci_artifact#getting-started) is not set, or not running on CircleCI.", success: false)
end
end
desc "Builds and submits a Develop release to Hockey"
lane :develop do
match
build("develop-PRODUCTNAME", 'enterprise', {})
hockey(public_identifier: 'ZZHOCKEY_DEVELOP_IDZZ')
# upload_symbols_to_crashlytics(:api_token => 'ZZCRASHLYTICS_API_TOKEN_DEVELOPZZ')
slack(message: "Successfully uploaded build #{build_number} to develop", success: true)
end
desc "Builds and submits a Sprint release to Hockey"
lane :sprint do
match
build("sprint-PRODUCTNAME", 'enterprise', {})
hockey(public_identifier: 'ZZHOCKEY_SPRINT_IDZZ')
# upload_symbols_to_crashlytics(:api_token => 'ZZCRASHLYTICS_API_TOKEN_SPRINTZZ')
slack(message: "Successfully uploaded build #{build_number} to sprint", success: true)
end
# desc "Builds and submits an App Store release to TestFlight"
lane :beta do
# match(type: "appstore")
#
# build("appStore-PRODUCTNAME", 'app-store', {})
# pilot(
# distribute_external: false,
# skip_waiting_for_build_processing: true,
# )
# upload_symbols_to_crashlytics(:api_token => 'ZZCRASHLYTICS_API_TOKEN_APPSTOREZZ')
# slack(message: "Successfully uploaded build #{build_number} to test flight", success: true)
end
# Helpers ----------------------
desc "Sync Project and Directory Structure"
lane :synx do
sh "cd .. && synx PRODUCTNAME.xcodeproj"
end
desc "Syncs all match credentials with the developer portal, generating any required credentials"
lane :sync_match do
# Wildcard App ID by default.
match(
readonly: false,
type: "enterprise",
)
# NOTE: ! Don't comment any of these in without this without specifying a git_branch
# in your Matchfile. These should be scoped per project using git branches.
# Comment this in if you would like to store a shared debug profile in match
# match(
# readonly: false,
# type: "development",
# app_identifier: FIXME: Your Debug App ID,
# )
# Comment these in if you have custom entitlements and need to generate credentials
# for them. Ensure you've configured your app ids in the developer portal and
# specify them here:
# match(
# readonly: false,
# type: "enterprise",
# app_identifier: FIXME: Your Develop App ID,
# )
#
# match(
# readonly: false,
# type: "enterprise",
# app_identifier: FIXME: Your Sprint App ID,
# )
# Comment this in and configure these parameters to support signing app store releases.
# you can also see the match docs regarding match import instead of syncing them.
# match(
# username: [email protected], # ensure this account has access to the developer portal
# readonly: false,
# type: "appstore",
# app_identifier: FIXME: Your Appstore App ID,
# team_id: FIXME: Your Appstore Team ID
# )
end
def build(scheme, export_method, export_options)
gym(
output_directory: "#{ENV['RZ_ARTIFACTS']}",
output_name: "PRODUCTNAME",
export_method: export_method,
scheme: scheme,
include_bitcode: true,
xcargs: "BUILD_NUMBER=#{build_number}",
buildlog_path: "#{ENV['RZ_ARTIFACTS']}",
export_options: export_options
)
end
def build_number
`git rev-list HEAD --count`.chomp()
end
end