Last active
April 26, 2018 14:54
-
-
Save danielgomezrico/e7e0983208883e65c928b2572dc7d929 to your computer and use it in GitHub Desktop.
Gitlab - Local Gitlab Runner for Android (setup your computer with real usb attached devices)
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
stages: | |
- build | |
- test | |
cache: | |
key: ${CI_PROJECT_ID} | |
paths: | |
- .gradle/ | |
before_script: | |
- sh scripts/cp-env-to-properties.sh | |
- sh scripts/adb-all.sh uninstall com.your.app.package # to avoid INSTALL_FAILED_UPDATE_INCOMPATIBLE | |
build: | |
type: build | |
script: | |
- sh scripts/install-android-dependencies.sh | |
- ./gradlew assemble --stacktrace | |
unit_tests: | |
type: test | |
script: | |
- ./gradlew test --stacktrace | |
artifacts: | |
paths: | |
- app/build/outputs/ | |
ui_tests: | |
type: test | |
script: | |
# Wake up screen | |
- sh scripts/adb-all.sh shell input keyevent 26 # KEYCODE_POWER | |
- sh scripts/adb-all.sh shell input keyevent 3 # HOME | |
# run your UI tests tasks, in my case I use spoon everywhere | |
- ./gradlew spoonDebugAndroidTest --stacktrace || true # allow to get artficat on failure | |
artifacts: | |
paths: | |
- app/build/outputs/ | |
- app/build/spoon/ |
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
#!/usr/bin/env bash | |
# | |
# Run any adb command on all the connected devices to avoid: | |
# "error: more than one device and emulator" | |
# | |
adb devices | while read line | |
do | |
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ] | |
then | |
device=`echo $line | awk '{print $1}'` | |
echo "$device $@ ..." | |
adb -s $device $@ | |
fi | |
done |
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
#!/usr/bin/env bash | |
# | |
# Copy env variables to app module gradle properties file | |
# | |
PROPERTIES_FILE_PATH=gradle.properties | |
set +x // dont print the next lines on run script | |
printenv | tr ' ' '\n' > $PROPERTIES_FILE_PATH | |
set -x |
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
#!/usr/bin/env bash | |
# | |
# Install required dependencies | |
# sdkmanager can be found in $ANDROID_HOME/tools/bin/sdkmanager | |
# | |
for I in "platforms;android-25" \ | |
"platforms;android-23" \ | |
"platforms;android-21" \ | |
"build-tools;25.0.3" \ | |
"build-tools;25.0.2" \ | |
"extras;google;m2repository" \ | |
"extras;android;m2repository" \ | |
"extras;google;google_play_services"; do | |
echo "Trying to update with tools/bin/sdkmanager: " $I | |
echo y | sdkmanager $I | |
done | |
sdkmanager --update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment