@@ -2,6 +2,7 @@ version: 2.1
22
33orbs :
445+ android :
circleci/[email protected] 56
67workflows :
78 test :
4344 - run : java -version
4445 - run : ./gradlew dependencies
4546 - run : ./gradlew jar
47+ - run : ./gradlew javadoc
4648 - run : ./gradlew checkstyleMain
4749 - persist_to_workspace :
4850 root : build
@@ -121,49 +123,31 @@ jobs:
121123 path : .\junit
122124
123125 build-test-android :
124- # This is adapted from the CI build for android-client-sdk
125- macos :
126- xcode : " 10.3.0"
127- shell : /bin/bash --login -eo pipefail
128- working_directory : ~/launchdarkly/android-client-sdk-private
129- environment :
130- TERM : dumb
131- QEMU_AUDIO_DRV : none
132- _JAVA_OPTIONS : " -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xms2048m -Xmx4096m"
133- GRADLE_OPTS : " -Dorg.gradle.daemon=false"
134- JVM_OPTS : -Xmx3200m
135- ANDROID_HOME : " /usr/local/share/android-sdk"
136- ANDROID_SDK_HOME : " /usr/local/share/android-sdk"
137- ANDROID_SDK_ROOT : " /usr/local/share/android-sdk"
126+ executor :
127+ name : android/android-machine
128+ resource-class : large
129+
138130 steps :
139131 - checkout
132+
133+ # What we want to do here is somewhat unusual: we want Android to run all of our tests from
134+ # src/test/java, but run them in the Android emulator (to prove that we're only using Java
135+ # APIs that our minimum Android API version supports). Normally, only tests in
136+ # src/androidTest/java would be run that way. Also, Android needs a different JUnit test
137+ # runner annotation on all of the test classes. So we can't just run the test code as-is.
138+ #
139+ # This step copies all the code from src/test/java into src/androidTest/java, except for the
140+ # base class BaseTest.java, which is already defined in src/androidTest/java to provide the
141+ # necessary test runner annotation.
140142 - run :
141- name : Install Android tools
142- command : ./scripts/install-android-tools.sh
143- - run :
144- name : Start Android environment
145- command : ./scripts/start-android-env.sh
146- background : true
147- timeout : 1200
148- no_output_timeout : 20m
149- - run :
150- name : Wait for Android environment
151- command : ./scripts/started-android-env.sh
152- - run :
153- name : Run tests
154- command : ./scripts/run-android-tests.sh
155- no_output_timeout : 20m
156- - run :
157- name : Save test results
158- command : |
159- mkdir -p ~/test-results
160- cp -r ./build/outputs/androidTest-results/* ~/test-results/
161- when : always
162- - run :
163- name : Stop Android environment
164- command : ./scripts/stop-android-env.sh
165- when : always
143+ name : Copy tests
144+ command : rsync -r ./src/test/java/ ./src/androidTest/java/ --exclude='BaseTest.java'
145+
146+ - android/start-emulator-and-run-tests :
147+ system-image : system-images;android-21;default;x86
148+ max-tries : 1
149+ post-emulator-launch-assemble-command : ./gradlew -b build-android.gradle :assembleAndroidTest
150+ test-command : ./gradlew -b build-android.gradle :connectedAndroidTest
151+
166152 - store_test_results :
167- path : ~/test-results
168- - store_artifacts :
169- path : ~/artifacts
153+ path : ./build/outputs/androidTest-results
0 commit comments