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

168 lines
6.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

image: registry.gitlab.com/fdroid/fdroidserver:buildserver-bullseye
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
.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
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
- echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
- apt-get update || apt-get update
- apt-get install -y openjdk-17-jdk-headless
- update-java-alternatives -s java-1.17.0-openjdk-amd64
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:
extends: .base
interruptible: true
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint --write-verification-metadata sha256
- git diff --quiet gradle/verification-metadata.xml || (echo 'Verification of dependencies failed!' && exit 1)
artifacts:
when: on_failure
paths:
- gradle/verification-metadata.xml
# Make Project
assembleDebug:
extends: .base
interruptible: true
stage: build
tags:
- server_artectrex
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
# Run all tests, if any fails, interrupt the pipeline (fail it)
debugTests:
extends: .base
interruptible: true
stage: test
script:
- ./gradlew -Pci --console=plain :app:testDebug -x lint
.connected-template: &connected-template
extends: .base
interruptible: true
allow_failure: true
image: briar/ci-image-android-emulator:latest
stage: test
script:
- export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
- ./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)
artifacts:
paths:
- logcat.txt
connected 27 default x86_64:
<<: *connected-template
fdroid build:
stage: build
image: registry.gitlab.com/fdroid/ci-images-client:latest
tags:
- server_artectrex
artifacts:
paths:
- signed/
when: always
only:
- tags
cache:
key: "$CI_JOB_NAME"
paths:
- .gradle
- .android
script:
# Put the correct versionName and versionCode in the .fdroid.yml
- 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
- rm .fdroid.yml.template
- test -d build || mkdir build
- test -d fdroidserver || mkdir fdroidserver
- git ls-remote https://gitlab.com/fdroid/fdroidserver.git master
- curl --silent https://gitlab.com/fdroid/fdroidserver/-/archive/master/fdroidserver-master.tar.gz
| tar -xz --directory=fdroidserver --strip-components=1
- export PATH="`pwd`/fdroidserver:$PATH"
- export PYTHONPATH="$CI_PROJECT_DIR/fdroidserver:$CI_PROJECT_DIR/fdroidserver/examples"
- export PYTHONUNBUFFERED=true
- bash fdroidserver/buildserver/setup-env-vars $ANDROID_HOME
- adduser --disabled-password --gecos "" vagrant
- ln -s $CI_PROJECT_DIR/fdroidserver /home/vagrant/fdroidserver
- mkdir -p /vagrant/cache
- wget -q https://services.gradle.org/distributions/gradle-5.6.2-bin.zip --output-document=/vagrant/cache/gradle-5.6.2-bin.zip
# Check sha256 of the gradle build
- echo '32fce6628848f799b0ad3205ae8db67d0d828c10ffe62b748a7c0d9f4a5d9ee0 /vagrant/cache/gradle-5.6.2-bin.zip' | sha256sum -c
- bash fdroidserver/buildserver/provision-gradle
- bash fdroidserver/buildserver/provision-apt-get-install https://deb.debian.org/debian
- source /etc/profile.d/bsenv.sh
- apt-get dist-upgrade
# install fdroidserver from git, with deps from Debian, until fdroidserver
# is stable enough to include all the things needed here
- apt-get install -t stretch-backports
fdroidserver
python3-asn1crypto
python3-ruamel.yaml
yamllint
- apt-get purge fdroidserver
- export GRADLE_USER_HOME=$PWD/.gradle
# each fdroid build --on-server run expects sudo, then uninstalls it
- set -x
- apt-get install sudo
- fdroid fetchsrclibs --verbose
# 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