-
Notifications
You must be signed in to change notification settings - Fork 1
Travis CI
Travis CI is a CI/CD tool that provides easy testing and deployments by making this process automatically.
language: android
jdk: oraclejdk8
env:
global:
- ANDROID_TARGET=android-24
- ANDROID_ABI=armeabi-v7a
android:
components:
- tools
- platform-tools
- build-tools-29.0.3
- android-28
- extra-google-m2repository
- extra-android-m2repository
- extra-android-support
- $ANDROID_TARGET
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
licenses:
- 'google-gdk-license-.+'
- 'android-sdk-preview-license-.+'
As you can see, this is the first step of the CI process, where I'm telling Travis that I want a Virtual machine with Android and jdk8 that will be used to compile the project.
Then I ask for a series of needed componentes like android tools, sdks, Android Virtual devices etc and also giving the ability to accept licenses when installing things.
stages:
- name: lint
- name: tests
jobs:
include:
- stage: lint
script:
- ./gradlew detektLint;
- ./gradlew lintDebug
- stage: tests
script:
- ./gradlew testDebugUnitTest
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI --device 'Nexus 4'
- emulator -avd test -no-window -skin 768x1280 &
- android-wait-for-emulator
- adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
- ./gradlew connectedAndroidTest
- ./gradlew jacocoTestReport
after_success:
- bash <(curl -s https://codecov.io/bash)
before_deploy:
- git config --local user.name "PexegoUva"
- git config --local user.email "samuelvv22@gmail.com"
- export TRAVIS_TAG=${TRAVIS_TAG:-$(./gradlew -q printVersionName)}
- echo $TRAVIS_TAG
- git tag $TRAVIS_TAG
This part is about steps of the CI process:
- First of all, we have the
lintstep, wheredetektandlintDebugwill be executed to ensure code quality and no bad smells. - Secondly, we have
teststep, where we will rununitandconnectedtests by executing an Android Virtual device. - Third, when tests are OK and
code-coveragehas been generated, I send results to Codecov to be able to get useful information about test health.
PD: I'm doing tests on only one device because in the current state of the project I think it is enough. I have picked the last supported version (API 24) and a old device (like Nexus 4) to ensure the app works on low device.
To improve this part we can make use of Firebase lab that will run Acceptance test in a cluster of devices from all the supported APIs and models.
#### Travis deployments
deploy:
- provider: releases
api_key: "$GITHUB_API_KEY"
file: app/build/outputs/apk/debug/*
file_glob: true
skip_cleanup: true
prerelease: true
on:
branch: master
This last part is about CD (continuos delivery). Will run at the end of the process is everything was OK, and will generate a Release with the provided APK, then will upload that to Github project.