Skip to content

Commit c3665ef

Browse files
authored
Merge pull request #3876 from woocommerce/fix/select-correct-device-on-circleci
Update CircleCI script to fix wrong iOS sim usage
2 parents c402f55 + bd49fb7 commit c3665ef

File tree

2 files changed

+56
-29
lines changed

2 files changed

+56
-29
lines changed

.circleci/config.yml

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ orbs:
66
git: wordpress-mobile/[email protected]
77
slack: circleci/[email protected]
88

9+
xcode_version: &xcode_version
10+
xcode-version: "12.0.0"
11+
12+
iphone_test_device: &iphone_test_device
13+
device: iPhone 11
14+
ios-version: "14.0"
15+
16+
ipad_test_device: &ipad_test_device
17+
device: iPad Air (4th generation)
18+
ios-version: "14.0"
19+
920
commands:
1021
fix-image:
1122
steps:
@@ -30,9 +41,16 @@ commands:
3041
3142
jobs:
3243
Build Tests:
44+
parameters:
45+
device:
46+
type: string
47+
description: The device (e.g. "iPhone 11") to use when running unit tests.
48+
ios-version:
49+
type: string
50+
description: The iOS version (e.g. "14.0") of the device used to run tests.
3351
executor:
3452
name: ios/default
35-
xcode-version: "12.0.0"
53+
<<: *xcode_version
3654
steps:
3755
- git/shallow-checkout
3856
- fix-image
@@ -44,51 +62,55 @@ jobs:
4462
command: bundle exec fastlane run configure_apply
4563
- run:
4664
name: Build for Testing
47-
command: bundle exec fastlane build_for_testing
65+
command: bundle exec fastlane build_for_testing device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>'
4866
- persist_to_workspace:
4967
root: ./
5068
paths:
5169
- DerivedData/Build/Products
5270
- vendor/bundle
5371

5472
Unit Tests:
73+
parameters:
74+
device:
75+
type: string
76+
description: The device (e.g. "iPhone 11") to use when running unit tests.
77+
ios-version:
78+
type: string
79+
description: The iOS version (e.g. "14.0") of the device used to run tests.
5580
executor:
5681
name: ios/default
57-
xcode-version: "12.0.0"
82+
<<: *xcode_version
5883
steps:
5984
- git/shallow-checkout
6085
- fix-image
61-
- ios/boot-simulator:
62-
xcode-version: "12.0.0"
63-
device: iPhone 11
6486
- attach_workspace:
6587
at: ./
6688
- run:
6789
name: Prepare Bundle
6890
command: bundle --path vendor/bundle
69-
- ios/wait-for-simulator
7091
- run:
7192
name: Run Unit Tests
72-
command: bundle exec fastlane test_without_building name:UnitTests try_count:3
93+
command: bundle exec fastlane test_without_building name:UnitTests try_count:3 device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>'
7394
- ios/save-xcodebuild-artifacts:
7495
result-bundle-path: build/results
7596
UI Tests:
7697
parameters:
7798
device:
7899
type: string
100+
description: The device (e.g. "iPhone 11") to use when running unit tests.
101+
ios-version:
102+
type: string
103+
description: The iOS version (e.g. "14.0") of the device used to run tests.
79104
post-to-slack:
80105
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
81106
type: boolean
82107
default: false
83108
executor:
84109
name: ios/default
85-
xcode-version: "12.0.0"
110+
<<: *xcode_version
86111
steps:
87112
- git/shallow-checkout
88113
- fix-image
89-
- ios/boot-simulator:
90-
xcode-version: "12.0.0"
91-
device: << parameters.device >>
92114
- attach_workspace:
93115
at: ./
94116
- run:
@@ -98,10 +120,9 @@ jobs:
98120
name: Run mocks
99121
command: ./WooCommerce/WooCommerceUITests/Mocks/scripts/start.sh 8282
100122
background: true
101-
- ios/wait-for-simulator
102123
- run:
103124
name: Run UI Tests
104-
command: bundle exec fastlane test_without_building name:UITests
125+
command: bundle exec fastlane test_without_building name:UITests device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>'
105126
- ios/save-xcodebuild-artifacts:
106127
result-bundle-path: build/results
107128
- when:
@@ -111,9 +132,8 @@ jobs:
111132
name: Prepare Slack message
112133
when: always
113134
command: |
114-
# Get the name of the device that is running. Using "<< parameters.device >>" can cause slack formatting errors.
115-
DEVICE_NAME=$(xcrun simctl list -j | jq -r --arg UDID $SIMULATOR_UDID '.devices[] | .[] | select(.udid == "\($UDID)") | .name')
116-
echo "export SLACK_FAILURE_MESSAGE=':red_circle: WooCommerce iOS UI tests failed on ${DEVICE_NAME} in \`${CIRCLE_BRANCH}\` branch by ${CIRCLE_USERNAME}.\n\nPlease reach out in #platform9 if you think this failure is not caused by your changes, so we can investigate.'" >> $BASH_ENV
135+
# Get the name of the device that is running.
136+
echo "export SLACK_FAILURE_MESSAGE=':red_circle: WooCommerce iOS UI tests failed on << parameters.device >> in \`${CIRCLE_BRANCH}\` branch by ${CIRCLE_USERNAME}.\n\nPlease reach out in #platform9 if you think this failure is not caused by your changes, so we can investigate.'" >> $BASH_ENV
117137
- slack/status:
118138
fail_only: true
119139
include_job_number_field: false
@@ -122,7 +142,7 @@ jobs:
122142
Installable Build:
123143
executor:
124144
name: ios/default
125-
xcode-version: "12.0.0"
145+
<<: *xcode_version
126146
steps:
127147
- git/shallow-checkout
128148
- fix-image
@@ -144,9 +164,9 @@ jobs:
144164
path: Artifacts
145165
destination: Artifacts
146166
Release Build:
147-
executor:
167+
executor:
148168
name: ios/default
149-
xcode-version: "12.0.0"
169+
<<: *xcode_version
150170
environment:
151171
HOMEBREW_NO_AUTO_UPDATE: 1
152172
steps:
@@ -183,13 +203,15 @@ jobs:
183203
workflows:
184204
woocommerce_ios:
185205
jobs:
186-
- Build Tests
206+
- Build Tests:
207+
<<: *iphone_test_device
187208
- Unit Tests:
209+
<<: *iphone_test_device
188210
requires: [ "Build Tests" ]
189211
# Always run UI tests on develop and release branches
190212
- UI Tests:
191-
name: UI Tests (iPhone 11)
192-
device: iPhone 11
213+
name: UI Tests (iPhone)
214+
<<: *iphone_test_device
193215
post-to-slack: true
194216
requires: [ "Build Tests" ]
195217
filters:
@@ -198,8 +220,8 @@ workflows:
198220
- develop
199221
- /^release.*/
200222
- UI Tests:
201-
name: UI Tests (iPad Air 4th generation)
202-
device: iPad Air \\(4th generation\\)
223+
name: UI Tests (iPad)
224+
<<: *ipad_test_device
203225
post-to-slack: true
204226
requires: [ "Build Tests" ]
205227
filters:
@@ -218,14 +240,15 @@ workflows:
218240
- develop
219241
- /^release.*/
220242
- Build Tests:
243+
<<: *iphone_test_device
221244
requires: [ "Hold" ]
222245
- UI Tests:
223-
name: Optional UI Tests (iPhone 11)
224-
device: iPhone 11
246+
name: Optional UI Tests (iPhone)
247+
<<: *iphone_test_device
225248
requires: [ "Build Tests" ]
226249
- UI Tests:
227-
name: Optional UI Tests (iPad Air 4th generation)
228-
device: iPad Air \\(4th generation\\)
250+
name: Optional UI Tests (iPad)
251+
<<: *ipad_test_device
229252
requires: [ "Build Tests" ]
230253
Installable Build:
231254
jobs:

fastlane/Fastfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ ENV["APP_STORE_STRINGS_FILE_NAME"]="AppStoreStrings.pot"
387387
scheme: "WooCommerce",
388388
derived_data_path: "DerivedData",
389389
build_for_testing: true,
390+
device: options[:device],
391+
deployment_target_version: options[:ios_version],
390392
)
391393
end
392394

@@ -754,6 +756,8 @@ end
754756
multi_scan(
755757
workspace: "WooCommerce.xcworkspace",
756758
scheme: "WooCommerce",
759+
device: options[:device],
760+
deployment_target_version: options[:ios_version],
757761
test_without_building: true,
758762
xctestrun: testPlanPath,
759763
try_count: options[:try_count],

0 commit comments

Comments
 (0)