Skip to content

Instantly share code, notes, and snippets.

@TheDancerCodes
Created January 28, 2020 08:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheDancerCodes/4d1847faa7282e28af7d87ee0e5a0bc5 to your computer and use it in GitHub Desktop.
Save TheDancerCodes/4d1847faa7282e28af7d87ee0e5a0bc5 to your computer and use it in GitHub Desktop.
This is the final Circle CI config file.
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
version: 2
# References are blocks of configurations that we can reference and reuse.
references:
# Workspaces represent the spaces we work on & are useful for sharing data between jobs.
# Create a workspace with the ~/code directory.
workspace: &workspace
~/code
# Docker Image Configs
android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-28-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx3200m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx3200m"'
# Cache - a cache mechanism for our dependencies
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:
paths:
- ~/.gradle
- ~/.m2
key: *gradle_key
save_gems_cache: &save_gems_cache
save_cache:
paths:
- vendor/bundle
key: *gems_key
# Dependencies
ruby_dependencies: &ruby_dependencies
run:
name: Download Ruby Dependencies
command: |
gem install bundler
bundle check || bundle update || bundle install --path vendor/bundle
android_dependencies: &android_dependencies
run:
name: Download Android Dependencies
command: ./gradlew androidDependencies
# Keys
decode_android_key: &decode_android_key
run:
name: Decode Android Keystore
command: echo $KEYSTORE_PATH | base64 -d | tee keystore.jks app/keystore.jks >/dev/null
# ---------------------------------------------------------------------------------------------------------------------
# DECODE FIREBASE GOOGLE_SERVICE_JSON FILE AND WRITE IT TO A FILE
# ---------------------------------------------------------------------------------------------------------------------
decode_gservices_key: &decode_gservices_key
run:
name: Decode Google Services JSON key
command: |
echo
| base64 -d | tee app/google-services.json app/src/mock/google-services.json app/src/prod/google-services.json >/dev/null
# ---------------------------------------------------------------------------------------------------------------------
# INSTALL THE FIREBASE CLI FILE & ENABLE THE GLOBALLY AVAILABLE firebase COMMAND
# ---------------------------------------------------------------------------------------------------------------------
firebase_cli_install: &firebase_cli_install
run:
name: Install the Firebase CLI
command: |
curl -sL firebase.tools | bash
jobs:
## Run unit tests
test_unit:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *android_dependencies
- *ruby_dependencies
- *save_gradle_cache
- *save_gems_cache
- *decode_gservices_key
- 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/
slack_deployment:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *android_dependencies
- *ruby_dependencies
- *save_gradle_cache
- *save_gems_cache
- *decode_android_key
- run:
name: Upload APK to Slack Channel
command: bundle exec fastlane slack_apk_build
firebase_app_distribution:
<<: *android_config
steps:
- checkout
- *restore_gradle_cache
- *restore_gems_cache
- *android_dependencies
- *ruby_dependencies
- *save_gradle_cache
- *save_gems_cache
- *decode_android_key
- *firebase_cli_install
- run:
name: Deploy latest Beta build to Firebase App Distribution
command: bundle exec fastlane distribute group:android-qa
workflows:
version: 2
workflow:
# Jobs that will run when you push to your repo
jobs:
- test_unit
- slack_deployment:
requires:
- test_unit
- firebase_app_distribution:
requires:
- test_unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment