Skip to content

Instantly share code, notes, and snippets.

@bffcorreia
Last active February 16, 2020 07:46
Show Gist options
  • Save bffcorreia/62f7b3f0bfad78c5d7fd66e2b3db0ce9 to your computer and use it in GitHub Desktop.
Save bffcorreia/62f7b3f0bfad78c5d7fd66e2b3db0ce9 to your computer and use it in GitHub Desktop.
version: 2
references:
## Workspaces
workspace: &workspace
~/src
## Docker image configurations
android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-27-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
## Cache
gradle_key: &gradle_key
jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
gems_key: &gems_key
gems-{{ checksum "Gemfile.lock" }}
restore_gradle_cache: &restore_gradle_cache
restore_cache:
key: *gradle_key
restore_gems_cache: &restore_gems_cache
restore_cache:
key: *gems_key
save_gradle_cache: &save_gradle_cache
save_cache:
key: *gradle_key
paths:
- ~/.gradle
- ~/.m2
save_gems_cache: &save_gems_cache
save_cache:
key: *gems_key
paths:
- vendor/bundle
## Dependencies
ruby_dependencies: &ruby_dependencies
run:
name: Download Ruby Dependencies
command: bundle check || bundle install --path vendor/bundle
android_dependencies: &android_dependencies
run:
name: Download Android Dependencies
command: ./gradlew androidDependencies
jobs:
## Run unit tests
test_unit:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *ruby_dependencies
- *android_dependencies
- *save_gradle_cache
- *save_gems_cache
- run:
name: Run unit tests
command: bundle exec fastlane unit_tests
- store_artifacts:
path: app/build/reports/
destination: /reports/
- store_test_results:
path: app/build/test-results/
destination: /test-results/
## Run instrumentation tests
test_instrumentation:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *ruby_dependencies
- *android_dependencies
- *save_gradle_cache
- *save_gems_cache
# Since we will download a video, we require integrity checking with CRC32c
# But the crcmod installation in the docker image isn't using the module's C extension
# So, uninstall it and install again with the C extension
- run:
name: Uninstall crcmod
command: echo "y" | sudo pip uninstall crcmod
- run:
name: Install crcmod
command: sudo pip install -U crcmod
- run:
name: Run instrumentation tests in Firebase testlab
command: bundle exec fastlane instrumentation_tests_testlab
- store_artifacts:
path: firebase/
destination: /firebase/
## Deploy to Crashlytics Beta
deploy_crashlytics:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *ruby_dependencies
- *android_dependencies
- *save_gradle_cache
- *save_gems_cache
- run:
name: Deploy to Crashlytics Beta
command: bundle exec fastlane deploy_to_crashlytics
## Deploy to Play Store
deploy_play_store:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *ruby_dependencies
- *android_dependencies
- *save_gradle_cache
- *save_gems_cache
- run:
name: Deploy to Play Store
command: bundle exec fastlane deploy_to_play_store
workflows:
version: 2
workflow:
jobs:
- test_unit
- test_instrumentation:
requires:
- test_unit
- deploy_crashlytics:
filters:
branches:
only:
- beta
requires:
- test_unit
- test_instrumentation
- deploy_play_store:
filters:
branches:
only:
- production
requires:
- test_unit
- test_instrumentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment