2022-05-20 15:44:12 +02:00
image : registry.gitlab.com/fdroid/fdroidserver:buildserver-bullseye
2017-10-11 23:48:12 +02:00
stages :
2022-12-19 15:40:51 +01:00
- lint
2017-10-11 23:48:12 +02:00
- test
- deploy
2022-11-24 20:10:03 +01:00
# only create a pipeline if it is a merge request, not for plain
# branches, unless that branch is master.
workflow :
rules :
- if : '$CI_PIPELINE_SOURCE == "merge_request_event"'
2024-02-15 10:56:15 +01:00
- if : '$CI_PIPELINE_SOURCE == "web"'
- if : '$CI_PIPELINE_SOURCE == "webide"'
2022-11-24 20:10:03 +01:00
- if : '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
2021-02-23 08:51:12 +01:00
.base :
2023-11-23 11:20:49 +01:00
tags :
- saas-linux-xlarge-amd64
2024-01-23 22:10:55 +01:00
variables :
JAVA_HOME : /usr/lib/jvm/java-17-openjdk-amd64
2021-02-23 08:51:12 +01:00
before_script :
2023-06-12 19:00:59 +02:00
- echo "org.gradle.caching=true" >> gradle.properties
2022-05-25 15:25:25 +02:00
- test -e /etc/apt/sources.list.d/bullseye-backports.list
|| echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list
- apt update
2024-01-23 22:10:55 +01:00
- apt-get -qy install -t bullseye-backports --no-install-recommends git sdkmanager openjdk-17-jdk-headless
2022-05-25 15:25:25 +02:00
- test -n "$ANDROID_HOME" || source /etc/profile.d/bsenv.sh
- export cmdline_tools_latest="$ANDROID_HOME/cmdline-tools/latest/bin"
- test -e $cmdline_tools_latest && export PATH="$cmdline_tools_latest:$PATH"
2021-02-23 08:51:12 +01:00
- export GRADLE_USER_HOME=$PWD/.gradle
2024-01-23 21:55:27 +01:00
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdk\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
2022-04-07 22:50:45 +02:00
- echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
2023-06-12 19:00:59 +02:00
# index-v1.jar tests need SHA1 support still, TODO use apksig to validate JAR sigs
2024-01-09 19:23:32 +01:00
- sed -i 's,SHA1 denyAfter 20[0-9][0-9],SHA1 denyAfter 2026,'
2024-01-24 14:43:13 +01:00
/usr/lib/jvm/java-17-openjdk-amd64/conf/security/java.security
2021-02-23 08:51:12 +01:00
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 :
2023-06-12 19:00:59 +02:00
key : '${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}'
2021-02-23 08:51:12 +01:00
paths :
- .gradle/wrapper
- .gradle/caches
2016-09-27 16:19:45 +02:00
2018-01-12 13:50:28 +01:00
.test-template : &test-template
2021-02-23 08:51:12 +01:00
extends : .base
2018-06-15 18:22:38 +02:00
stage : test
2018-01-12 13:50:28 +01:00
artifacts :
name : "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths :
2021-02-17 09:44:33 +01:00
- kernel.log
2018-01-12 13:50:28 +01:00
- logcat.txt
2021-01-12 11:50:53 +01:00
- app/core*
- app/*.log
2018-01-12 13:50:28 +01:00
- app/build/reports
- app/build/outputs/*ml
- app/build/outputs/apk
2023-06-13 19:47:45 +02:00
- libs/*/build/reports
2022-01-27 17:54:12 +01:00
- build/reports
2024-04-08 15:31:30 +02:00
reports :
junit :
- app/build/**/TEST-*.xml
- libs/*/build/**/TEST-*.xml
2018-01-12 13:50:28 +01:00
expire_in : 1 week
when : on_failure
after_script :
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
2023-06-12 19:00:59 +02:00
# 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/
2018-01-12 13:50:28 +01:00
2023-06-12 18:31:13 +02:00
.always-on-these-changes : &always-on-these-changes
changes :
- .gitlab-ci.yml
- build.gradle
2023-06-12 19:31:19 +02:00
app assembleFullRelease test :
2018-01-12 13:50:28 +01:00
<< : *test-template
2023-06-09 21:53:05 +02:00
rules :
2023-06-12 18:31:13 +02:00
- << : *always-on-these-changes
2023-06-09 21:53:05 +02:00
- changes :
- app/**/*
2023-06-20 14:33:27 +02:00
- libs/**/*
2015-08-27 05:28:38 +02:00
script :
2023-06-12 19:31:19 +02:00
- ./gradlew :app:assembleFullRelease :app:testFullDebugUnitTest
2024-02-13 15:17:00 +01:00
artifacts :
name : "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths :
- app/build/reports
- app/build/outputs/apk
- libs/*/build/reports
2024-04-08 15:31:30 +02:00
reports :
junit :
- app/build/test-results/*/TEST-*.xml
2024-02-13 15:17:00 +01:00
expire_in : 1 week
when : always
2023-06-09 21:53:05 +02:00
2023-06-12 18:31:13 +02:00
libs db test :
<< : *test-template
rules :
- << : *always-on-these-changes
- changes :
- libs/database/**/*
script :
- ./gradlew :libs:database:testDebugUnitTest
libs download test :
<< : *test-template
rules :
- << : *always-on-these-changes
- changes :
- libs/download/**/*
script :
- ./gradlew :libs:download:testDebugUnitTest
libs index test :
<< : *test-template
rules :
- << : *always-on-these-changes
- changes :
- libs/index/**/*
script :
- ./gradlew :libs:index:testDebugUnitTest
app lint pmd checkstyle :
2023-06-09 21:53:05 +02:00
<< : *test-template
stage : lint
rules :
2023-06-12 18:31:13 +02:00
- << : *always-on-these-changes
2023-06-09 21:53:05 +02:00
- changes :
- app/**/*
script :
2016-02-24 22:59:01 +01:00
# always report on lint errors to the build log
2016-03-28 12:12:37 +02:00
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
2022-12-19 15:46:44 +01:00
# the tasks "lint", "test", etc don't always include everything
2024-07-12 14:42:31 +02:00
- ./gradlew :app:lint :app:pmd :app:checkstyle :app:ktlintCheck
2023-06-12 18:31:13 +02:00
libs lint ktlintCheck :
<< : *test-template
stage : lint
rules :
- << : *always-on-these-changes
- changes :
- libs/**/*
script :
# always report on lint errors to the build log
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
- ./gradlew :libs:database:lint :libs:download:lint :libs:index:lint ktlintCheck
2022-12-19 15:40:51 +01:00
2023-06-12 18:31:13 +02:00
app tools scripts :
2022-12-19 15:40:51 +01:00
stage : lint
image : debian:bullseye-slim
2023-06-09 21:53:05 +02:00
rules :
2023-06-12 18:31:13 +02:00
- << : *always-on-these-changes
2023-06-09 21:53:05 +02:00
- changes :
- app/**/*
2022-12-19 15:40:51 +01:00
script :
- apt-get update
- apt-get -qy install --no-install-recommends git python3
2022-05-25 21:27:51 +02:00
- ./tools/check-format-strings.py
- ./tools/check-fastlane-whitespace.py
- ./tools/remove-unused-and-blank-translations.py
2018-02-05 17:05:35 +01:00
- echo "These are unused or blank translations that should be removed:"
2022-05-25 21:27:51 +02:00
- git --no-pager diff --ignore-all-space --name-only --exit-code app/src/*/res/values*/strings.xml
2016-05-12 16:18:41 +02:00
2023-06-12 18:31:13 +02:00
app weblate merge conflict :
2023-06-07 19:25:58 +02:00
stage : lint
image : debian:bookworm-slim
rules :
- changes :
- .gitlab-ci.yml
- app/src/*/res/values*/strings.xml
2023-10-19 16:36:42 +02:00
- metadata/
2023-06-07 19:25:58 +02:00
script :
- apt-get update
- apt-get -qy install --no-install-recommends ca-certificates git
- git config user.name "$CI_PIPELINE_ID/$CI_JOB_ID"
- git config user.email $CI_PROJECT_PATH@f-droid.org
- git fetch https://hosted.weblate.org/git/f-droid/f-droid
- git checkout -B weblate FETCH_HEAD
- export EXITVALUE=0
- if ! git rebase $CI_COMMIT_SHA; then
export EXITVALUE=1;
set -x;
while git rebase --skip; do echo; done;
set +x;
fi
- git diff --exit-code
- exit $EXITVALUE
2023-06-12 18:31:13 +02:00
app errorprone :
2021-02-23 08:51:12 +01:00
extends : .base
2023-06-09 21:53:05 +02:00
stage : lint
rules :
2023-06-12 18:31:13 +02:00
- << : *always-on-these-changes
2023-06-09 21:53:05 +02:00
- changes :
- app/**/*
2018-02-13 20:19:45 +01:00
script :
2024-07-12 14:42:31 +02:00
- sed -i "s@plugins {@plugins{\nid 'net.ltgt.errorprone' version '3.1.0'@" app/build.gradle
2018-02-13 20:19:45 +01:00
- cat config/errorprone.gradle >> app/build.gradle
2022-04-07 22:50:45 +02:00
- ./gradlew -Dorg.gradle.dependency.verification=lenient assembleDebug
2018-02-13 20:19:45 +01:00
2023-06-12 18:31:13 +02:00
libs database schema :
2023-06-09 21:53:05 +02:00
stage : lint
2023-02-23 16:46:57 +01:00
image : debian:bullseye-backports
2023-06-09 21:53:05 +02:00
rules :
2023-06-12 18:31:13 +02:00
- << : *always-on-these-changes
2023-06-09 21:53:05 +02:00
- changes :
- libs/database/**/*
2024-01-23 22:10:55 +01:00
variables :
JAVA_HOME : /usr/lib/jvm/java-17-openjdk-amd64
2023-02-23 16:46:57 +01:00
script :
- apt-get update
2024-01-23 22:10:55 +01:00
- apt-get -qy --no-install-recommends install openjdk-17-jdk-headless git sdkmanager
2023-02-23 16:46:57 +01:00
- export ANDROID_HOME=/opt/android-sdk
2024-01-23 21:55:27 +01:00
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdk\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
2024-01-23 22:20:47 +01:00
- sdkmanager "platforms;android-$ANDROID_COMPILE_SDK" "build-tools;34.0.0"
2023-02-23 16:46:57 +01:00
- ./gradlew :libs:database:kaptDebugKotlin
- git --no-pager diff --exit-code
2021-02-17 09:44:33 +01:00
# 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.
#
2018-08-16 13:32:57 +02:00
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
2018-06-15 18:22:38 +02:00
.connected-template : &connected-template
2021-02-23 08:51:12 +01:00
extends : .base
2016-05-16 12:42:58 +02:00
script :
2019-01-07 23:44:28 +01:00
- ./gradlew assembleFullDebug
2019-01-07 11:42:03 +01:00
- 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
2019-03-29 14:26:18 +01:00
2022-04-07 22:50:45 +02:00
- ls -l ~/.android
2019-10-23 15:14:55 +02:00
2022-04-07 22:50:45 +02:00
- adb start-server
- start-emulator
- wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
2021-02-17 09:44:33 +01:00
- ./gradlew installFullDebug
- adb shell am start -n org.fdroid.fdroid.debug/org.fdroid.fdroid.views.main.MainActivity
2023-06-12 20:53:32 +02:00
- if [ $AVD_SDK -lt 29 ] || ! emulator -accel-check; then
2021-01-27 14:55:38 +01:00
export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest;
2019-11-05 21:07:47 +01:00
fi
2019-04-26 00:00:29 +02:00
- ./gradlew connectedFullDebugAndroidTest $FLAG
2016-05-16 12:42:58 +02:00
2022-05-25 15:25:25 +02:00
.kvm-connected-template : &kvm-connected-template
extends : .base
image : briar/ci-image-android-emulator:latest
tags :
- kvm
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
- $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose delete avd --name "$NAME_AVD"
- export AVD="$AVD_PACKAGE"
- echo y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "$AVD"
- echo no | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose create avd --name "$NAME_AVD" --package "$AVD" --device "pixel"
- start-emulator.sh
- ./gradlew installFullDebug
- adb shell am start -n org.fdroid.fdroid.debug/org.fdroid.fdroid.views.main.MainActivity
2023-06-12 20:53:32 +02:00
- if [ $AVD_SDK -lt 29 ] || ! emulator -accel-check; then
2022-05-25 15:25:25 +02:00
export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest;
fi
2023-06-12 19:56:22 +02:00
- ./gradlew :app:connectedFullDebugAndroidTest :libs:database:connectedCheck :libs:download:connectedCheck :libs:index:connectedCheck $FLAG
2022-05-25 15:25:25 +02:00
2018-06-15 18:22:38 +02:00
2022-05-25 15:25:25 +02:00
# Since jobs that require KVM need special runners, these jobs are
# opt-in. To set up your fork to run KVM jobs, go to Settings ->
# CI/CD -> Variables, and add a variable called RUN_KVM_JOBS with a
# value of "1". For example, this is for the canonical repo:
#
# https://gitlab.com/fdroid/fdroidclient/-/settings/ci_cd#js-cicd-variables-settings
2019-01-07 23:44:28 +01:00
.kvm-template : &kvm-template
tags :
- fdroid
- kvm
2022-11-24 20:10:03 +01:00
rules :
- if : $RUN_KVM_JOBS
2019-01-07 23:44:28 +01:00
<< : *test-template
2022-05-25 15:25:25 +02:00
<< : *kvm-connected-template
2019-01-07 23:44:28 +01:00
2023-06-21 11:34:35 +02:00
kvm jobs skipped :
rules :
- if : '$RUN_KVM_JOBS == null || $RUN_KVM_JOBS == "" || $RUN_KVM_JOBS == "0"'
image : alpine # this only needs printf, so it should be as small as possible
variables :
GIT_DEPTH : 1
script :
- printf '\x1b[33mJobs that require KVM need special runners, these jobs are opt-in. To set up your fork to run KVM jobs, go to Settings -> CI/CD -> Variables, and add a variable called RUN_KVM_JOBS with a value of "1". This link should take you there:\n'
- printf "\x1b[32m${CI_SERVER_URL}/$CI_PROJECT_PATH/-/settings/ci_cd#js-cicd-variables-settings\n"
2023-06-12 23:13:06 +02:00
kvm 23 default x86 :
2022-05-25 15:25:25 +02:00
<< : *test-template
2019-01-07 23:44:28 +01:00
<< : *kvm-template
2022-05-20 15:44:12 +02:00
pages :
extends : .base
stage : deploy
only :
- master
script :
2022-07-20 21:06:50 +02:00
- ./gradlew :libs:download:dokkaHtml :libs:index:dokkaHtml :libs:database:dokkaHtml
- mkdir -p public/libs
- touch public/index.html public/libs/index.html
- cp -r libs/download/build/dokka/html public/libs/download
- cp -r libs/index/build/dokka/html public/libs/index
- cp -r libs/database/build/dokka/html public/libs/database
2022-05-20 15:44:12 +02:00
artifacts :
paths :
- public
2022-05-25 15:25:25 +02:00
2019-04-26 10:44:44 +02:00
deploy_nightly :
2021-02-23 08:51:12 +01:00
extends : .base
2017-10-11 23:48:12 +02:00
stage : deploy
only :
- master
2024-01-23 22:10:55 +01:00
variables :
JAVA_HOME : /usr/lib/jvm/java-17-openjdk-amd64
2017-10-11 23:48:12 +02:00
script :
2018-06-27 16:28:03 +02:00
- test -z "$DEBUG_KEYSTORE" && exit 0
2024-01-23 22:10:55 +01:00
- apt-get install -t bullseye-backports openjdk-17-jdk-headless fdroidserver
2017-12-06 16:29:51 +01:00
- 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
2017-12-02 22:50:28 +01:00
- 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
2022-07-26 16:33:36 +02:00
- echo "<item>${CI_PROJECT_URL}-nightly/-/raw/master/fdroid/repo</item>" >> app/src/main/res/values/default_repos.xml
2017-12-02 22:50:28 +01:00
- cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
2022-07-20 21:06:50 +02:00
- export DB=`sed -n 's,.*version *= *\([0-9][0-9]*\).*,\1,p' libs/database/src/main/java/org/fdroid/database/FDroidDatabase.kt`
2022-02-23 19:38:00 +01:00
- export versionCode=`printf '%d%05d' $DB $(date '+%s'| cut -b1-8)`
2018-06-13 13:50:01 +02:00
- sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," app/build.gradle
2017-12-06 16:29:51 +01:00
# build the APKs!
2018-01-04 23:00:55 +01:00
- ./gradlew assembleDebug
- fdroid nightly -v