Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Circle CI config involving workflows, caching and sharing the workspace between steps in workflow.
#!/usr/bin/env bash
# Accept licenses
${ANDROID_HOME}/tools/bin/sdkmanager --licenses
# Install dependencies
./gradlew androidDependencies || true
version: 2.0
references:
workspace_root: &workspace_root
~/workspace
container_config: &container_config
docker:
- image: circleci/android:api-28
working_directory: *workspace_root
environment:
TERM: dumb
JVM_OPTS: -Xmx4096m
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root
general_cache_key: &general_cache_key
key: app-{{ checksum "build.gradle.kts" }}-{{ checksum "app/build.gradle.kts" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "gradle.properties" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
jobs:
build:
<<: *container_config
steps:
- checkout
- restore_cache:
<<: *general_cache_key
- run:
name: Setup environment
command: scripts/ci-setup.sh
- save_cache:
<<: *general_cache_key
paths:
- "~/.gradle"
- "~/.m2"
- "/opt/android-sdk-linux/licenses/"
- run:
name: Build
command: ./gradlew assembleDebug
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/
- persist_to_workspace:
root: *workspace_root
paths:
- .
check:
<<: *container_config
steps:
- *attach_workspace
- restore_cache:
<<: *general_cache_key
- run:
name: Run checks
command: ./gradlew lintDebug ktlintCheck
- store_artifacts:
path: app/build/reports/
destination: lint_reports/app/
test:
<<: *container_config
steps:
- *attach_workspace
- restore_cache:
<<: *general_cache_key
- run:
name: Run tests
command: ./gradlew testDebugUnitTest
- store_artifacts:
path: app/build/reports/tests/
destination: tests_reports/
- store_test_results:
path: app/build/test-results
workflows:
version: 2
build_check_tests:
jobs:
- build
- check:
requires:
- build
- test:
requires:
- build
@Bhavnaharitsa

This comment has been minimized.

Copy link

Bhavnaharitsa commented Mar 17, 2019

Should the circle ci directory have 2 files
one - config.yml
two-ci-setup.sh ?
Kindly reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.