diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5f56aa7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Android CI with Gradle + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + unit_tests: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Install NDK + run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT} + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run unit tests with Gradle + run: ./gradlew :opensrp-chw-family-planning:clean :opensrp-chw-family-planning:jacocoTestReport --stacktrace + - name: Upload coverage to Coveralls with Gradle + run: ./gradlew coveralls --stacktrace + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7eb8a5a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: android -# sudo set to required because of an issue with how TravisCI handles builds in Docker containers https://github.com/travis-ci/travis-ci/issues/3695. -# Setting sudo to required prevents Travis from testing the project in a Docker container. -sudo: required -jdk: oraclejdk8 -dist: precise - -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/ - -env: - matrix: - - ANDROID_TARGET=android-22 ANDROID_ABI=armeabi-v7a - global: - # wait up to 10 minutes for adb to connect to emulator - - MALLOC_ARENA_MAX=2 - - ADB_INSTALL_TIMEOUT=20 #increment timeout to 20 mins - -android: - components: - # tools required - - tools - # The BuildTools version used by your project - - build-tools-27.0.3 - - build-tools-28.0.3 - # The SDK version used to compile your projects - - android-22 - - android-28 - # Additional components - - extra-google-m2repository - - extra-android-m2repository - - # Specify at least one system image, - # if you need to run emulator(s) during your tests - - sys-img-armeabi-v7a-android-22 - -before_script: - # Emulator Management: Create, Start and Wait - - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI - - emulator -avd test -no-skin -no-audio -no-window & - - android-wait-for-emulator - - adb shell input keyevent 82 & - -script: - - echo "Travis branch is $TRAVIS_BRANCH" - - echo "Travis branch is in pull request $TRAVIS_PULL+REQUEST" - - chmod 755 gradlew - - ls -la - #Run jacocoTestReport -> Runs all unit tests & instrumentation tests - - travis_wait ./gradlew :opensrp-chw-family-planning:jacocoTestReport coveralls --stacktrace - -notifications: - slack: - secure: fAiZ4yA7DM6nUKh7nqsCTqZBb03VEAvi5NcRu5mNh5coNn/50XNeZl+qpv7Dw70Ef85Y/k68uc6KwTGVqPXEmVq9Hk3e7lqpBNN8rufvgCYDDGPmywBmU5BhSeykKo0Ee7llM3mRR/EipjIWw1+YvMcS3hCoygf/UlMDDhG0Jo0= diff --git a/build.gradle b/build.gradle index 5975934..a6a06ef 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,12 @@ buildscript { repositories { google() mavenCentral() + maven{ url "https://plugins.gradle.org/m2/" } } dependencies { classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0" + classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2' } } @@ -49,6 +51,7 @@ subprojects { maven { url "https://repo.maven.apache.org/maven2" } maven { url "https://cloudant.github.io/cloudant-sync-eap/repository" } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } + maven{ url "https://plugins.gradle.org/m2/" } mavenLocal() } diff --git a/gradle.properties b/gradle.properties index 747b3ec..ec533a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,3 +14,4 @@ POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev POM_SETTING_NAME=OpenSRP Client Chw Family Plannin POM_SETTING_ARTIFACT_ID=opensrp-chw-family-planning POM_SETTING_PACKAGING=aar +org.gradle.jvmargs=-Xmx2048M -XX\:MaxHeapSize\=32g diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15feb87..08d890a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Nov 27 22:05:16 EAT 2019 +#Tue Dec 01 15:03:54 EAT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/opensrp-chw-family-planning/build.gradle b/opensrp-chw-family-planning/build.gradle index 82d8c3f..a8f7701 100644 --- a/opensrp-chw-family-planning/build.gradle +++ b/opensrp-chw-family-planning/build.gradle @@ -6,8 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' + classpath "com.android.tools.build:gradle:4.0.0" } } @@ -72,7 +71,6 @@ android { includeAndroidResources = true } } - } tasks.withType(Test) { @@ -166,18 +164,23 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea getReports().getHtml().setDestination(file("${buildDir}/reports/jacoco/jacocoRootReport/html")) def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$ViewBinder*.*'] - def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter) + def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/classes", excludes: fileFilter) def mainSrc = "$project.projectDir/src/main/java" - sourceDirectories = files([mainSrc]) - classDirectories = files([debugTree]) - executionData = fileTree(dir: project.buildDir, includes: [ + sourceDirectories.from(files([mainSrc])) + classDirectories .from(files([debugTree])) + executionData.from(fileTree(dir: project.buildDir, includes: [ 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' - ]) + ])) +} + +tasks.coveralls { + dependsOn 'jacocoTestReport' } coveralls { jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/merged.xml" + sourceDirs = ["$project.projectDir/src/main/java"] } apply from: '../maven.gradle' diff --git a/sample/build.gradle b/sample/build.gradle index 5b46dbf..da0bcee 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -60,8 +60,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' + classpath "com.android.tools.build:gradle:4.0.0" } }