blob: 9ad92cc0fec1e732d7ddde1c0461730daf43d524 [file] [log] [blame]
stages:
- test
- deploy
.base:
image: registry.gitlab.com/fdroid/ci-images-client:latest
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`
- export ANDROID_BUILD_TOOLS=`sed -n "s,.*buildToolsVersion\s*'\([0-9][0-9.]*\)'.*,\1,p" app/build.gradle`
- apt-get update && apt-get -y install gnupg python3-argcomplete python3-requests
- git clone --depth=1 --branch=0.5.1 https://gitlab.com/fdroid/sdkmanager.git
- git -C sdkmanager checkout -B master 0e9b843482124fab502fd1b21ab1ca8e2e4c90c5
- ./sdkmanager/sdkmanager.py "build-tools;${ANDROID_BUILD_TOOLS}" "platforms;android-${ANDROID_COMPILE_SDK}"
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/
cache:
paths:
- .gradle/wrapper
- .gradle/caches
.test-template: &test-template
extends: .base
stage: test
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- kernel.log
- logcat.txt
- app/core*
- app/*.log
- 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"
build_on_debian:
image: debian:stretch
only:
- branches
variables:
ANDROID_HOME: /usr/lib/android-sdk
before_script:
- echo 'skipping sdkmanager, deps come from apt-get'
script:
- printf 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";\n'
> /etc/apt/apt.conf.d/99no-install-recommends
- printf 'APT::Acquire::Retries "20";\n'
> /etc/apt/apt.conf.d/99acquire-retries
- printf 'APT::Get::Assume-Yes "true";\n'
> /etc/apt/apt.conf.d/99assumeyes
- apt-get update
- apt-get upgrade
- apt-get install git wget
- apt-get install --install-recommends
android-sdk
android-sdk-platform-23
gradle-debian-helper
libgradle-android-plugin-java
python3-argcomplete
python3-requests
- git clone --depth=1 --branch=0.5.1 https://gitlab.com/fdroid/sdkmanager.git
- git -C sdkmanager checkout -B master 0e9b843482124fab502fd1b21ab1ca8e2e4c90c5
- ./sdkmanager/sdkmanager.py "platforms;android-25" "extras;android;m2repository"
- mkdir -p $ANDROID_HOME/licenses/
- echo '24333f8a63b6825ea9c5514f83c2829b004d1fee'
> $ANDROID_HOME/licenses/android-sdk-license
- sed -i
-e "s,jcenter(),maven { url 'file:///usr/share/maven-repo' },"
build.gradle app/build.gradle
- mkdir ~/.android
- gradle assembleDebug
artifacts:
name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}_${CI_JOB_NAME}"
paths:
- app/build/outputs/apk/*-debug.apk
expire_in: 1 week
when: on_success
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
test:
extends: .base
only:
- branches
script:
- ./gradlew checkstyle
- ./gradlew assembleDebug
- ./create_ota.sh debug
- printf "key.store=${HOME}/.android/debug.keystore\nkey.store.password=android\nkey.alias=androiddebugkey\nkey.alias.password=android\n" > signing.properties
- ./create_ota.sh release
# always report on lint errors to the build log
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
- ./gradlew build || {
for log in app/build/reports/*ests/*/*ml; do
echo "read $log here:";
cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
done;
exit 1;
}
- echo "use versionCode that is known to exist on f-droid.org for test:"
- apt-get -qy install --no-install-recommends jq
- wget --quiet --tries=0 https://f-droid.org/repo/index-v1.jar
- versionCode=`unzip -qqc index-v1.jar index-v1.json
| jq '.packages."org.fdroid.fdroid.privileged"[0].versionCode'`
- sed -i 's,versionCode="[^"]*",versionCode="'$versionCode'",' app/src/main/AndroidManifest.xml
- ./create_ota.sh release binaries
artifacts:
name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}_${CI_JOB_NAME}"
paths:
- app/build/distributions/*-debug.zip
expire_in: 2 months
when: on_success
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
# Run the tests in the emulator. Each step is broken out to run on
# its own since the CI runner can have limited RAM, and the emulator
# can take a while to start.
#
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
.connected-template: &connected-template
extends: .base
script:
- ./gradlew assembleDebug
- 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
- adb start-server
- start-emulator
- wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
- ./gradlew installDebug
- ./gradlew connectedCheck
no-accel 22 default x86:
only:
- branches
<<: *test-template
<<: *connected-template
deploy_nightly:
extends: .base
stage: deploy
only:
refs:
- master
variables:
- $DEBUG_KEYSTORE
script:
- sed -i 's,F-Droid,F-Nightly,i' app/src/main/res/values*/strings.xml
- export currentVersionCode=$(grep -Eo '[1-9][0-9]{3,}' app/src/main/AndroidManifest.xml)
- export versionCode=`printf '%d%05d' $currentVersionCode $(date '+%s'| cut -b4-8)`
- sed -i "s,\(\s*android:versionCode=\"\) *[1-9][0-9]*,\1$versionCode," app/src/main/AndroidManifest.xml
- sed -Ei 's@(\s*new Pair<>)@ // aosp testkey\n new Pair<>("org.fdroid.fdroid", "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc"),\n new Pair<>("org.fdroid.fdroid.debug", "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc"),\n // fdroidclient-nightly\n new Pair<>("org.fdroid.fdroid.debug", "659e1fd284549f70d13fb02c620100e27eeea3420558cce62b0f5d4cf2b77d84"),\1\n@' app/src/main/java/org/fdroid/fdroid/privileged/ClientWhitelist.java
- git diff
# build the APKs!
- ./gradlew assembleDebug
- fdroid nightly -v