|
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,74 @@ 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: bundle exec fastlane test_without_building xctestrun:DerivedData/Build/Products/WooCommerce_UnitTests_iphonesimulator13.2-x86_64.xctestrun destination:"platform=iOS Simulator,id=$SIMULATOR_UDID" try_count:3 |
| 56 | + - ios/save-xcodebuild-artifacts: |
| 57 | + result-bundle-path: build/results |
| 58 | + UI Tests: |
| 59 | + parameters: |
| 60 | + device: |
| 61 | + type: string |
| 62 | + post-to-slack: |
| 63 | + description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set. |
| 64 | + type: boolean |
| 65 | + default: false |
| 66 | + executor: |
| 67 | + name: ios/default |
| 68 | + xcode-version: "11.2.1" |
| 69 | + steps: |
| 70 | + - git/shallow-checkout |
| 71 | + - ios/boot-simulator: |
| 72 | + xcode-version: "11.2.1" |
| 73 | + device: << parameters.device >> |
| 74 | + - attach_workspace: |
| 75 | + at: ./ |
| 76 | + - run: |
| 77 | + name: Prepare Bundle |
| 78 | + command: bundle --path vendor/bundle |
| 79 | + - run: |
| 80 | + name: Run mocks |
| 81 | + command: ./WooCommerce/WooCommerceUITests/Mocks/scripts/start.sh 8282 |
| 82 | + background: true |
| 83 | + - ios/wait-for-simulator |
| 84 | + - run: |
| 85 | + name: Run UI Tests |
| 86 | + command: bundle exec fastlane test_without_building xctestrun:DerivedData/Build/Products/WooCommerce_UITests_iphonesimulator13.2-x86_64.xctestrun destination:"platform=iOS Simulator,id=$SIMULATOR_UDID" try_count:3 |
| 87 | + - ios/save-xcodebuild-artifacts: |
| 88 | + result-bundle-path: build/results |
| 89 | + - when: |
| 90 | + condition: << parameters.post-to-slack >> |
| 91 | + steps: |
| 92 | + - run: |
| 93 | + name: Prepare Slack message |
| 94 | + when: always |
| 95 | + command: | |
| 96 | + # Get the name of the device that is running. Using "<< parameters.device >>" can cause slack formatting errors. |
| 97 | + DEVICE_NAME=$(xcrun simctl list -j | jq -r --arg UDID $SIMULATOR_UDID '.devices[] | .[] | select(.udid == "\($UDID)") | .name') |
| 98 | + 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 |
| 99 | + - slack/status: |
| 100 | + fail_only: true |
| 101 | + include_job_number_field: false |
| 102 | + include_project_field: false |
| 103 | + failure_message: '${SLACK_FAILURE_MESSAGE}' |
51 | 104 | Installable Build: |
52 | 105 | executor: |
53 | 106 | name: ios/default |
@@ -105,6 +158,44 @@ workflows: |
105 | 158 | - Build Tests |
106 | 159 | - Unit Tests: |
107 | 160 | requires: [ "Build Tests" ] |
| 161 | + # Always run UI tests on develop and release branches |
| 162 | + - UI Tests: |
| 163 | + name: UI Tests (iPhone 11) |
| 164 | + device: iPhone 11 |
| 165 | + post-to-slack: true |
| 166 | + requires: [ "Build Tests" ] |
| 167 | + filters: |
| 168 | + branches: |
| 169 | + only: |
| 170 | + - develop |
| 171 | + - /^release.*/ |
| 172 | + - UI Tests: |
| 173 | + name: UI Tests (iPad Air 3rd generation) |
| 174 | + device: iPad Air \\(3rd generation\\) |
| 175 | + post-to-slack: true |
| 176 | + requires: [ "Build Tests" ] |
| 177 | + filters: |
| 178 | + branches: |
| 179 | + only: |
| 180 | + - develop |
| 181 | + - /^release.*/ |
| 182 | + #Optionally run UI tests on PRs |
| 183 | + - Optional Tests: |
| 184 | + type: approval |
| 185 | + requires: [ "Build Tests" ] |
| 186 | + filters: |
| 187 | + branches: |
| 188 | + ignore: |
| 189 | + - develop |
| 190 | + - /^release.*/ |
| 191 | + - UI Tests: |
| 192 | + name: Optional UI Tests (iPhone 11) |
| 193 | + device: iPhone 11 |
| 194 | + requires: [ "Optional Tests" ] |
| 195 | + - UI Tests: |
| 196 | + name: Optional UI Tests (iPad Air 3rd generation) |
| 197 | + device: iPad Air \\(3rd generation\\) |
| 198 | + requires: [ "Optional Tests" ] |
108 | 199 | Installable Build: |
109 | 200 | jobs: |
110 | 201 | - Hold: |
|
0 commit comments