Created
January 3, 2019 13:45
-
-
Save tranductam2802/c0f4f1e38d74ba02d482c625e44e076f to your computer and use it in GitHub Desktop.
Config GitLab CI - demo for Android
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
# Newest JDK | |
image: openjdk:8-jdk | |
variables: | |
RUNNER_HOME: "/home/gitlab-runner" | |
ANDROID_HOME: "${RUNNER_HOME}/android-sdk-linux" | |
# Android target SDK configured on build.gradle | |
ANDROID_TARGET_SDK: "25" | |
# Android compile SDK configured on build.gradle | |
ANDROID_COMPILE_SDK: "25" | |
# Android build tool configured on build.gradle | |
ANDROID_BUILD_TOOLS: "25.0.2" | |
# Newest SDK now | |
ANDROID_SDK_TOOLS: "24.4.1" | |
# Make the gradle wrapper executable. This essentially downloads a copy of Gradle to build the project with | |
before_script: | |
# Update newest library (Remove ## for the first-times setup) | |
##- sudo apt-get --quiet update --yes | |
##- sudo apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 | |
##- wget --quiet --output-document=${RUNNER_HOME}/android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz | |
##- tar --extract --gzip --file=${RUNNER_HOME}/android-sdk.tgz --directory=${RUNNER_HOME} | |
# Create licenses accept for all dependencies (Remove ## for the first-times setup) | |
##- mkdir ${ANDROID_HOME}/licenses | |
##- echo 8933bad161af4178b1185d1a37fbf41ea5269c55 > ${ANDROID_HOME}/licenses/android-sdk-license | |
##- echo 84831b9409646a918e30573bab4c9c91346d8abd > ${ANDROID_HOME}/licenses/android-sdk-preview-license | |
# Update Android SDK (Remove ## for the first-times setup) | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t android-${ANDROID_TARGET_SDK} | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t android-${ANDROID_COMPILE_SDK} | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t build-tools-${ANDROID_BUILD_TOOLS} | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t tools | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t platform-tools | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t extra-m2repository | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t extra-android-support | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t extra-android-m2repository | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t extra-google-google_play_services | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t extra-google-m2repository | |
# Clear cache first | |
- sudo rm -rf ${RUNNER_HOME}/.gradlew | |
# Export ANDROID_HOME | |
- export ANDROID_HOME=${ANDROID_HOME} | |
- export PATH=$PATH:${ANDROID_HOME}/platform-tools/ | |
- chmod +x ./gradlew | |
# Define list support states | |
stages: | |
- build | |
- test | |
# Generated build output | |
build: | |
stage: build | |
script: | |
- ./gradlew assemble --stacktrace | |
artifacts: | |
paths: | |
- app/build/outputs/ | |
allow_failure: false | |
# Use the generated build output to run the unit tests | |
unitTests: | |
stage: test | |
script: | |
- ./gradlew test | |
# Use the generated build output to run the functional tests | |
functionalTests: | |
stage: test | |
script: | |
# Create emulater folder (Remove ## for the first-times setup) | |
##- 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 | |
# Download image emulator (Remove ## for the first-times setup) | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t sys-img-x86_64-google_apis-${ANDROID_COMPILE_SDK} | |
##- ${ANDROID_HOME}/tools/android -v update sdk -s -u -a -t sys-img-arm64-v8a-google_apis-${ANDROID_COMPILE_SDK} | |
- echo no | ${ANDROID_HOME}/tools/android create avd -n test -t android-${ANDROID_COMPILE_SDK} --abi google_apis/x86_64 | |
# Config emulator (Remove ## for the first-times setup) | |
- ${ANDROID_HOME}/tools/emulator64-x86 -avd test -no-window -no-audio & | |
# Waiting for | |
- ./android-wait-for-emulator | |
- adb shell input keyevent 82 | |
- ./gradlew cAT | |
artifacts: | |
paths: | |
- app/build/reports/androidTests/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment