blob: c4f16f417efab3351453362e632eabd270c13ced [file] [log] [blame]
version: 2.1
job_config: &job_config
working_directory: ~/code
docker:
- image: circleci/openjdk:11.0.6-jdk-stretch
resource_class: xlarge
environment:
GRADLE_MAX_PARALLEL_FORKS: 2
ANDROID_HOME: /home/circleci/Android
commands:
run_tests_for_sdks:
description: "Run tests for specific SDK versions"
parameters:
codenames:
type: string
versions:
type: string
steps:
- run:
name: Test << parameters.versions >> (<< parameters.codenames >>)
command: |
GRADLE_MAX_PARALLEL_FORKS=2 \
SKIP_JAVADOC=true \
./gradlew test --info --stacktrace --continue \
--parallel \
-Drobolectric.enabledSdks=<< parameters.versions >> \
-Drobolectric.alwaysIncludeVariantMarkersInTestName=true \
-Dorg.gradle.workers.max=2
- run:
name: Collect Test Results
command: |
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
jobs:
check_java_formatting:
<< : *job_config
steps:
- checkout
- run:
name: Download google-java-format 1.9
command: |
curl -L -o $HOME/google-java-format.jar https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar
curl -L -o $HOME/google-java-format-diff.py https://raw.githubusercontent.com/google/google-java-format/google-java-format-1.9/scripts/google-java-format-diff.py
chmod +x $HOME/google-java-format-diff.py
- run:
name: Check Java formatting
command: |
diff=$(git diff -U0 $(git merge-base HEAD origin/master) | $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1)
if [[ $diff ]]; then
echo "Please run google-java-format on the changes in this pull request"
git diff -U0 $(git merge-base HEAD origin/master) | $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1
exit 1
fi
build:
<< : *job_config
steps:
- checkout
- run:
name: Calculate Cache Hash
command: |
find . \( -name \*.gradle -or -name \*.groovy -or -name \*.sh -or -name \*.rb -or -name circle.yml \) -exec shasum {} \; | sort > .cache-hash
cat .cache-hash
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run:
name: Download Dependencies
command: |
curl --output ~/commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
mkdir -p ~/Android/cmdline-tools && (cd ~/Android/cmdline-tools && unzip -o ~/commandlinetools.zip)
yes | $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --licenses || true
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install 'platforms;android-29' > /dev/null
./gradlew --parallel prefetchDependencies
- save_cache:
paths:
- ~/.gradle
- ~/.m2
- ~/Android
key: cache-{{ checksum ".cache-hash" }}
- run:
name: Build
command: SKIP_JAVADOC=true ./gradlew clean assemble testClasses --parallel --stacktrace
- persist_to_workspace:
root: ~/code
paths:
- ".cache-hash"
- "[a-zA-Z]*" # not .git
test_16_17_18:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run_tests_for_sdks:
codenames: JELLY_BEAN
versions: 16,17,18
- store_test_results:
path: ~/junit
- store_artifacts:
path: build/reports
destination: reports
test_19_21_22:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run_tests_for_sdks:
codenames: KITKAT/LOLLIPOP
versions: 19,21,22
- store_test_results:
path: ~/junit
- store_artifacts:
path: build/reports
destination: reports
test_23_24_25:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run_tests_for_sdks:
codenames: M/N
versions: 23,24,25
- store_test_results:
path: ~/junit
- store_artifacts:
path: build/reports
destination: reports
test_26_27_28:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run_tests_for_sdks:
codenames: O/P
versions: 26,27,28
- store_test_results:
path: ~/junit
- store_artifacts:
path: build/reports
destination: reports
test_29_30:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run_tests_for_sdks:
codenames: Q/R
versions: 29,30
- store_test_results:
path: ~/junit
- store_artifacts:
path: build/reports
destination: reports
finish:
<< : *job_config
steps:
- attach_workspace:
at: ~/code
- restore_cache:
key: cache-{{ checksum ".cache-hash" }}
- run:
name: Publish Snapshot
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./gradlew publish --no-rebuild
fi
workflows:
version: 2
build-and-test:
jobs:
- build
- test_16_17_18:
requires:
- build
- test_19_21_22:
requires:
- build
- test_23_24_25:
requires:
- build
- test_26_27_28:
requires:
- build
- test_29_30:
requires:
- build
- finish:
requires:
- test_16_17_18
- test_19_21_22
- test_23_24_25
- test_26_27_28
- test_29_30
check-formatting:
jobs:
- check_java_formatting