Skip to content

Instantly share code, notes, and snippets.

@shalzz
Forked from lordcodes/ci-setup.sh
Created October 31, 2019 06:31
Show Gist options
  • Save shalzz/4fe6044ad67e1a9a4318383c457a85ae to your computer and use it in GitHub Desktop.
Save shalzz/4fe6044ad67e1a9a4318383c457a85ae to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment