Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with circleCI 2 #17

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Building
--------
Build using gradle. Remember to `git submodule init` before.

Automatied Builds
------------------
**Travis:** [![Build Status](https://travis-ci.org/microg/NominatimGeocoderBackend.png?branch=master)](https://travis-ci.org/microg/NominatimGeocoderBackend)
**CircleCI:** [![CircleCI](https://circleci.com/gh/microg/NominatimGeocoderBackend/tree/master.png?style=badge)](https://circleci.com/gh/microg/NominatimGeocoderBackend)

The APK can be downloaded from CircleCI, [here](https://circleci.com/api/v1/project/microg/NominatimGeocoderBackend/latest/artifacts/0/$CIRCLE_ARTIFACTS/NominatimGeocoderBackend.apk?filter=successful&branch=master)

or via QR-Code
[![here](https://circleci.com/api/v1/project/microg/NominatimGeocoderBackend/latest/artifacts/0/$CIRCLE_ARTIFACTS/QR_apk.png?filter=successful&branch=master)](https://circleci.com/api/v1/project/microg/NominatimGeocoderBackend/latest/artifacts/0/$CIRCLE_ARTIFACTS/NominatimGeocoderBackend.apk?filter=successful&branch=master)

Used libraries
--------------
Expand Down
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ dependencies {
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
multiDexEnabled false
vectorDrawables.useSupportLibrary = true
}

aaptOptions {
additionalParameters "--no-version-vectors"
}

lintOptions {
abortOnError false
absolutePaths false
showAll true
textReport true
xmlReport true
htmlReport true
textOutput file("lint-report.txt")
htmlOutput file("lint-report.html")
xmlOutput file("lint-report.xml")
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

}

if (file('user.gradle').exists()) {
Expand Down
160 changes: 160 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
machine:
timezone:
Europe/Vienna
java:
version: oraclejdk8
environment:
ZEMU_: "appemu23"
EMU_: "appemu21"
XEMU_: "appemu10"
Zsdpath: "/sdcard"
sdpath: "/storage/sdcard"
Xsdpath: "/mnt/sdcard"
ANDROID_HOME: /usr/local/android-sdk-linux
ANDROID_SDK: /usr/local/android-sdk-linux/
_SDK_: /usr/local/android-sdk-linux/
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
JAVA_OPTS: "-Xms512m -Xmx1024m"
GRADLE_OPTS: '-Xmx512m -Dorg.gradle.jvmargs="-Xmx1700m -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=1700m"'
CLASS_P: org.microg.nlp.backend.nominatim
START_INTENT_P: .SettingsActivity
dependencies:
cache_directories:
- ~/.android
- ~/.gradle
override:
- echo "dummy"
pre:
- sudo apt-get update > /dev/null 2> /dev/null
- sudo apt-get install xvfb > /dev/null 2> /dev/null
- sudo apt-get install xdotool > /dev/null 2> /dev/null
- sudo apt-get install telnet > /dev/null 2> /dev/null
- sudo apt-get install x11-utils > /dev/null 2> /dev/null
- sudo apt-get install xvkbd > /dev/null 2> /dev/null
- sudo apt-get install qrencode > /dev/null 2> /dev/null

- gradle -v # display gradle version
- echo y | android update sdk --no-ui --all --filter "tools"
- android list sdk --all | grep -i tools
- android list sdk --all --extended

- echo y | android update sdk --no-ui --all --filter build-tools-25.0.1
- echo y | android update sdk --no-ui --all --filter build-tools-25.0.2
- echo y | android update sdk --no-ui --all --filter build-tools-24.0.0
- echo y | android update sdk --no-ui --all --filter build-tools-23.0.1
- echo y | android update sdk --no-ui --all --filter build-tools-23.0.2
- echo y | android update sdk --no-ui --all --filter build-tools-23.0.3
- echo y | android update sdk --no-ui --all --filter build-tools-22.0.0
- echo y | android update sdk --no-ui --all --filter android-21 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter android-22 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter android-23 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter android-24 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter android-25 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter platform-tools > /dev/null 2> /dev/null

- echo y | android update sdk --no-ui --all --filter extra-android-m2repository > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter extra-google-m2repository > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter extra-android-support > /dev/null 2> /dev/null

- echo y | android update sdk --no-ui --all --filter platform-tools-preview > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter sys-img-armeabi-v7a-android-23 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter sys-img-armeabi-v7a-addon-google_apis-google-23 > /dev/null 2> /dev/null
- echo y | android update sdk --no-ui --all --filter addon-google_apis-google-23 > /dev/null 2> /dev/null

- pwd ; ls -al

compile:
override:
- ./gradlew lint --info
- ./gradlew assembleRelease --stacktrace --info --no-daemon
- ls -al build/outputs/apk/ ; exit 0
- find . -name '*.apk' -exec ls -al {} \; ; exit 0
- find . -name '*lint-report*' -exec ls -al {} \; ; exit 0

# --- save lint output ---
- cp -av ./lint-report.html $CIRCLE_ARTIFACTS/ ; exit 0
- cp -av ./lint-report.xml $CIRCLE_ARTIFACTS/ ; exit 0
- cp -av ./lint-report.txt $CIRCLE_ARTIFACTS/ ; exit 0
# --- save lint output ---

# --- copy apk file to generic location ---
- mkdir -p ./app/build/outputs/apk/
- cp -av ./build/outputs/apk/NominatimGeocoderBackend-release-unsigned.apk app/build/outputs/apk/app-debug-unaligned.apk
# --- copy apk file to generic location ---

- zip -d app/build/outputs/apk/app-debug-unaligned.apk META-INF/\* # remove signature !!
- cp -av app/build/outputs/apk/app-debug-unaligned.apk ~/app.apk ;
cd ~/ ;
echo xxxxxxrm -f ~/.android/debug.keystore ;
ls -al ~/.android/debug.keystore ;
if [ ! -f ~/.android/debug.keystore ]; then echo "*** generating new signer key ***" ;
echo "*** generating new signer key ***";
echo "*** generating new signer key ***";
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -keyalg RSA -keysize 2048 -validity 10000 -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US" ;
fi ;
ls -al ~/ ;
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android -sigalg SHA1withRSA -digestalg SHA1 -sigfile CERT -signedjar app-signed.apk app.apk androiddebugkey ;
ls -al ~/ ;
$_SDK_/build-tools/23.0.3/zipalign -v 4 app-signed.apk app-signed-aligned.apk ;
ls -al ~/ ;
pwd ;
ls -al ;
cp -av app-signed-aligned.apk $CIRCLE_ARTIFACTS/${CIRCLE_PROJECT_REPONAME}.apk || exit 1

## also make apk files with different names for each build (for individual downloads)
- cp -av $CIRCLE_ARTIFACTS/${CIRCLE_PROJECT_REPONAME}.apk $CIRCLE_ARTIFACTS/${CIRCLE_PROJECT_REPONAME}_circleci_$CIRCLE_SHA1.apk ; exit 0
## qr code to scan with your phone to directly download the apk file (for convenience)
- qrencode -o $CIRCLE_ARTIFACTS/QR_apk.png 'https://circle-artifacts.com/gh/'${CIRCLE_PROJECT_USERNAME}'/'${CIRCLE_PROJECT_REPONAME}'/'${CIRCLE_BUILD_NUM}'/artifacts/'${CIRCLE_NODE_INDEX}'/tmp/'`basename $CIRCLE_ARTIFACTS`'/'"${CIRCLE_PROJECT_REPONAME}_circleci_$CIRCLE_SHA1.apk" ; exit 0
## qr code to go directly to the aritfacts (to scan with phone)
- qrencode -o $CIRCLE_ARTIFACTS/QR_artifacts.png 'https://circleci.com/gh/'${CIRCLE_PROJECT_USERNAME}'/'${CIRCLE_PROJECT_REPONAME}'/'${CIRCLE_BUILD_NUM}'#artifacts' ; exit 0

test:
pre:
- mksdcard -l e 180M sdcard.img
- echo 'mtools_skip_check=1' > ~/.mtoolsrc
- android list targets
#
- if [ "$EMU_" == "appemu23" ]; then echo "no" | android create avd -n appemu23 -f -t android-23 --abi default/armeabi-v7a --skin "WXGA720" ; fi
- if [ "$EMU_" == "appemu23" ]; then cat ~/.android/avd/appemu23.avd/config.ini ; fi
#
- if [ "$EMU_" == "appemu21" ]; then echo "no" | android create avd -n appemu21 -f -t android-21 --abi default/armeabi-v7a --skin "WXGA720" ; fi
- if [ "$EMU_" == "appemu21" ]; then cat ~/.android/avd/appemu21.avd/config.ini ; fi
#
- if [ "$EMU_" == "appemu10" ]; then echo "no" | android create avd -n appemu10 -f -t android-10 --abi default/armeabi --skin "WQVGA432" ; fi
- if [ "$EMU_" == "appemu10" ]; then cat ~/.android/avd/appemu10.avd/config.ini ; fi
#
- echo "$EMU_"
- echo "$sdpath"
override:
- emulator -avd "$EMU_" -sdcard sdcard.img -no-audio:
background: true
parallel: true
- circle-android wait-for-boot

- sleep 210 # let the emulator settle down first

- adb shell input keyevent 82 # remove lock screen on emulator
- sleep 10
- import -window root $CIRCLE_ARTIFACTS/capture_emulator_running.png

- fb-adb shell "cat /proc/meminfo" ; exit 0

- adb shell ls -al / ; exit 0
- adb shell ls -al /storage/ ; exit 0
- adb shell ls -al /sdcard/ ; exit 0

- adb install ~/app-signed-aligned.apk

- adb logcat -v time > $CIRCLE_ARTIFACTS/adb_out.txt 2>&1 :
background: true
- sleep 60 # let the emulator settle down first

- fb-adb shell am start -n $CLASS_P/$START_INTENT_P
- sleep 60
- sleep 120 # wait to be sure the app has started fully

- died_count=`cat $CIRCLE_ARTIFACTS/adb_out.txt|grep 'Process. '"$CLASS_P"', PID.'|wc -l|tr -d ' '` ; if [ $died_count -gt 0 ]; then echo "app crashed"; exit 1; fi

- import -window root $CIRCLE_ARTIFACTS/capture_app_running.png # get proof that the app is running
- adb shell screencap -p | sed 's/\r$//' > $CIRCLE_ARTIFACTS/capture_app_running_2.png