-
-
Save ahmedeltaher/88af5833aa33c64e973c78392470aa2f to your computer and use it in GitHub Desktop.
Config for gitlab ci android with unit tests and instrumented tests
This file contains 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:8-jdk | |
variables: | |
ANDROID_COMPILE_SDK: "28" | |
ANDROID_BUILD_TOOLS: "28.0.3" | |
SDK_TOOLS: "4333796" # from https://developer.android.com/studio/#command-tools | |
EMULATOR_VERSION: "22" # Unable to install with newer emulator versions. Don`t know why. | |
before_script: | |
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${SDK_TOOLS}.zip | |
- unzip -q android-sdk.zip -d android-sdk-linux | |
- mkdir android-sdk-linux/licenses | |
- printf "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > android-sdk-linux/licenses/android-sdk-license | |
- printf "84831b9409646a918e30573bab4c9c91346d8abd" > android-sdk-linux/licenses/android-sdk-preview-license | |
- android-sdk-linux/tools/bin/sdkmanager --update > update.log | |
- android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log | |
- export ANDROID_HOME=$PWD/android-sdk-linux | |
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ | |
- chmod +x ./gradlew | |
stages: | |
- build | |
- test | |
build: | |
stage: build | |
script: | |
- ./gradlew assembleDebug | |
artifacts: | |
paths: | |
- app/build/outputs/ | |
unitTests: | |
stage: test | |
script: | |
- ./gradlew test | |
instrumentedTests: | |
stage: test | |
script: | |
- 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