2021-12-22 15:54:55 +01:00
|
|
|
image: dev.funkwhale.audio:5050/funkwhale/funkwhale-android:latest
|
2021-06-26 20:50:26 +02:00
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
variables:
|
2021-08-06 21:16:46 +02:00
|
|
|
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'
|
2021-06-26 20:50:26 +02:00
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
stages:
|
2021-12-22 15:54:55 +01:00
|
|
|
- build_ci_env
|
2021-07-30 10:57:49 +02:00
|
|
|
- test
|
|
|
|
- visualize
|
|
|
|
- build
|
|
|
|
- deploy
|
2021-06-26 20:50:26 +02:00
|
|
|
|
2021-12-22 15:54:55 +01:00
|
|
|
build_ci_image:
|
|
|
|
stage: build_ci_env
|
|
|
|
image: egon0/docker-with-buildx-and-git:bash
|
|
|
|
tags:
|
|
|
|
- dind
|
|
|
|
services:
|
|
|
|
- docker:20-dind
|
|
|
|
before_script:
|
|
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
|
|
script:
|
|
|
|
- docker build -t $CI_REGISTRY_IMAGE docker
|
|
|
|
after_script:
|
|
|
|
- docker push $CI_REGISTRY_IMAGE
|
|
|
|
rules:
|
|
|
|
- if: '$BUILD_CI_IMAGE'
|
|
|
|
variables:
|
|
|
|
DOCKER_HOST: tcp://docker:2375/
|
|
|
|
DOCKER_DRIVER: overlay2
|
|
|
|
DOCKER_TLS_CERTDIR: ""
|
|
|
|
|
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
.gradle-default:
|
2021-07-13 10:30:33 +02:00
|
|
|
before_script:
|
2021-07-30 10:57:49 +02:00
|
|
|
- export GRADLE_USER_HOME=$(pwd)/.gradle
|
|
|
|
- chmod +x ./gradlew
|
|
|
|
- mkdir -p .android && touch .android/repositories.cfg
|
2021-07-13 10:30:33 +02:00
|
|
|
script:
|
2021-07-30 10:57:49 +02:00
|
|
|
- echo "Overwrite me"
|
2021-07-13 10:30:33 +02:00
|
|
|
|
|
|
|
cache:
|
|
|
|
key: ${CI_PROJECT_ID}
|
|
|
|
paths:
|
2021-07-30 10:57:49 +02:00
|
|
|
- .gradle/
|
|
|
|
|
|
|
|
.build:
|
2021-08-11 14:02:31 +02:00
|
|
|
stage: build
|
|
|
|
variables:
|
|
|
|
apk_file: 'app/build/outputs/apk/debug/app-debug.apk'
|
2021-08-27 10:14:00 +02:00
|
|
|
metadata_file: 'metadata/audio.funkwhale.android.dev.yml'
|
|
|
|
metadata_template: 'metadata/preview.template.yml'
|
|
|
|
output_metadata: 'app/build/outputs/apk/debug/output-metadata.json'
|
2021-08-10 22:56:48 +02:00
|
|
|
before_script:
|
2021-08-11 11:28:19 +02:00
|
|
|
- git fetch --unshallow --tags
|
2021-08-11 14:02:31 +02:00
|
|
|
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
|
2021-08-27 10:14:00 +02:00
|
|
|
- cat $metadata_template | envsubst > $metadata_file
|
2021-07-30 10:57:49 +02:00
|
|
|
extends: .gradle-default
|
|
|
|
artifacts:
|
|
|
|
paths:
|
2021-08-11 14:02:31 +02:00
|
|
|
- $apk_file
|
|
|
|
- $metadata_file
|
2021-08-27 10:14:00 +02:00
|
|
|
- $output_metadata
|
2021-07-13 10:30:33 +02:00
|
|
|
|
2021-07-30 10:57:49 +02:00
|
|
|
test:
|
|
|
|
extends: .gradle-default
|
|
|
|
stage: test
|
2021-08-27 10:14:00 +02:00
|
|
|
except:
|
|
|
|
- tags
|
2021-07-30 10:57:49 +02:00
|
|
|
script:
|
2021-12-22 15:54:55 +01:00
|
|
|
- ./gradlew --no-daemon --stacktrace test jacocoTestReport
|
2021-07-30 10:57:49 +02:00
|
|
|
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $JACOCO_CSV_LOCATION
|
2021-06-26 20:50:26 +02:00
|
|
|
artifacts:
|
2021-07-30 10:57:49 +02:00
|
|
|
reports:
|
|
|
|
junit: app/build/test-results/test**/TEST-*.xml
|
2021-06-26 20:50:26 +02:00
|
|
|
paths:
|
2021-08-06 21:16:46 +02:00
|
|
|
- $JACOCO_XML_LOCATION
|
2021-07-30 10:57:49 +02:00
|
|
|
|
|
|
|
coverage:
|
|
|
|
stage: visualize
|
2022-01-03 09:34:37 +01:00
|
|
|
image: haynes/jacoco2cobertura:1.0.8
|
2021-07-30 10:57:49 +02:00
|
|
|
script:
|
|
|
|
# convert report from jacoco to cobertura, use relative project path
|
2021-08-06 21:16:46 +02:00
|
|
|
- 'python /opt/cover2cover.py $JACOCO_XML_LOCATION $CI_PROJECT_DIR/app/src/main/java > app/build/reports/cobertura.xml'
|
2021-07-30 10:57:49 +02:00
|
|
|
needs: [ "test" ]
|
|
|
|
dependencies:
|
|
|
|
- test
|
2021-08-27 10:14:00 +02:00
|
|
|
except:
|
|
|
|
- tags
|
2021-07-30 10:57:49 +02:00
|
|
|
artifacts:
|
|
|
|
reports:
|
2021-08-06 21:16:46 +02:00
|
|
|
cobertura: $COBERTURA_REPORT
|
2021-07-11 21:40:34 +02:00
|
|
|
|
2021-07-13 10:30:33 +02:00
|
|
|
build-develop:
|
|
|
|
extends: .build
|
|
|
|
script:
|
2021-08-27 10:14:00 +02:00
|
|
|
- echo -n $PREVIEW_SIGNING_KEY_STORE | base64 -d > app/android.keystore
|
2022-01-03 09:52:57 +01:00
|
|
|
- ./gradlew --stacktrace --no-daemon assembleDebug -x check -Psigning.store=android.keystore -Psigning.store_passphrase=$PREVIEW_SIGNING_KEY_PASS -Psigning.key_passphrase=$PREVIEW_SIGNING_KEY_PASS
|
2021-07-13 10:30:33 +02:00
|
|
|
only:
|
2021-07-30 10:57:49 +02:00
|
|
|
- develop
|
2021-07-13 10:30:33 +02:00
|
|
|
|
2021-08-27 10:14:00 +02:00
|
|
|
build-release:
|
|
|
|
variables:
|
|
|
|
apk_file: 'app/build/outputs/apk/release/app-release.apk'
|
|
|
|
output_metadata: 'app/build/outputs/apk/release/output-metadata.json'
|
|
|
|
metadata_template: 'metadata/release.template.yml'
|
|
|
|
metadata_file: 'metadata/audio.funkwhale.android.yml'
|
|
|
|
extends: .build
|
|
|
|
script:
|
|
|
|
- echo -n $SIGNING_KEY_STORE | base64 -d > app/android.keystore
|
2021-12-22 15:54:55 +01:00
|
|
|
- ./gradlew --stacktrace --no-daemon assembleRelease -Psigning.store=android.keystore -Psigning.store_passphrase=$SIGNING_KEY_PASS -Psigning.key_passphrase=$SIGNING_KEY_PASS
|
2021-08-27 10:14:00 +02:00
|
|
|
only:
|
|
|
|
- tags
|
|
|
|
|
2021-07-13 10:30:33 +02:00
|
|
|
build-bleeding-edge:
|
|
|
|
extends: .build
|
|
|
|
script:
|
2022-01-03 09:52:57 +01:00
|
|
|
- ./gradlew --stacktrace --no-daemon -x check assembleDebug
|
2021-07-13 10:30:33 +02:00
|
|
|
except:
|
2021-07-30 10:57:49 +02:00
|
|
|
- develop
|
2021-08-30 20:03:00 +02:00
|
|
|
- tags
|
2021-07-13 10:30:33 +02:00
|
|
|
|
2021-08-30 20:32:40 +02:00
|
|
|
.deploy:
|
|
|
|
image: debian
|
|
|
|
before_script:
|
2021-08-30 20:53:48 +02:00
|
|
|
- apt update && apt -y install openssh-server
|
2021-08-30 20:32:40 +02:00
|
|
|
|
2021-07-11 21:40:34 +02:00
|
|
|
deploy-develop:
|
2021-08-30 20:32:40 +02:00
|
|
|
extends: .deploy
|
2021-07-11 21:40:34 +02:00
|
|
|
stage: deploy
|
2021-07-30 10:57:49 +02:00
|
|
|
only:
|
|
|
|
- develop
|
2021-07-11 21:40:34 +02:00
|
|
|
script:
|
2021-07-30 10:57:49 +02:00
|
|
|
- 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
|
2021-08-11 14:39:36 +02:00
|
|
|
- scp -o StrictHostKeyChecking=no app/build/outputs/apk/debug/output-metadata.json fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/output-metadata.json
|
2021-08-27 10:14:00 +02:00
|
|
|
- scp -o StrictHostKeyChecking=no metadata/audio.funkwhale.android.dev.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'
|
|
|
|
|
|
|
|
deploy-release:
|
2021-08-30 20:32:40 +02:00
|
|
|
extends: .deploy
|
2021-08-27 10:14:00 +02:00
|
|
|
stage: deploy
|
|
|
|
only:
|
|
|
|
- tags
|
|
|
|
script:
|
|
|
|
- eval `ssh-agent -s`
|
|
|
|
- ssh-add <(echo "$SSH_PRIVATE_KEY")
|
2021-09-05 11:33:03 +02:00
|
|
|
- scp -o StrictHostKeyChecking=no app/build/outputs/apk/release/app-release.apk fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/repo/audio.funkwhale.ffa-$CI_COMMIT_TAG.apk
|
2021-08-27 10:14:00 +02:00
|
|
|
- scp -o StrictHostKeyChecking=no app/build/outputs/apk/release/output-metadata.json fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/output-metadata.json
|
|
|
|
- scp -o StrictHostKeyChecking=no metadata/audio.funkwhale.android.yml fdroid@apps.funkwhale.audio:/srv/fdroid/fdroid/develop/metadata/audio.funkwhale.ffa.yml
|
2021-07-30 10:57:49 +02:00
|
|
|
- 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'
|