image: jangrewe/gitlab-ci-android variables: COBERTURA_REPORT: '$CI_PROJECT_DIR/app/build/reports/cobertura.xml' JACOCO_CSV_LOCATION: '$CI_PROJECT_DIR/app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.csv' JACOCO_XML_LOCATION: '$CI_PROJECT_DIR/app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml' stages: - test - visualize - build - deploy .gradle-default: before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle - chmod +x ./gradlew - mkdir -p .android && touch .android/repositories.cfg script: - echo "Overwrite me" cache: key: ${CI_PROJECT_ID} paths: - .gradle/ .build: stage: build variables: apk_file: 'app/build/outputs/apk/debug/app-debug.apk' metadata_file: 'metadata/audio.funkwhale.android.yml' before_script: - git fetch --unshallow --tags after_script: - export versionCode=`$ANDROID_HOME/build-tools/30.0.2/aapt dump badging $apk_file | grep versionCode | awk '{print $3}' | sed s/versionCode=//g | sed s/\'//g` - apt update && apt install gettext-base - cat metadata/template.yml | envsubst > $metadata_file extends: .gradle-default artifacts: paths: - $apk_file - $metadata_file test: extends: .gradle-default stage: test script: - ./gradlew test jacocoTestReport - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $JACOCO_CSV_LOCATION artifacts: reports: junit: app/build/test-results/test**/TEST-*.xml paths: - $JACOCO_XML_LOCATION coverage: stage: visualize image: gjrtimmer/jacoco2cobertura:1.0.8 script: # convert report from jacoco to cobertura, use relative project path - 'python /opt/cover2cover.py $JACOCO_XML_LOCATION $CI_PROJECT_DIR/app/src/main/java > app/build/reports/cobertura.xml' needs: [ "test" ] dependencies: - test artifacts: reports: cobertura: $COBERTURA_REPORT build-develop: extends: .build script: - echo -n $SIGNING_KEY_STORE | base64 -d > app/android.keystore - ./gradlew assembleDebug -Psigning.store=android.keystore -Psigning.store_passphrase=$SIGNING_KEY_PASS -Psigning.key_passphrase=$SIGNING_KEY_PASS only: - develop build-bleeding-edge: extends: .build script: - ./gradlew assembleDebug except: - develop deploy-develop: stage: deploy only: - develop script: - eval `ssh-agent -s` - ssh-add <(echo "$SSH_PRIVATE_KEY") - scp -o StrictHostKeyChecking=no app/build/outputs/apk/debug/app-debug.apk fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/repo/audio.funkwhale.ffa.dev-$CI_COMMIT_SHORT_SHA.apk - scp -o StrictHostKeyChecking=no metadata/audio.funkwhale.android.yml fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/metadata/audio.funkwhale.ffa.dev.yml - ssh -o StrictHostKeyChecking=no fdroid@apps.funkwhale.audio 'docker run --rm -u $(id -u):$(id -g) -v /srv/fdroid/fdroid/develop:/repo registry.gitlab.com/fdroid/docker-executable-fdroidserver:master update' tags: - shell