PixelDroid-App-Android/.gitlab-ci.yml

143 lines
5.2 KiB
YAML
Raw Normal View History

2022-12-31 14:30:57 +01:00
image: registry.gitlab.com/fdroid/fdroidserver:buildserver-bullseye
2022-10-25 01:11:54 +02:00
variables:
GIT_SUBMODULE_STRATEGY: recursive
2023-12-21 14:43:23 +01:00
GIT_SUBMODULE_FORCE_HTTPS: "true"
2022-10-25 01:11:54 +02:00
2022-07-26 21:52:38 +02:00
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
2022-12-31 14:30:57 +01:00
.base:
before_script:
- 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
- apt-get -qy install -t bullseye-backports --no-install-recommends git sdkmanager
- 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"
- export GRADLE_USER_HOME=$PWD/.gradle
2023-12-21 14:43:23 +01:00
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdk\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
2022-12-31 14:30:57 +01:00
- echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
- apt-get update || apt-get update
- apt-get install -y openjdk-17-jdk-headless
2023-01-21 17:35:39 +01:00
- update-java-alternatives -s java-1.17.0-openjdk-amd64
2022-12-31 14:30:57 +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:
paths:
- .gradle/wrapper
- .gradle/caches
# Basic android and gradle stuff
# Check linting
lintDebug:
2022-12-31 14:30:57 +01:00
extends: .base
interruptible: true
stage: build
script:
2022-08-21 11:08:48 +02:00
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint --write-verification-metadata sha256
2022-08-21 12:05:50 +02:00
- git diff --quiet gradle/verification-metadata.xml || (echo 'Verification of dependencies failed!' && exit 1)
2022-08-21 11:08:48 +02:00
artifacts:
2022-08-21 12:05:50 +02:00
when: on_failure
2022-08-21 11:08:48 +02:00
paths:
- gradle/verification-metadata.xml
# Make Project
assembleDebug:
2022-12-31 14:30:57 +01:00
extends: .base
interruptible: true
stage: build
2022-07-11 11:07:41 +02:00
tags:
- server_artectrex
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
2022-07-11 11:07:41 +02:00
# Run all tests, if any fails, interrupt the pipeline (fail it)
debugTests:
2022-12-31 14:30:57 +01:00
extends: .base
interruptible: true
stage: test
script:
2021-03-26 10:26:00 +01:00
- ./gradlew -Pci --console=plain :app:testDebug -x lint
2022-07-11 11:07:41 +02:00
.connected-template: &connected-template
2022-12-31 14:30:57 +01:00
extends: .base
2023-03-21 12:05:46 +01:00
interruptible: true
2022-10-12 14:28:59 +02:00
allow_failure: true
2022-12-31 22:57:54 +01:00
image: briar/ci-image-android-emulator:latest
2022-07-11 11:07:41 +02:00
stage: test
script:
2023-01-21 17:35:39 +01:00
- export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
2022-12-31 22:57:54 +01:00
- ./gradlew assembleStaging
- 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 installStaging
- adb shell am start -n org.pixeldroid.app.debug/org.pixeldroid.app.MainActivity
- if [ $AVD_SDK -lt 25 ] || ! emulator -accel-check; then
export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest;
fi
- ./gradlew connectedStagingAndroidTest $FLAG --info || (adb -e logcat -d > logcat.txt; exit 1)
2022-07-11 11:07:41 +02:00
artifacts:
paths:
- logcat.txt
2022-07-26 21:52:38 +02:00
connected 27 default x86_64:
2022-07-11 11:07:41 +02:00
<<: *connected-template
2021-05-15 12:58:13 +02:00
#inspired from https://gitlab.com/mvglasow/satstat/-/blob/master/.gitlab-ci.yml
fdroid build:
stage: build
image: registry.gitlab.com/mvglasow/ci-images-server:latest
2023-06-22 14:04:36 +02:00
tags:
- server_artectrex
allow_failure: true
artifacts:
# name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- signed/
when: always
2023-06-22 14:04:36 +02:00
only:
- tags
cache:
key: "$CI_JOB_NAME"
paths:
- .android
- .gradle
2021-05-15 12:58:13 +02:00
script:
# Put the correct versionName and versionCode in the .fdroid.yml
2022-08-09 12:49:15 +02:00
- sed -e "s/\${versionName}/$(grep "versionName " app/build.gradle | awk '{print $2}' | tr -d \")$(grep "versionCode" app/build.gradle -m 1 | awk '{print $2}')/" -e "s/\${versionCode}/$(grep "versionCode" app/build.gradle -m 1 | awk '{print $2}')/" .fdroid.yml.template > .fdroid.yml
2021-05-15 12:58:13 +02:00
- rm .fdroid.yml.template
# each `fdroid build --on-server` run expects sudo, then uninstalls it
2021-05-15 12:58:13 +02:00
- set -x
- apt-get install sudo
2023-06-22 14:46:55 +02:00
- fdroid fetchsrclibs --verbose
2021-05-15 12:58:13 +02:00
# this builds the latest version of the app from its source dir, using the build recipe in .fdroid.yml
- fdroid build --verbose --on-server --no-tarball
# create a keystore if we dont have one
- ls .android || mkdir .android
- ls .android/debug.keystore || keytool -genkey -v -keystore .android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname 'C=US, O=Android, CN=Android Debug'
# sign the apk
- cp -R unsigned signed
- jarsigner -verbose -keystore .android/debug.keystore -storepass android -keypass android signed/*.apk androiddebugkey