|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +orbs: |
| 4 | + android: circleci/android@0.2.1 |
| 5 | + |
| 6 | + |
| 7 | +#------------------------------ |
| 8 | +#---------- COMMANDS ---------- |
| 9 | +#------------------------------ |
| 10 | +commands: |
| 11 | + write-workspace: |
| 12 | + steps: |
| 13 | + - persist_to_workspace: |
| 14 | + root: ~/code |
| 15 | + paths: |
| 16 | + - ./ |
| 17 | + |
| 18 | + read-workspace: |
| 19 | + steps: |
| 20 | + - attach_workspace: |
| 21 | + at: ~/code |
| 22 | + |
| 23 | + restore-gradle-cache: |
| 24 | + steps: |
| 25 | + - run: |
| 26 | + name: Generate cache key |
| 27 | + command: cd MapboxSearch && ./../scripts/checksum.sh /tmp/checksum.txt |
| 28 | + - restore_cache: |
| 29 | + keys: |
| 30 | + - deps-{{ checksum "/tmp/checksum.txt" }} |
| 31 | + # In case if cache for the version specified above is not present |
| 32 | + - deps- |
| 33 | + - run: |
| 34 | + name: Download Dependencies |
| 35 | + command: cd MapboxSearch && ./gradlew androidDependencies |
| 36 | + - save_cache: |
| 37 | + paths: |
| 38 | + - ~/.gradle |
| 39 | + key: deps-{{ checksum "/tmp/checksum.txt" }} |
| 40 | + |
| 41 | + login-google-cloud-platform: |
| 42 | + steps: |
| 43 | + - run: |
| 44 | + name: Log in to Google Cloud Platform |
| 45 | + shell: /bin/bash -euo pipefail |
| 46 | + command: | |
| 47 | + echo "${GCLOUD_SERVICE_ACCOUNT_JSON}" > secret.json |
| 48 | + gcloud auth activate-service-account --key-file secret.json --project mapbox-search-android |
| 49 | + rm secret.json |
| 50 | +
|
| 51 | + set-up-aws-for-android: |
| 52 | + steps: |
| 53 | + - run: |
| 54 | + name: Set up AWS access for Android environment |
| 55 | + command: | |
| 56 | + curl -Ls https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-linux-amd64 > mbx-ci |
| 57 | + chmod 755 ./mbx-ci |
| 58 | + ./mbx-ci aws setup |
| 59 | +
|
| 60 | + verify-codebase: |
| 61 | + steps: |
| 62 | + - run: |
| 63 | + name: Verify codebase |
| 64 | + command: | |
| 65 | + cd MapboxSearch |
| 66 | + ./gradlew :sdk:lint |
| 67 | + ./gradlew :ui:lint |
| 68 | + ./gradlew :sdk-common:lint |
| 69 | + ./gradlew :sample:lint |
| 70 | + ./gradlew :sdk:ktlint |
| 71 | + ./gradlew :ui:ktlint |
| 72 | + ./gradlew :sdk-common:ktlint |
| 73 | + ./gradlew :sample:ktlint |
| 74 | + ./gradlew detektAll |
| 75 | +
|
| 76 | + check-license: |
| 77 | + steps: |
| 78 | + - run: |
| 79 | + name: Check license |
| 80 | + command: python scripts/license-validate.py |
| 81 | + |
| 82 | + check-public-api: |
| 83 | + steps: |
| 84 | + - run: |
| 85 | + name: Check public API |
| 86 | + command: cd MapboxSearch && bash ../scripts/public-api.sh --check |
| 87 | + |
| 88 | + check-public-documentation: |
| 89 | + steps: |
| 90 | + - run: |
| 91 | + name: Check public documentation |
| 92 | + command: cd MapboxSearch && bash ../scripts/validate-kdocs.sh |
| 93 | + |
| 94 | + clean-build: |
| 95 | + steps: |
| 96 | + - run: |
| 97 | + name: Clean build |
| 98 | + command: cd MapboxSearch && ./gradlew clean |
| 99 | + |
| 100 | + assemble-sample-debug: |
| 101 | + steps: |
| 102 | + - run: |
| 103 | + name: Assemble sample (debug) |
| 104 | + no_output_timeout: 30m |
| 105 | + command: | |
| 106 | + cd MapboxSearch |
| 107 | + ./gradlew :sample:assembleDebug -Pcoverage |
| 108 | + ./gradlew :sample:assembleDebugAndroidTest -Pcoverage |
| 109 | +
|
| 110 | + assemble-sample-release: |
| 111 | + steps: |
| 112 | + - run: |
| 113 | + name: Assemble sample (release) |
| 114 | + no_output_timeout: 30m |
| 115 | + command: | |
| 116 | + cd MapboxSearch |
| 117 | + ./gradlew :sample:assembleRelease |
| 118 | +
|
| 119 | + codebase-unit-tests: |
| 120 | + steps: |
| 121 | + - run: |
| 122 | + name: Codebase unit tests |
| 123 | + command: | |
| 124 | + cd MapboxSearch |
| 125 | + ./gradlew :sdk:testDebugUnitTest -Pcoverage |
| 126 | + ./gradlew :ui:testDebugUnitTest -Pcoverage |
| 127 | + ./gradlew :sdk-common:testDebugUnitTest -Pcoverage |
| 128 | +
|
| 129 | + store-results: |
| 130 | + parameters: |
| 131 | + module_target: |
| 132 | + description: module target |
| 133 | + type: string |
| 134 | + steps: |
| 135 | + - store_test_results: |
| 136 | + path: MapboxSearch/<< parameters.module_target >>/build/test-results |
| 137 | + |
| 138 | + run-firebase-sample-robo: |
| 139 | + steps: |
| 140 | + - run: |
| 141 | + name: Run robo tests on Firebase |
| 142 | + no_output_timeout: 10m |
| 143 | + command: | |
| 144 | + gcloud firebase test android run \ |
| 145 | + --type robo --app MapboxSearch/sample/build/outputs/apk/release/sample-release.apk \ |
| 146 | + --device model=Pixel2,version=30,locale=en,orientation=portrait \ |
| 147 | + --device model=Nexus6,version=21,locale=en,orientation=portrait \ |
| 148 | + --timeout 120s \ |
| 149 | + --project mapbox-search-android |
| 150 | +
|
| 151 | + run-firebase-sample-instrumentation: |
| 152 | + steps: |
| 153 | + - run: |
| 154 | + name: Run instrumentation tests for sample app on Firebase |
| 155 | + no_output_timeout: 10m |
| 156 | + command: | |
| 157 | + gcloud firebase test android run \ |
| 158 | + --type instrumentation --app MapboxSearch/sample/build/outputs/apk/debug/sample-debug.apk --test MapboxSearch/sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk \ |
| 159 | + --device model=Pixel2,version=30,locale=en,orientation=portrait \ |
| 160 | + --device model=Nexus6,version=21,locale=en,orientation=portrait \ |
| 161 | + --timeout 600s \ |
| 162 | + --project mapbox-search-android |
| 163 | +
|
| 164 | + run-firebase-sdk-instrumentation: |
| 165 | + steps: |
| 166 | + - run: |
| 167 | + name: Run instrumentation tests for SDK module on Firebase |
| 168 | + no_output_timeout: 10m |
| 169 | + command: | |
| 170 | + cd MapboxSearch |
| 171 | + ./gradlew :sdk:assembleDebugAndroidTest -Pcoverage |
| 172 | + gcloud firebase test android run \ |
| 173 | + --type instrumentation --app sample/build/outputs/apk/debug/sample-debug.apk --test sdk/build/outputs/apk/androidTest/debug/mapbox-search-android-debug-androidTest.apk --environment-variables coverage=true,coverageFile=/sdcard/coverage.ec --directories-to-pull /sdcard --results-dir=$CIRCLE_BUILD_NUM \ |
| 174 | + --device model=Pixel2,version=30,locale=en,orientation=portrait \ |
| 175 | + --device model=Nexus6,version=21,locale=en,orientation=portrait \ |
| 176 | + --timeout 300s \ |
| 177 | + --project mapbox-search-android |
| 178 | +
|
| 179 | +#------------------------------- |
| 180 | +#---------- EXECUTORS ---------- |
| 181 | +#------------------------------- |
| 182 | +executors: |
| 183 | + ndk-r21e-executor: |
| 184 | + docker: |
| 185 | + - image: mbgl/android-ndk-r21e:86bcba4d3f |
| 186 | + working_directory: ~/code |
| 187 | + environment: |
| 188 | + MBX_CI_DOMAIN: o619qyc20d.execute-api.us-east-1.amazonaws.com |
| 189 | + |
| 190 | + |
| 191 | +#-------------------------- |
| 192 | +#---------- JOBS ---------- |
| 193 | +#-------------------------- |
| 194 | +jobs: |
| 195 | + prepare-and-assemble: |
| 196 | + executor: ndk-r21e-executor |
| 197 | + steps: |
| 198 | + - checkout |
| 199 | + - set-up-aws-for-android |
| 200 | + - restore-gradle-cache |
| 201 | + - clean-build |
| 202 | + - assemble-sample-debug |
| 203 | + - assemble-sample-release |
| 204 | + - write-workspace |
| 205 | + |
| 206 | + static-analysis: |
| 207 | + executor: ndk-r21e-executor |
| 208 | + steps: |
| 209 | + - read-workspace |
| 210 | + - check-license |
| 211 | + - verify-codebase |
| 212 | + - check-public-api |
| 213 | + - check-public-documentation |
| 214 | + |
| 215 | + pitest-validate: |
| 216 | + executor: ndk-r21e-executor |
| 217 | + steps: |
| 218 | + - read-workspace |
| 219 | + - run: |
| 220 | + name: Validate pitest set up |
| 221 | + command: cd MapboxSearch && bash ../scripts/quick_pitest_check.sh |
| 222 | + |
| 223 | + unit-tests: |
| 224 | + executor: ndk-r21e-executor |
| 225 | + steps: |
| 226 | + - read-workspace |
| 227 | + - codebase-unit-tests |
| 228 | + - store-results: |
| 229 | + module_target: "sdk" |
| 230 | + - store-results: |
| 231 | + module_target: "ui" |
| 232 | + - run: |
| 233 | + name: Calculate coverage |
| 234 | + command: cd MapboxSearch && ./gradlew :sdk:testDebugUnitTestCoverage |
| 235 | + - run: |
| 236 | + name: Post code coverage reports to Codecov.io |
| 237 | + command: bash ./scripts/codecov.sh ./MapboxSearch/sdk/build/reports/jacoco/testDebugUnitTestCoverage/testDebugUnitTestCoverage.xml |
| 238 | + - write-workspace |
| 239 | + |
| 240 | + instrumentation-tests: |
| 241 | + executor: ndk-r21e-executor |
| 242 | + steps: |
| 243 | + - checkout |
| 244 | + - set-up-aws-for-android |
| 245 | + - restore-gradle-cache |
| 246 | + - login-google-cloud-platform |
| 247 | + - clean-build |
| 248 | + - assemble-sample-debug |
| 249 | + - run-firebase-sdk-instrumentation |
| 250 | + |
| 251 | + ui-robo-tests: |
| 252 | + executor: ndk-r21e-executor |
| 253 | + steps: |
| 254 | + - read-workspace |
| 255 | + - login-google-cloud-platform |
| 256 | + - run-firebase-sample-robo |
| 257 | + |
| 258 | + ui-instrumentation-tests: |
| 259 | + executor: ndk-r21e-executor |
| 260 | + steps: |
| 261 | + - read-workspace |
| 262 | + - login-google-cloud-platform |
| 263 | + - run-firebase-sample-instrumentation |
| 264 | + |
| 265 | + publish-snapshots: |
| 266 | + executor: ndk-r21e-executor |
| 267 | + steps: |
| 268 | + - checkout |
| 269 | + - set-up-aws-for-android |
| 270 | + - restore-gradle-cache |
| 271 | + - run: |
| 272 | + name: Publish snapshots |
| 273 | + command: bash ./scripts/ci-publish-snapshots.sh |
| 274 | + |
| 275 | + publish-release: |
| 276 | + executor: ndk-r21e-executor |
| 277 | + steps: |
| 278 | + - checkout |
| 279 | + - set-up-aws-for-android |
| 280 | + - restore-gradle-cache |
| 281 | + - run: |
| 282 | + name: Publish release |
| 283 | + command: bash ./scripts/ci-publish-release.sh |
| 284 | + - run: |
| 285 | + name: Create PR in the SDK registry repository |
| 286 | + command: bash ./scripts/ci-create-registry-pr.sh |
| 287 | + - run: |
| 288 | + name: Publish API reference |
| 289 | + command: bash ./scripts/ci-publish-api-reference.sh |
| 290 | + |
| 291 | + |
| 292 | +#------------------------------- |
| 293 | +#---------- WORKFLOWS ---------- |
| 294 | +#------------------------------- |
| 295 | +workflows: |
| 296 | + version: 2 |
| 297 | + release-workflow: |
| 298 | + jobs: |
| 299 | + - publish-snapshots: |
| 300 | + filters: |
| 301 | + branches: |
| 302 | + only: |
| 303 | + - develop |
| 304 | + - publish-release: |
| 305 | + filters: |
| 306 | + tags: |
| 307 | + only: /^v.*/ |
| 308 | + branches: |
| 309 | + ignore: /.*/ |
| 310 | + |
| 311 | + nightly-build: |
| 312 | + jobs: |
| 313 | + - prepare-and-assemble |
| 314 | + - instrumentation-tests |
| 315 | + - static-analysis: |
| 316 | + requires: |
| 317 | + - prepare-and-assemble |
| 318 | + - unit-tests: |
| 319 | + requires: |
| 320 | + - prepare-and-assemble |
| 321 | + - ui-robo-tests: |
| 322 | + requires: |
| 323 | + - prepare-and-assemble |
| 324 | + - ui-instrumentation-tests: |
| 325 | + requires: |
| 326 | + - prepare-and-assemble |
| 327 | + - pitest-validate: |
| 328 | + requires: |
| 329 | + - unit-tests |
| 330 | + triggers: |
| 331 | + - schedule: |
| 332 | + cron: "0 0 * * *" |
| 333 | + filters: |
| 334 | + branches: |
| 335 | + only: |
| 336 | + - develop |
| 337 | + - main |
| 338 | + |
| 339 | + default: |
| 340 | + jobs: |
| 341 | + - prepare-and-assemble |
| 342 | + - instrumentation-tests |
| 343 | + - static-analysis: |
| 344 | + requires: |
| 345 | + - prepare-and-assemble |
| 346 | + - unit-tests: |
| 347 | + requires: |
| 348 | + - prepare-and-assemble |
| 349 | + - ui-robo-tests: |
| 350 | + requires: |
| 351 | + - prepare-and-assemble |
| 352 | + - ui-instrumentation-tests: |
| 353 | + requires: |
| 354 | + - prepare-and-assemble |
| 355 | + - pitest-validate: |
| 356 | + requires: |
| 357 | + - unit-tests |
0 commit comments