BobStore/.gitlab-ci.yml
Hans-Christoph Steiner 22773f3de3 gitlab-ci: force skip Espresso tests on < android-25
It seems that ARM emulators timeout even when just trying to run the
assumeTrue() tests via Espresso.  There needs to be one test still enabled
in the file, otherwise, the run fails with:

org.fdroid.fdroid.MainActivityEspressoTest > initializationError[Nexus_One_API_19(AVD) - 4.4.2] FAILED
        java.lang.Exception: No runnable methods
        at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
2019-01-08 20:36:32 +01:00

189 lines
5.9 KiB
YAML

image: registry.gitlab.com/fdroid/ci-images-client:latest
cache:
paths:
- .gradle/wrapper
- .gradle/caches
stages:
- test
- deploy
before_script:
- export GRADLE_USER_HOME=$PWD/.gradle
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
- alias sdkmanager="sdkmanager --no_https"
- echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
.test-template: &test-template
stage: test
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- logcat.txt
- app/build/reports
- app/build/outputs/*ml
- app/build/outputs/apk
expire_in: 1 week
when: on_failure
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
# Run the most important first. Then we can decide whether to ignore
# the style tests if the rest of the more meaningful tests pass.
test_lint_pmd_checkstyle:
<<: *test-template
script:
- export EXITVALUE=0
- ./gradlew assemble
# always report on lint errors to the build log
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
- ./gradlew testFullDebugUnitTest
- ./gradlew lint
- ./gradlew pmd || export EXITVALUE=1
- ./gradlew checkstyle || export EXITVALUE=1
- ./tools/check-format-strings.py || export EXITVALUE=1
- ./tools/remove-unused-and-blank-translations.py || export EXITVALUE=1
- echo "These are unused or blank translations that should be removed:"
- git --no-pager diff --ignore-all-space --name-only --exit-code app/src/*/res/values*/strings.xml || export EXITVALUE=1
- exit $EXITVALUE
errorprone:
stage: test
script:
- cat config/errorprone.gradle >> app/build.gradle
- ./gradlew assembleDebug
allow_failure: true
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
.connected-template: &connected-template
script:
- ./gradlew assembleFullDebug
- export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
- export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
- export AVD_ARCH=`echo $CI_JOB_NAME | awk '{print $4}'`
- export AVD_PACKAGE="system-images;android-${AVD_SDK};${AVD_TAG};${AVD_ARCH}"
- echo $AVD_PACKAGE
- emulator -accel-check || true
- alias sdkmanager
- echo y | sdkmanager "emulator" "platforms;android-$AVD_SDK" > /dev/null
- if ! avdmanager list avd | grep "Name. avd$AVD_SDK$"; then
set -x;
rm -rf ~/.android/avd $ANDROID_HOME/system-images;
echo y | sdkmanager "$AVD_PACKAGE" > /dev/null;
echo no | avdmanager create avd --name avd$AVD_SDK --tag "$AVD_TAG" --package "$AVD_PACKAGE" --sdcard 64M --device "Nexus 5";
export RAMSIZE="$((`sed -n 's,^MemAvailable:[^0-9]*\([0-9][0-9]*\)[^0-9]*$,\1,p' /proc/meminfo` * 3 / 4 / 1024))";
sed -i '/^hw\.ramSize\s*=.*/d' ~/.android/avd/*.avd/config.ini;
echo "hw.ramSize=$RAMSIZE" >> ~/.android/avd/*.avd/config.ini;
avdmanager list avd;
set +x;
fi
- adb start-server
- ls -l ~/.android
- emulator -avd avd$AVD_SDK
-no-audio
-no-jni
-no-snapstorage
-no-window
-skip-adb-auth
-verbose
-wipe-data
&
- wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
- test $AVD_SDK -ge 25 || export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=android.test.suitebuilder.annotation.LargeTest
- ./gradlew connectedFullDebugAndroidTest $FLAG || (adb -e logcat -d > logcat.txt; exit 1)
connected 24 default armeabi-v7a:
retry: 1
only:
- merge_requests
<<: *test-template
<<: *connected-template
.kvm-template: &kvm-template
tags:
- fdroid
- kvm
only:
- merge_requests
- branches@fdroid/fdroidclient
<<: *test-template
<<: *connected-template
connected 17 default x86:
<<: *kvm-template
connected 18 default x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 19 default x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 21 default x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 22 default x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 23 default x86:
<<: *kvm-template
connected 24 google_apis x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 25 default x86:
<<: *kvm-template
connected 26 google_apis x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 27 google_apis_playstore x86:
<<: *kvm-template
only:
- master@fdroid/fdroidclient
connected 28 default x86_64:
<<: *kvm-template
deploy_nightly:
stage: deploy
only:
- master
script:
- test -z "$DEBUG_KEYSTORE" && exit 0
- sed -i
's,<string name="app_name">.*</string>,<string name="app_name">F-Nightly</string>,'
app/src/main/res/values*/strings.xml
# add this nightly repo as a enabled repo
- sed -i -e '/<\/string-array>/d' -e '/<\/resources>/d' app/src/main/res/values/default_repos.xml
- echo "<item>${CI_PROJECT_PATH}-nightly</item>" >> app/src/main/res/values/default_repos.xml
- echo "<item>${CI_PROJECT_URL}-nightly/raw/master/fdroid/repo</item>" >> app/src/main/res/values/default_repos.xml
- cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
- export DB=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java`
- export versionCode=`printf '%d%05d' $DB $(date '+%s'| cut -b4-8)`
- sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," app/build.gradle
# build the APKs!
- ./gradlew assembleDebug
- fdroid nightly -v
after_script:
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/