Skip to content

Add configuration for building on Travis CI #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
sudo: required # disables container-based builds which have a maximum of 4GB of memory
language: android
jdk: oraclejdk8
env:
global:
- ADB_INSTALL_TIMEOUT=15 # wait up to 15 minutes for adb to connect to emulator (2 minutes by default)
- EMULATOR_ANDROID_VERSION=19
- BUILD_ANDROID_VERSION=28
- BUILD_TOOLS_VERSION=28.0.3
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
android:
components:
- tools # to get the new `repository-11.xml`
- tools # https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- platform-tools
- build-tools-$BUILD_TOOLS_VERSION
- android-$BUILD_ANDROID_VERSION
- android-$EMULATOR_ANDROID_VERSION
- sys-img-armeabi-v7a-android-$EMULATOR_ANDROID_VERSION
licenses:
- 'android-sdk-license-.+'
before_install:
# List all available targets, device definitions and AVDs.
- sdkmanager --list || true

# Update sdk tools to latest version and install/update components
- yes | sdkmanager "tools" > /dev/null
- yes | sdkmanager "platform-tools" > /dev/null
- yes | sdkmanager "build-tools;$BUILD_TOOLS_VERSION" > /dev/null

- yes | sdkmanager "platforms;android-$EMULATOR_ANDROID_VERSION" > /dev/null
- yes | sdkmanager "platforms;android-$BUILD_ANDROID_VERSION" > /dev/null

# - yes | sdkmanager "system-images;android-24;google_apis;armeabi-v7a" > /dev/null

- yes | sdkmanager --update > /dev/null
- yes | sdkmanager --licenses > /dev/null

# Check components status
- sdkmanager --list || true

before_script:
# local.properties file is not checked in but required (an empty file is good enough)
- touch local.properties

# Make sure gradlew is executable
- chmod +x gradlew

# Create emulator and wait for it to start
- sdkmanager "system-images;android-$EMULATOR_ANDROID_VERSION;google_apis;armeabi-v7a"
- echo no | avdmanager -v create avd -f -n test -k "system-images;android-$EMULATOR_ANDROID_VERSION;google_apis;armeabi-v7a"
# Use new emulator executable location
- $ANDROID_HOME/emulator/emulator -avd test -no-audio -no-window &
- android-wait-for-emulator

# Turn off animations
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &

# Wake up
- adb shell input keyevent 82 &
- adb shell input keyevent 1 &

script:
- ./gradlew clean test --stacktrace

# Simpler config, but less up-to-date when it comes to tooling.
# Added here for historical reasons.
# language: android
# jdk: oraclejdk8
# android:
# components:
# - tools
# - platform-tools
# - build-tools-28.0.3
# - android-28
# - android-24
# - sys-img-armeabi-v7a-android-24
# licenses:
# - 'android-sdk-license-.+'
# before_install:
# - yes | sdkmanager "platforms;android-24"
# - yes | sdkmanager "platforms;android-28"
# - yes | sdkmanager "build-tools;28.0.3"
# before_script:
# local.properties file is not checked in but required (an empty file is good enough)
# - touch local.properties

# Make sure gradlew is executable
# - chmod +x gradlew

# Create emulator and wait for it to start
# - echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a
# - emulator -avd test -no-skin -no-window &
# - android-wait-for-emulator
# - adb shell input keyevent 82 &

# 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
# script:
# - ./gradlew clean test --stacktrace
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
projectVersion = [
minSdk : 21,
minSdk : 19,
targetSdk : 28,
compileSdk : 28,
kotlin : "1.3.11"
Expand Down
84 changes: 84 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
8 changes: 8 additions & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ pluginBundle {
}
}

test {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams true
}
}

dependencies {
compileOnly gradleApi()
implementation projectDependency.gradlePlugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.neotech.plugin.rootcoverage

import com.google.common.truth.Truth.assertThat
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
import java.io.OutputStreamWriter
import kotlin.test.assertEquals

@RunWith(Parameterized::class)
Expand All @@ -24,7 +22,9 @@ class IntegrationTest(
val runner = GradleRunner.create()
.withProjectDir(projectRoot)
.withPluginClasspath()
.forwardStdOutput(OutputStreamWriter(System.out))
// Without forwardOutput travis CI could timeout because not output will be reported
// for a long time.
.forwardOutput()
.withArguments("clean", "rootCodeCoverageReport", "--stacktrace")

// Expect no failure
Expand Down