-
-
Save CypherpunkSamurai/cf64601487d653d387d47171f360bce5 to your computer and use it in GitHub Desktop.
Config for gitlab ci android with unit tests and instrumented tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| image: openjdk:11-jdk | |
| variables: | |
| ANDROID_COMPILE_SDK: "30" | |
| ANDROID_BUILD_TOOLS: "30.0.3" | |
| SDK_TOOLS: "6858069" # from https://developer.android.com/studio/#command-tools | |
| EMULATOR_VERSION: "24" | |
| before_script: | |
| - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${SDK_TOOLS}_latest.zip | |
| - unzip -q android-sdk.zip -d android-sdk-linux | |
| - rm android-sdk.zip | |
| - export ANDROID_HOME=$PWD/android-sdk-linux | |
| - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ | |
| - android-sdk-linux/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --update > update.log | |
| - echo y | android-sdk-linux/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log | |
| - chmod +x ./gradlew | |
| stages: | |
| - test | |
| unitTests: | |
| stage: test | |
| script: | |
| - ./gradlew test | |
| instrumentedTests: | |
| stage: test | |
| script: | |
| - apt-get --quiet update --yes | |
| - apt-get --quiet install --yes libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2 | |
| - wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator | |
| - chmod +x android-wait-for-emulator | |
| - android-sdk-linux/tools/bin/sdkmanager --update > update.log | |
| - android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a" > installEmulator.log | |
| - echo no | android-sdk-linux/tools/bin/avdmanager create avd -n test -k "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a" | |
| - android-sdk-linux/emulator/emulator -avd test -no-window -no-audio & | |
| - ./android-wait-for-emulator | |
| - adb shell input keyevent 82 | |
| - ./gradlew connectedCheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment