This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
/
.travis.yml
91 lines (81 loc) · 4.26 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
sudo: true
language: bash
# ignored on non-linux platforms, but bionic is required for nested virtualization
dist: bionic
services:
- docker
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
env:
global:
- API=21 # Android API level 21 by default
- EMU_FLAVOR=default # use google_apis flavor if no default flavor emulator
- ABI=x86_64
- ADB_INSTALL_TIMEOUT=8 # minutes (2 minutes by default)
- GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/"
- JDK="1.8"
- ANDROID_HOME=${HOME}/android-sdk
- ANDROID_TOOLS_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
- TOOLS=${ANDROID_HOME}/tools # PATH order matters, exists more than one emulator script
- PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH}
before_install:
# Set up JDK 8 for Android SDK - Java is universally needed: codacy, unit tests, emulators
- curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh
- export TARGET_JDK="${JDK}"
- source ~/.install-jdk-travis.sh
- wget -q "${ANDROID_TOOLS_URL}" -O android-sdk-tools.zip
- unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}
- rm android-sdk-tools.zip
- echo 'count=0' > ~/.android/repositories.cfg # avoid harmless sdkmanager warning
- yes | sdkmanager --licenses >/dev/null # accept all sdkmanager warnings
- echo y | sdkmanager --no_https "platform-tools" >/dev/null
- echo y | sdkmanager --no_https "tools" >/dev/null # A second time per Travis docs, gets latest versions
- echo y | sdkmanager --no_https "build-tools;28.0.3" >/dev/null # Implicit gradle dependency - gradle drives changes
- echo y | sdkmanager --no_https "platforms;android-28" >/dev/null # We need the API of the current compileSdkVersion from gradle.properties
- export EMULATOR="system-images;android-${API};${EMU_FLAVOR};${ABI}" # Used to install/create emulator
- docker build -t rpicheck/test-sshd ./ssh/src/test/resources/
- docker run -d -p 127.0.0.1:2222:22 rpicheck/test-sshd
install:
# List and delete unnecessary components to free space
- sdkmanager --list || true
# Update sdk tools to latest version and install/update components
- echo yes | sdkmanager "platforms;android-28" >/dev/null # Latest platform required by SDK tools
- echo yes | sdkmanager "platforms;android-${API}" >/dev/null # Android platform required by emulator
- echo yes | sdkmanager "extras;android;m2repository" >/dev/null
- echo yes | sdkmanager "extras;google;m2repository" >/dev/null
- echo yes | sdkmanager "emulator" >/dev/null # latest emulator
- echo yes | sdkmanager "$EMULATOR" >/dev/null # Install emulator system image
# Set up KVM on linux for hardware acceleration. Manually here so it only happens for emulator tests, takes ~30s
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends install bridge-utils libpulse0 libvirt-bin qemu-kvm virtinst ubuntu-vm-builder
- sudo adduser $USER libvirt
- sudo adduser $USER kvm
# Check components status
- sdkmanager --list || true
- echo $PATH
before_script:
# Create and start emulator
- echo no | avdmanager create avd --force -n test -k "$EMULATOR" -c 10M
- |
EMU_PARAMS="-verbose -no-snapshot -no-window -camera-back none -camera-front none -selinux permissive -qemu -m 2048"
EMU_COMMAND="emulator"
# This double "sudo" monstrosity is used to have Travis execute the
# emulator with its new group permissions and help preserve the rule
# of least privilege.
sudo -E sudo -u $USER -E bash -c "${ANDROID_HOME}/emulator/${EMU_COMMAND} -avd test ${AUDIO} ${EMU_PARAMS} &"
# Wait for emulator fully-booted and disable animations
- sudo chmod a+x ./tools/android-wait-for-emulator.sh
- ./tools/android-wait-for-emulator.sh
- adb shell input keyevent 82 &
script:
# Run all device checks
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew build connectedCheck -PdisablePreDex
after_script:
# Show tests and lint results
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/outputs/androidTest-results/connected/*
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/reports/lint-results.xml