Hans-Christoph Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 1 | stages: |
| 2 | - test |
| 3 | - deploy |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 4 | |
| 5 | .base: |
| 6 | image: registry.gitlab.com/fdroid/ci-images-client:latest |
Hans-Christoph Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 7 | 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 Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 10 | - export ANDROID_BUILD_TOOLS=`sed -n "s,.*buildToolsVersion\s*'\([0-9][0-9.]*\)'.*,\1,p" app/build.gradle` |
Hans-Christoph Steiner | 7c7813a | 2021-06-23 23:05:58 +0200 | [diff] [blame] | 11 | - 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 Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 15 | 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 Steiner | a00e48d | 2017-03-17 12:22:32 +0100 | [diff] [blame] | 23 | |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 24 | .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 Steiner | 684d824 | 2019-01-11 16:06:28 +0100 | [diff] [blame] | 43 | build_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 Steiner | 7c7813a | 2021-06-23 23:05:58 +0200 | [diff] [blame] | 66 | 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 Steiner | 684d824 | 2019-01-11 16:06:28 +0100 | [diff] [blame] | 71 | - mkdir -p $ANDROID_HOME/licenses/ |
relan | 6e5ec52 | 2019-02-08 19:27:32 +0300 | [diff] [blame] | 72 | - echo '24333f8a63b6825ea9c5514f83c2829b004d1fee' |
Hans-Christoph Steiner | 684d824 | 2019-01-11 16:06:28 +0100 | [diff] [blame] | 73 | > $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 Steiner | 91d025c | 2016-08-08 16:35:46 +0200 | [diff] [blame] | 88 | test: |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 89 | extends: .base |
Hans-Christoph Steiner | 48c77d3 | 2018-06-28 10:51:08 +0200 | [diff] [blame] | 90 | only: |
| 91 | - branches |
Hans-Christoph Steiner | 91d025c | 2016-08-08 16:35:46 +0200 | [diff] [blame] | 92 | script: |
Hans-Christoph Steiner | 8cb5c09 | 2017-03-17 12:12:32 +0100 | [diff] [blame] | 93 | - ./gradlew checkstyle |
Hans-Christoph Steiner | 8213e3b | 2017-04-21 13:37:21 +0200 | [diff] [blame] | 94 | - ./gradlew assembleDebug |
| 95 | - ./create_ota.sh debug |
Hans-Christoph Steiner | 73474d2 | 2018-03-21 17:32:45 +0100 | [diff] [blame] | 96 | - 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 Steiner | e40a250 | 2016-08-08 16:36:31 +0200 | [diff] [blame] | 98 | # always report on lint errors to the build log |
| 99 | - sed -i -e 's,textReport .*,textReport true,' app/build.gradle |
Hans-Christoph Steiner | 899f6da | 2016-08-09 16:33:17 +0200 | [diff] [blame] | 100 | - ./gradlew build || { |
Hans-Christoph Steiner | 91d025c | 2016-08-08 16:35:46 +0200 | [diff] [blame] | 101 | 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 Steiner | 03c1cd5 | 2017-04-24 11:14:32 +0200 | [diff] [blame] | 107 | - echo "use versionCode that is known to exist on f-droid.org for test:" |
Hans-Christoph Steiner | e50c32b | 2019-11-21 09:59:33 +0100 | [diff] [blame] | 108 | - 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 Steiner | 8213e3b | 2017-04-21 13:37:21 +0200 | [diff] [blame] | 113 | - ./create_ota.sh release binaries |
Hans-Christoph Steiner | 1c37c35 | 2018-06-28 10:53:28 +0200 | [diff] [blame] | 114 | artifacts: |
Hans-Christoph Steiner | 684d824 | 2019-01-11 16:06:28 +0100 | [diff] [blame] | 115 | name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}_${CI_JOB_NAME}" |
Hans-Christoph Steiner | 1c37c35 | 2018-06-28 10:53:28 +0200 | [diff] [blame] | 116 | 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 Steiner | 0887baf | 2016-08-10 11:59:12 +0200 | [diff] [blame] | 122 | |
Hans-Christoph Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 123 | # 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 Steiner | 48c77d3 | 2018-06-28 10:51:08 +0200 | [diff] [blame] | 129 | .connected-template: &connected-template |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 130 | extends: .base |
Hans-Christoph Steiner | 0887baf | 2016-08-10 11:59:12 +0200 | [diff] [blame] | 131 | script: |
Hans-Christoph Steiner | 48c77d3 | 2018-06-28 10:51:08 +0200 | [diff] [blame] | 132 | - ./gradlew assembleDebug |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 133 | - 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 Steiner | 0887baf | 2016-08-10 11:59:12 +0200 | [diff] [blame] | 138 | |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 139 | - 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 | |
| 147 | no-accel 22 default x86: |
Hans-Christoph Steiner | 48c77d3 | 2018-06-28 10:51:08 +0200 | [diff] [blame] | 148 | only: |
| 149 | - branches |
Hans-Christoph Steiner | 816f054 | 2021-03-08 15:37:26 +0100 | [diff] [blame] | 150 | <<: *test-template |
Hans-Christoph Steiner | 48c77d3 | 2018-06-28 10:51:08 +0200 | [diff] [blame] | 151 | <<: *connected-template |
Hans-Christoph Steiner | 9e4d1e8 | 2017-03-17 12:23:44 +0100 | [diff] [blame] | 152 | |
Hans-Christoph Steiner | 09793e7 | 2021-06-23 13:30:11 +0200 | [diff] [blame] | 153 | |
| 154 | deploy_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 |