From df0277830d8202ac9d80cb725a7f4e17234e9728 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Tue, 1 Dec 2020 14:43:25 +0300 Subject: [PATCH 1/6] Migrate family to circle ci --- .github/workflows/ci.yml | 32 +++++++++++++ .travis.yml | 60 ------------------------ build.gradle | 2 + opensrp-chw-family-planning/build.gradle | 3 +- 4 files changed, 35 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml 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..4818456 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ buildscript { 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 +50,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/opensrp-chw-family-planning/build.gradle b/opensrp-chw-family-planning/build.gradle index 82d8c3f..a2ba32c 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.2" } } From c040a5af9d7d18f8392ba848be1bedf4b2897f1b Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Tue, 1 Dec 2020 15:44:55 +0300 Subject: [PATCH 2/6] Migrate family to circle ci --- build.gradle | 1 + gradle/wrapper/gradle-wrapper.properties | 4 ++-- opensrp-chw-family-planning/build.gradle | 8 ++++---- sample/build.gradle | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 4818456..a6a06ef 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ buildscript { repositories { google() mavenCentral() + maven{ url "https://plugins.gradle.org/m2/" } } dependencies { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15feb87..845abea 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.5-all.zip diff --git a/opensrp-chw-family-planning/build.gradle b/opensrp-chw-family-planning/build.gradle index a2ba32c..5038aaf 100644 --- a/opensrp-chw-family-planning/build.gradle +++ b/opensrp-chw-family-planning/build.gradle @@ -168,11 +168,11 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", 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' - ]) + ])) } coveralls { diff --git a/sample/build.gradle b/sample/build.gradle index 5b46dbf..77c52b8 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.2" } } From 8a1f05af1c4c6d647691fd7eee1bc026844774b0 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Tue, 1 Dec 2020 17:17:37 +0300 Subject: [PATCH 3/6] Changed Versions on gradle file --- gradle/wrapper/gradle-wrapper.properties | 2 +- opensrp-chw-family-planning/build.gradle | 7 +++++-- sample/build.gradle | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 845abea..08d890a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-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 5038aaf..58c42da 100644 --- a/opensrp-chw-family-planning/build.gradle +++ b/opensrp-chw-family-planning/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.0.2" + classpath "com.android.tools.build:gradle:4.0.0" } } @@ -70,8 +70,11 @@ android { unitTests { includeAndroidResources = true } - } + unitTests.all { + jvmArgs "-Xmx3g" + } + } } tasks.withType(Test) { diff --git a/sample/build.gradle b/sample/build.gradle index 77c52b8..da0bcee 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -60,7 +60,7 @@ buildscript { jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.0.2" + classpath "com.android.tools.build:gradle:4.0.0" } } From 14decee554074aa134f523b06efe1b25b40f1949 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Tue, 1 Dec 2020 17:24:48 +0300 Subject: [PATCH 4/6] Removes unitTests.all section from gradle file --- opensrp-chw-family-planning/build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/opensrp-chw-family-planning/build.gradle b/opensrp-chw-family-planning/build.gradle index 58c42da..b5db89f 100644 --- a/opensrp-chw-family-planning/build.gradle +++ b/opensrp-chw-family-planning/build.gradle @@ -70,10 +70,6 @@ android { unitTests { includeAndroidResources = true } - - unitTests.all { - jvmArgs "-Xmx3g" - } } } From 45b80c994e02c51245d13043d1e4b543cdfe5452 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Tue, 1 Dec 2020 21:30:48 +0300 Subject: [PATCH 5/6] Trigger CI From 619fb2c43055c18aa838a181238001476432f4d5 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Wed, 2 Dec 2020 15:11:50 +0300 Subject: [PATCH 6/6] Fixes failing test build --- gradle.properties | 1 + opensrp-chw-family-planning/build.gradle | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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/opensrp-chw-family-planning/build.gradle b/opensrp-chw-family-planning/build.gradle index b5db89f..a8f7701 100644 --- a/opensrp-chw-family-planning/build.gradle +++ b/opensrp-chw-family-planning/build.gradle @@ -164,7 +164,7 @@ 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.from(files([mainSrc])) @@ -174,8 +174,13 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea ])) } +tasks.coveralls { + dependsOn 'jacocoTestReport' +} + coveralls { jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/merged.xml" + sourceDirs = ["$project.projectDir/src/main/java"] } apply from: '../maven.gradle'