-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
config.yml
354 lines (331 loc) · 9.76 KB
/
config.yml
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
version: 2.1
orbs:
aws-cli: circleci/aws-cli@3.1
codecov: codecov/codecov@1.1.3
aws_cli_setup: &aws_cli_setup
role-arn: $AWS_ROLE_ARN
xcode_version: &xcode_version 13.3.1
iphone_name: &iphone_name iPhone 8
preload_simulator: &preload_simulator xcrun instruments -w "iPhone 8 (15.4) [" || true
# Works around an issue in xcodebuild where it requires GitHub to have been added to the known_hosts in order for it to clone dependencies.
spm_ssh_workaround: &spm_ssh_workaround for ip in $(dig @1.1.1.1 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
# Templates
default_environment: &default_environment
CIRCLE_ARTIFACTS: /tmp
BUNDLE_PATH: vendor/bundle
FL_OUTPUT_DIR: output
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
IPHONE_NAME: *iphone_name
XCODE_VERSION: *xcode_version
PLATFORM: iOS
base_job: &base_job
macos:
xcode: *xcode_version
working_directory: ~/kickstarter
test_job: &test_job
steps:
- checkout
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- run:
name: Download GraphQL Schema
command: bin/apollo-schema-download.sh
- run:
name: Pre-load simulator
command: *preload_simulator
- run:
name: Run tests
command: make test
no_output_timeout: "20m" # 20 minutes
- restore_cache:
name: Restore Bundler
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Install Bundler
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- run:
name: Generate Slather coverage report
command: bundle exec slather coverage -x --scheme $SCHEME ./Kickstarter.xcodeproj
- codecov/upload:
file: cobertura.xml
distribute_job: &distribute_job
steps:
- checkout
- aws-cli/setup:
<<: *aws_cli_setup
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- restore_cache:
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Increment build number
command: agvtool new-version -all $(($(date +%s)/100))
- run:
name: Fastlane
command: bundle exec fastlane $LANE --verbose
no_output_timeout: "30m" # 30 minutes
environment:
FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 180
- run:
name: Upload dSYMs
command: bin/upload-dysms-firebase.sh $FIREBASE_DIR $DSYMS_FILE
- run:
name: Cleanup Temp Branch
command: make cleanup
- store_artifacts:
path: output
all_jobs: &all_jobs
- build-and-cache
- kickstarter-tests
- library-tests
- ksapi-tests
# Jobs
jobs:
build-and-cache:
<<: *base_job
environment:
- *default_environment
steps:
- checkout
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- save_cache:
name: Cache SPM
key: spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
paths:
- SourcePackages
- restore_cache:
name: Restore Bundler
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Install Bundler
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
name: Cache Bundler
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Danger
command: bin/danger.sh
# Kickstarter tests
kickstarter-tests:
<<: *base_job
<<: *test_job
environment:
- *default_environment
- SCHEME=Kickstarter-Framework-iOS
# Library tests
library-tests:
<<: *base_job
<<: *test_job
environment:
- *default_environment
- TARGET=Library
- SCHEME=Library-iOS
# KsApi tests
ksapi-tests:
<<: *base_job
<<: *test_job
environment:
- *default_environment
- SCHEME=KsApi
deploy_alpha:
<<: *base_job
environment:
- *default_environment
steps:
- checkout
- aws-cli/setup:
<<: *aws_cli_setup
- run:
name: Deploy Alpha
command: make alpha
deploy_beta:
<<: *base_job
environment:
- *default_environment
steps:
- checkout
- aws-cli/setup:
<<: *aws_cli_setup
- run:
name: Deploy Beta
command: make beta
# AppCenter and S3 bucket beta
beta:
<<: *base_job
<<: *distribute_job
environment:
- *default_environment
- LANE=beta_match_gym_appcenter_s3
- FIREBASE_DIR=Firebase-Beta
- DSYMS_FILE=KickBeta.app.dSYM.zip
# AppCenter Alpha
alpha:
<<: *base_job
<<: *distribute_job
environment:
- *default_environment
- LANE=alpha_match_gym_appcenter
- FIREBASE_DIR=Firebase-Alpha
- DSYMS_FILE=KickAlpha.app.dSYM.zip
refresh_app_store_dsyms:
<<: *base_job
environment:
- *default_environment
steps:
- checkout
- run:
name: Secrets
command: make secrets
- restore_cache:
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Download dSYMs and upload to Crashlytics
command: bundle exec fastlane refresh_dsyms
# iTunes
itunes:
<<: *base_job
<<: *distribute_job
environment:
- *default_environment
- LANE=itunes_match_gym_deliver
- FIREBASE_DIR=Firebase-Production
- DSYMS_FILE=Kickstarter.app.dSYM.zip
# Workflows
workflows:
version: 2
build:
# Matches all_jobs
jobs:
- build-and-cache
- kickstarter-tests
- library-tests
- ksapi-tests
# ** Refreshing dSYMs disabled until a suitable workaround is found for App Store Connect 2FA authentication
# or Fastlane implements API key support in this Fastlane action. Uncomment below to re-enable.
# See: https://docs.fastlane.tools/app-store-connect-api/
# https://docs.fastlane.tools/best-practices/continuous-integration/
# - refresh_app_store_dsyms:
# filters:
# branches:
# # matches all branches that begin with 'beta-dist'
# only: /beta-dist-.*/
- deploy_alpha:
context: aws
filters:
branches:
# matches all branches that contain 'feature' but do not contain 'alpha-dist'
only: /^((?!alpha\-dist).*feature.*)*$/
requires: *all_jobs
- deploy_beta:
context: aws
filters:
branches:
only: main
requires: *all_jobs
- beta:
filters:
branches:
# matches all branches that begin with 'beta-dist'
only: /beta-dist-.*/
requires: *all_jobs
- alpha:
filters:
branches:
# matches all branches that begin with 'alpha-dist'
only: /alpha-dist.*/
requires: *all_jobs
- itunes:
context: aws
filters:
branches:
# matches branch named exactly `itunes-dist`
only: itunes-dist
requires: *all_jobs
experimental:
notify:
branches:
only:
# matches branch named exactly `main`
- main
# matches all branches that begin with 'alpha-dist'
- /alpha-dist.*/
# matches all branches that begin with 'beta-dist'
- /beta-dist-.*/
# matches branch named exactly `itunes-dist`
- itunes-dist