|
4 | 4 | # Using 1.0 of the Orbs means it will use the latest 1.0.x version from https://github.com/wordpress-mobile/circleci-orbs |
5 | 5 | ios: wordpress-mobile/[email protected] |
6 | 6 | git: wordpress-mobile/[email protected] |
| 7 | + |
7 | 8 |
|
8 | 9 | commands: |
9 | 10 | fix-circleci: |
@@ -32,22 +33,80 @@ jobs: |
32 | 33 | root: ./ |
33 | 34 | paths: |
34 | 35 | - DerivedData/Build/Products |
| 36 | + - vendor/bundle |
35 | 37 |
|
36 | 38 | Unit Tests: |
37 | 39 | executor: |
38 | 40 | name: ios/default |
39 | 41 | xcode-version: "11.2.1" |
40 | 42 | steps: |
| 43 | + - git/shallow-checkout |
41 | 44 | - ios/boot-simulator: |
42 | 45 | xcode-version: "11.2.1" |
43 | 46 | device: iPhone 11 |
44 | 47 | - attach_workspace: |
45 | 48 | at: ./ |
| 49 | + - run: |
| 50 | + name: Prepare Bundle |
| 51 | + command: bundle --path vendor/bundle |
46 | 52 | - ios/wait-for-simulator |
47 | | - - ios/xcodebuild: |
48 | | - command: test-without-building |
49 | | - arguments: -xctestrun DerivedData/Build/Products/WooCommerce_UnitTests_iphonesimulator13.2-x86_64.xctestrun -destination "platform=iOS Simulator,id=$SIMULATOR_UDID" |
50 | | - - ios/save-xcodebuild-artifacts |
| 53 | + - run: |
| 54 | + name: Run Unit Tests |
| 55 | + command: > |
| 56 | + bundle exec fastlane test_without_building |
| 57 | + xctestrun:DerivedData/Build/Products/WooCommerce_UnitTests_iphonesimulator13.2-x86_64.xctestrun |
| 58 | + destination:"platform=iOS Simulator,id=$SIMULATOR_UDID" try_count:3 |
| 59 | + - ios/save-xcodebuild-artifacts: |
| 60 | + result-bundle-path: build/results |
| 61 | + UI Tests: |
| 62 | + parameters: |
| 63 | + device: |
| 64 | + type: string |
| 65 | + post-to-slack: |
| 66 | + description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set. |
| 67 | + type: boolean |
| 68 | + default: false |
| 69 | + executor: |
| 70 | + name: ios/default |
| 71 | + xcode-version: "11.2.1" |
| 72 | + steps: |
| 73 | + - git/shallow-checkout |
| 74 | + - ios/boot-simulator: |
| 75 | + xcode-version: "11.2.1" |
| 76 | + device: << parameters.device >> |
| 77 | + - attach_workspace: |
| 78 | + at: ./ |
| 79 | + - run: |
| 80 | + name: Prepare Bundle |
| 81 | + command: bundle --path vendor/bundle |
| 82 | + - run: |
| 83 | + name: Run mocks |
| 84 | + command: ./WooCommerce/WooCommerceUITests/Mocks/scripts/start.sh 8282 |
| 85 | + background: true |
| 86 | + - ios/wait-for-simulator |
| 87 | + - run: |
| 88 | + name: Run UI Tests |
| 89 | + command: > |
| 90 | + bundle exec fastlane test_without_building |
| 91 | + xctestrun:DerivedData/Build/Products/WooCommerce_UITests_iphonesimulator13.2-x86_64.xctestrun |
| 92 | + destination:"platform=iOS Simulator,id=$SIMULATOR_UDID" try_count:3 |
| 93 | + - ios/save-xcodebuild-artifacts: |
| 94 | + result-bundle-path: build/results |
| 95 | + - when: |
| 96 | + condition: << parameters.post-to-slack >> |
| 97 | + steps: |
| 98 | + - run: |
| 99 | + name: Prepare Slack message |
| 100 | + when: always |
| 101 | + command: | |
| 102 | + # Get the name of the device that is running. Using "<< parameters.device >>" can cause slack formatting errors. |
| 103 | + DEVICE_NAME=$(xcrun simctl list -j | jq -r --arg UDID $SIMULATOR_UDID '.devices[] | .[] | select(.udid == "\($UDID)") | .name') |
| 104 | + 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 |
| 105 | + - slack/status: |
| 106 | + fail_only: true |
| 107 | + include_job_number_field: false |
| 108 | + include_project_field: false |
| 109 | + failure_message: '${SLACK_FAILURE_MESSAGE}' |
51 | 110 | Installable Build: |
52 | 111 | executor: |
53 | 112 | name: ios/default |
@@ -105,6 +164,47 @@ workflows: |
105 | 164 | - Build Tests |
106 | 165 | - Unit Tests: |
107 | 166 | requires: [ "Build Tests" ] |
| 167 | + # Always run UI tests on develop and release branches |
| 168 | + - UI Tests: |
| 169 | + name: UI Tests (iPhone 11) |
| 170 | + device: iPhone 11 |
| 171 | + post-to-slack: true |
| 172 | + requires: [ "Build Tests" ] |
| 173 | + filters: |
| 174 | + branches: |
| 175 | + only: |
| 176 | + - develop |
| 177 | + - /^release.*/ |
| 178 | + - UI Tests: |
| 179 | + name: UI Tests (iPad Air 3rd generation) |
| 180 | + device: iPad Air \\(3rd generation\\) |
| 181 | + post-to-slack: true |
| 182 | + requires: [ "Build Tests" ] |
| 183 | + filters: |
| 184 | + branches: |
| 185 | + only: |
| 186 | + - develop |
| 187 | + - /^release.*/ |
| 188 | + #Optionally run UI tests on PRs |
| 189 | + Optional Tests: |
| 190 | + jobs: |
| 191 | + - Hold: |
| 192 | + type: approval |
| 193 | + filters: |
| 194 | + branches: |
| 195 | + ignore: |
| 196 | + - develop |
| 197 | + - /^release.*/ |
| 198 | + - Build Tests: |
| 199 | + requires: [ "Hold" ] |
| 200 | + - UI Tests: |
| 201 | + name: Optional UI Tests (iPhone 11) |
| 202 | + device: iPhone 11 |
| 203 | + requires: [ "Build Tests" ] |
| 204 | + - UI Tests: |
| 205 | + name: Optional UI Tests (iPad Air 3rd generation) |
| 206 | + device: iPad Air \\(3rd generation\\) |
| 207 | + requires: [ "Build Tests" ] |
108 | 208 | Installable Build: |
109 | 209 | jobs: |
110 | 210 | - Hold: |
|
0 commit comments