blob: 9ad92cc0fec1e732d7ddde1c0461730daf43d524 [file] [log] [blame]
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +02001stages:
2 - test
3 - deploy
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +01004
5.base:
6 image: registry.gitlab.com/fdroid/ci-images-client:latest
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +02007 before_script:
8 - export GRADLE_USER_HOME=$PWD/.gradle
9 - export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +020010 - export ANDROID_BUILD_TOOLS=`sed -n "s,.*buildToolsVersion\s*'\([0-9][0-9.]*\)'.*,\1,p" app/build.gradle`
Hans-Christoph Steiner7c7813a2021-06-23 23:05:58 +020011 - apt-get update && apt-get -y install gnupg python3-argcomplete python3-requests
12 - git clone --depth=1 --branch=0.5.1 https://gitlab.com/fdroid/sdkmanager.git
13 - git -C sdkmanager checkout -B master 0e9b843482124fab502fd1b21ab1ca8e2e4c90c5
14 - ./sdkmanager/sdkmanager.py "build-tools;${ANDROID_BUILD_TOOLS}" "platforms;android-${ANDROID_COMPILE_SDK}"
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +020015 after_script:
16 # this file changes every time but should not be cached
17 - rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
18 - rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/
19 cache:
20 paths:
21 - .gradle/wrapper
22 - .gradle/caches
Hans-Christoph Steinera00e48d2017-03-17 12:22:32 +010023
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +010024.test-template: &test-template
25 extends: .base
26 stage: test
27 artifacts:
28 name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
29 paths:
30 - kernel.log
31 - logcat.txt
32 - app/core*
33 - app/*.log
34 - app/build/reports
35 - app/build/outputs/*ml
36 - app/build/outputs/apk
37 expire_in: 1 week
38 when: on_failure
39 after_script:
40 - echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
41
42
Hans-Christoph Steiner684d8242019-01-11 16:06:28 +010043build_on_debian:
44 image: debian:stretch
45 only:
46 - branches
47 variables:
48 ANDROID_HOME: /usr/lib/android-sdk
49 before_script:
50 - echo 'skipping sdkmanager, deps come from apt-get'
51 script:
52 - printf 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";\n'
53 > /etc/apt/apt.conf.d/99no-install-recommends
54 - printf 'APT::Acquire::Retries "20";\n'
55 > /etc/apt/apt.conf.d/99acquire-retries
56 - printf 'APT::Get::Assume-Yes "true";\n'
57 > /etc/apt/apt.conf.d/99assumeyes
58 - apt-get update
59 - apt-get upgrade
60 - apt-get install git wget
61 - apt-get install --install-recommends
62 android-sdk
63 android-sdk-platform-23
64 gradle-debian-helper
65 libgradle-android-plugin-java
Hans-Christoph Steiner7c7813a2021-06-23 23:05:58 +020066 python3-argcomplete
67 python3-requests
68 - git clone --depth=1 --branch=0.5.1 https://gitlab.com/fdroid/sdkmanager.git
69 - git -C sdkmanager checkout -B master 0e9b843482124fab502fd1b21ab1ca8e2e4c90c5
70 - ./sdkmanager/sdkmanager.py "platforms;android-25" "extras;android;m2repository"
Hans-Christoph Steiner684d8242019-01-11 16:06:28 +010071 - mkdir -p $ANDROID_HOME/licenses/
relan6e5ec522019-02-08 19:27:32 +030072 - echo '24333f8a63b6825ea9c5514f83c2829b004d1fee'
Hans-Christoph Steiner684d8242019-01-11 16:06:28 +010073 > $ANDROID_HOME/licenses/android-sdk-license
74 - sed -i
75 -e "s,jcenter(),maven { url 'file:///usr/share/maven-repo' },"
76 build.gradle app/build.gradle
77 - mkdir ~/.android
78 - gradle assembleDebug
79 artifacts:
80 name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}_${CI_JOB_NAME}"
81 paths:
82 - app/build/outputs/apk/*-debug.apk
83 expire_in: 1 week
84 when: on_success
85 after_script:
86 - echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
87
Hans-Christoph Steiner91d025c2016-08-08 16:35:46 +020088test:
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +010089 extends: .base
Hans-Christoph Steiner48c77d32018-06-28 10:51:08 +020090 only:
91 - branches
Hans-Christoph Steiner91d025c2016-08-08 16:35:46 +020092 script:
Hans-Christoph Steiner8cb5c092017-03-17 12:12:32 +010093 - ./gradlew checkstyle
Hans-Christoph Steiner8213e3b2017-04-21 13:37:21 +020094 - ./gradlew assembleDebug
95 - ./create_ota.sh debug
Hans-Christoph Steiner73474d22018-03-21 17:32:45 +010096 - printf "key.store=${HOME}/.android/debug.keystore\nkey.store.password=android\nkey.alias=androiddebugkey\nkey.alias.password=android\n" > signing.properties
97 - ./create_ota.sh release
Hans-Christoph Steinere40a2502016-08-08 16:36:31 +020098 # always report on lint errors to the build log
99 - sed -i -e 's,textReport .*,textReport true,' app/build.gradle
Hans-Christoph Steiner899f6da2016-08-09 16:33:17 +0200100 - ./gradlew build || {
Hans-Christoph Steiner91d025c2016-08-08 16:35:46 +0200101 for log in app/build/reports/*ests/*/*ml; do
102 echo "read $log here:";
103 cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
104 done;
105 exit 1;
106 }
Hans-Christoph Steiner03c1cd52017-04-24 11:14:32 +0200107 - echo "use versionCode that is known to exist on f-droid.org for test:"
Hans-Christoph Steinere50c32b2019-11-21 09:59:33 +0100108 - apt-get -qy install --no-install-recommends jq
109 - wget --quiet --tries=0 https://f-droid.org/repo/index-v1.jar
110 - versionCode=`unzip -qqc index-v1.jar index-v1.json
111 | jq '.packages."org.fdroid.fdroid.privileged"[0].versionCode'`
112 - sed -i 's,versionCode="[^"]*",versionCode="'$versionCode'",' app/src/main/AndroidManifest.xml
Hans-Christoph Steiner8213e3b2017-04-21 13:37:21 +0200113 - ./create_ota.sh release binaries
Hans-Christoph Steiner1c37c352018-06-28 10:53:28 +0200114 artifacts:
Hans-Christoph Steiner684d8242019-01-11 16:06:28 +0100115 name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}_${CI_JOB_NAME}"
Hans-Christoph Steiner1c37c352018-06-28 10:53:28 +0200116 paths:
117 - app/build/distributions/*-debug.zip
118 expire_in: 2 months
119 when: on_success
120 after_script:
121 - echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
Hans-Christoph Steiner0887baf2016-08-10 11:59:12 +0200122
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +0200123# Run the tests in the emulator. Each step is broken out to run on
124# its own since the CI runner can have limited RAM, and the emulator
125# can take a while to start.
126#
127# once these prove stable, the task should be switched to
128# connectedCheck to test all the build flavors
Hans-Christoph Steiner48c77d32018-06-28 10:51:08 +0200129.connected-template: &connected-template
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +0100130 extends: .base
Hans-Christoph Steiner0887baf2016-08-10 11:59:12 +0200131 script:
Hans-Christoph Steiner48c77d32018-06-28 10:51:08 +0200132 - ./gradlew assembleDebug
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +0100133 - export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
134 - export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
135 - export AVD_ARCH=`echo $CI_JOB_NAME | awk '{print $4}'`
136 - export AVD_PACKAGE="system-images;android-${AVD_SDK};${AVD_TAG};${AVD_ARCH}"
137 - echo $AVD_PACKAGE
Hans-Christoph Steiner0887baf2016-08-10 11:59:12 +0200138
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +0100139 - adb start-server
140 - start-emulator
141 - wait-for-emulator
142 - adb devices
143 - adb shell input keyevent 82 &
144 - ./gradlew installDebug
145 - ./gradlew connectedCheck
146
147no-accel 22 default x86:
Hans-Christoph Steiner48c77d32018-06-28 10:51:08 +0200148 only:
149 - branches
Hans-Christoph Steiner816f0542021-03-08 15:37:26 +0100150 <<: *test-template
Hans-Christoph Steiner48c77d32018-06-28 10:51:08 +0200151 <<: *connected-template
Hans-Christoph Steiner9e4d1e82017-03-17 12:23:44 +0100152
Hans-Christoph Steiner09793e72021-06-23 13:30:11 +0200153
154deploy_nightly:
155 extends: .base
156 stage: deploy
157 only:
158 refs:
159 - master
160 variables:
161 - $DEBUG_KEYSTORE
162 script:
163 - sed -i 's,F-Droid,F-Nightly,i' app/src/main/res/values*/strings.xml
164 - export currentVersionCode=$(grep -Eo '[1-9][0-9]{3,}' app/src/main/AndroidManifest.xml)
165 - export versionCode=`printf '%d%05d' $currentVersionCode $(date '+%s'| cut -b4-8)`
166 - sed -i "s,\(\s*android:versionCode=\"\) *[1-9][0-9]*,\1$versionCode," app/src/main/AndroidManifest.xml
167 - 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
168 - git diff
169
170 # build the APKs!
171 - ./gradlew assembleDebug
172 - fdroid nightly -v