Skip to content

Commit 64cf2b3

Browse files
authored
feat(ops): Pipeline improvements, deploy step (#232)
* Run tests in parallel * Save junit results for plugins, fix gem cache key * Add deployment step
1 parent 0075df7 commit 64cf2b3

File tree

4 files changed

+361
-38
lines changed

4 files changed

+361
-38
lines changed

.circleci/config.yml

Lines changed: 94 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ defaults: &defaults
66
macos:
77
xcode: "11.2.1"
88
working_directory: ~/amplify-ios
9+
environment:
10+
BUNDLE_PATH: vendor/bundle
911

1012
references:
1113
repo_cache_key: &repo_cache_key
@@ -38,9 +40,22 @@ commands:
3840
pre start simulator, build may fail if simulator is not started
3941
steps:
4042
- run:
41-
name: pre-start simulator
43+
name: Pre-start simulator
4244
command: bash ~/amplify-ios/CircleciScripts/pre_start_simulator.sh
4345

46+
restore_gems:
47+
steps:
48+
- restore_cache:
49+
keys:
50+
- v1-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
51+
- v1-gems-
52+
53+
check_bundle:
54+
steps:
55+
- run:
56+
name: Check bundle
57+
command: bundle check --path $BUNDLE_PATH || bundle install --path $BUNDLE_PATH
58+
4459
save_plugin_pods:
4560
parameters:
4661
prefix:
@@ -71,20 +86,40 @@ jobs:
7186
key: *repo_cache_key
7287
paths:
7388
- ~/amplify-ios
89+
90+
install_gems:
91+
<<: *defaults
92+
steps:
93+
- *restore_repo
94+
- restore_gems
95+
- run:
96+
name: Bundle install
97+
command: bundle check --path $BUNDLE_PATH || bundle install --path $BUNDLE_PATH
98+
environment:
99+
BUNDLE_JOBS: 4
100+
BUNDLE_RETRY: 3
101+
- save_cache:
102+
key: v1-gems-{{ checksum "~/amplify-ios/Gemfile.lock" }}
103+
paths:
104+
- vendor/bundle
74105

75106
build_test_amplify:
76107
<<: *defaults
77108
steps:
78109
- *restore_repo
79110
- pre_start_simulator
80111
- run: pod install
112+
- restore_gems
113+
- check_bundle
81114
- run:
82-
name: build amplify
83-
command: xcodebuild build -workspace Amplify.xcworkspace -scheme Amplify -sdk iphonesimulator -destination "${destination}"
115+
name: Build amplify
116+
command: xcodebuild build-for-testing -workspace Amplify.xcworkspace -scheme Amplify -sdk iphonesimulator -destination "${destination}" | xcpretty
84117
- run:
85-
name: test amplify
86-
command: xcodebuild test -enableThreadSanitizer NO -workspace Amplify.xcworkspace -scheme Amplify -sdk iphonesimulator -destination "${destination}"
87-
118+
name: Test amplify
119+
command: xcodebuild test -enableThreadSanitizer NO -workspace Amplify.xcworkspace -scheme Amplify -sdk iphonesimulator -destination "${destination}" | xcpretty --simple --color --report junit
120+
- store_test_results:
121+
path: build/reports
122+
88123
plugin_unit_test:
89124
<<: *defaults
90125
parameters:
@@ -104,72 +139,93 @@ jobs:
104139
- run: pod install
105140
- save_plugin_pods:
106141
prefix: << parameters.path >>
107-
142+
- restore_gems
143+
- check_bundle
108144
- run:
109-
name: build << parameters.path >>
110-
command: xcodebuild build-for-testing -workspace << parameters.workspace >>.xcworkspace -scheme << parameters.scheme >> -sdk iphonesimulator -destination "${destination}"
145+
name: Build << parameters.path >>
146+
command: xcodebuild build-for-testing -workspace << parameters.workspace >>.xcworkspace -scheme << parameters.scheme >> -sdk iphonesimulator -destination "${destination}" | xcpretty
147+
- run:
148+
name: Test << parameters.path >>
149+
command: xcodebuild test -workspace << parameters.workspace >>.xcworkspace -scheme << parameters.scheme >> -sdk iphonesimulator -destination "${destination}" | xcpretty --simple --color --report junit
150+
- store_test_results:
151+
path: build/reports
152+
153+
deploy:
154+
<<: *defaults
155+
description: deploy pods to trunk
156+
steps:
157+
- *restore_repo
158+
- restore_gems
159+
- check_bundle
160+
# - run:
161+
# name: Bump pod versions
162+
# command: bundle exec fastlane bump_podspecs_patch
111163
- run:
112-
name: test << parameters.path >>
113-
command: xcodebuild test -workspace << parameters.workspace >>.xcworkspace -scheme << parameters.scheme >> -sdk iphonesimulator -destination "${destination}"
164+
name: Release pods
165+
command: bundle exec fastlane release_pods
166+
114167

115168
workflows:
116-
build_test:
169+
build_test_deploy:
117170
jobs:
118171
- checkout_code
119-
# Running all the tests in parallel leads to threading issues
120-
# Breaking them up into 2 groups:
121-
# Group 1
172+
- install_gems:
173+
requires:
174+
- checkout_code
122175
- build_test_amplify:
123176
requires:
124-
- checkout_code
177+
- install_gems
125178
- plugin_unit_test:
126179
name: unit_test_api
127180
path: API
128181
workspace: APICategoryPlugin
129182
scheme: AWSAPICategoryPlugin
130183
requires:
131-
- checkout_code
184+
- install_gems
132185
- plugin_unit_test:
133186
name: unit_test_analytics
134187
path: Analytics
135188
workspace: AnalyticsCategoryPlugin
136189
scheme: AWSPinpointAnalyticsPlugin
137190
requires:
138-
- checkout_code
191+
- install_gems
139192
- plugin_unit_test:
140193
name: unit_test_storage
141194
path: Storage
142195
workspace: StoragePlugin
143196
scheme: AWSS3StoragePlugin
144197
requires:
145-
- build_test_amplify
146-
- unit_test_api
147-
- unit_test_analytics
198+
- install_gems
148199
- plugin_unit_test:
149200
name: unit_test_predictions
150201
path: Predictions
151202
workspace: PredictionsCategoryPlugin
152203
scheme: AWSPredictionsPlugin
153204
requires:
154-
- build_test_amplify
155-
- unit_test_api
156-
- unit_test_analytics
205+
- install_gems
157206
- plugin_unit_test:
158-
name: unit_test_predictions_core_ml
207+
name: unit_test_core_ml
159208
path: Predictions
160209
workspace: PredictionsCategoryPlugin
161210
scheme: CoreMLPredictionsPlugin
162211
requires:
163-
- build_test_amplify
164-
- unit_test_api
165-
- unit_test_analytics
166-
# - plugin_unit_test:
167-
# name: unit_test_datastore
168-
# path: DataStore
169-
# workspace: DataStoreCategoryPlugin
170-
# scheme: AWSDataStoreCategoryPlugin
171-
# requires:
172-
# - build_test_amplify
173-
# - unit_test_api
174-
# - unit_test_analytics
175-
# - unit_test_storage
212+
- install_gems
213+
- plugin_unit_test:
214+
name: unit_test_datastore
215+
path: DataStore
216+
workspace: DataStoreCategoryPlugin
217+
scheme: AWSDataStoreCategoryPlugin
218+
requires:
219+
- install_gems
220+
- deploy:
221+
filters:
222+
branches:
223+
only:
224+
- release
225+
requires:
226+
- build_test_amplify
227+
- unit_test_api
228+
- unit_test_analytics
229+
- unit_test_storage
230+
- unit_test_predictions
231+
- unit_test_datastore

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Gemfile
2+
3+
source 'https://rubygems.org'
4+
gem 'xcpretty'
5+
gem 'cocoapods'
6+
gem 'fastlane'

0 commit comments

Comments
 (0)