diff --git a/.circleci/config.yml b/.circleci/config.yml index 795c6415f1..43c4a8ece3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,10 @@ jobs: # The next step will run the unit tests - android/run-tests: - test-command: ./gradlew -Pcoverage -PfirebaseDisable testFullDebugUnitTest jacocoTestFullDebugUnitTestReport + test-command: ./gradlew testFullDebugUnitTest + + - android/run-tests: + test-command: ./gradlew allDebugCoverage # Then start the emulator and run the Instrumentation tests! # - android/start-emulator-and-run-tests: @@ -33,35 +36,7 @@ jobs: # command: | # ./gradlew assembleRelease - codecov/upload: - file: './app/build/jacoco/jacoco.xml' - - codecov/upload: - file: './automation/build/jacoco/jacoco.xml' - - codecov/upload: - file: './combo/build/jacoco/jacoco.xml' - - codecov/upload: - file: './core/build/jacoco/jacoco.xml' - - codecov/upload: - file: './dana/build/jacoco/jacoco.xml' - - codecov/upload: - file: './danar/build/jacoco/jacoco.xml' - - codecov/upload: - file: './danars/build/jacoco/jacoco.xml' - - codecov/upload: - file: './database/build/jacoco/jacoco.xml' - - codecov/upload: - file: './insight/build/jacoco/jacoco.xml' - - codecov/upload: - file: './medtronic/build/jacoco/jacoco.xml' - - codecov/upload: - file: './omnipod-common/build/jacoco/jacoco.xml' - - codecov/upload: - file: './omnipod-dash/build/jacoco/jacoco.xml' - - codecov/upload: - file: './omnipod-eros/build/jacoco/jacoco.xml' - - codecov/upload: - file: './rileylink/build/jacoco/jacoco.xml' - - codecov/upload: - file: './wear/build/jacoco/jacoco.xml' + file: './build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml' workflows: # Below is the definition of your workflow. diff --git a/build.gradle b/build.gradle index b11d6d276d..419d8ccd94 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,7 @@ buildscript { plugins { id "io.gitlab.arturbosch.detekt" version "1.19.0" id "org.jlleitschuh.gradle.ktlint" version "10.2.1" + id 'org.barfuin.gradle.jacocolog' version '2.0.0' } allprojects { @@ -86,6 +87,8 @@ allprojects { } } +apply from: 'gradle/jacoco_project.gradle' + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/gradle/android_dependencies.gradle b/gradle/android_dependencies.gradle index eb031288c2..0b9f1aa958 100644 --- a/gradle/android_dependencies.gradle +++ b/gradle/android_dependencies.gradle @@ -19,10 +19,10 @@ android { debug { testCoverageEnabled(project.hasProperty('coverage')) } - firebaseDisable { - System.setProperty("disableFirebase", "true") - ext.enableCrashlytics = false - } +// firebaseDisable { +// System.setProperty("disableFirebase", "true") +// ext.enableCrashlytics = false +// } } compileOptions { diff --git a/gradle/jacoco_project.gradle b/gradle/jacoco_project.gradle new file mode 100644 index 0000000000..b5ccab1077 --- /dev/null +++ b/gradle/jacoco_project.gradle @@ -0,0 +1,85 @@ +apply plugin: 'jacoco' + +jacoco { + toolVersion '0.8.7' +} + +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] +} + +project.afterEvaluate { + def variants = ["debug", "fullDebug"] + + tasks.create(name: "allDebugCoverage", type: JacocoReport) { + + group = "Reporting" + description = "Generate overall Jacoco coverage report for the debug build." + + reports { + html.required.set(true) + xml.required.set(true) + } + + def excludes = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/*Test*.*', + 'android/**/*.*', + 'androidx/**/*.*', + '**/*$ViewInjector*.*', + '**/*Dagger*.*', + '**/*MembersInjector*.*', + '**/*_Factory.*', + '**/*_Provide*Factory*.*', + '**/*_ViewBinding*.*', + '**/AutoValue_*.*', + '**/R2.class', + '**/R2$*.class', + '**/*Directions$*', + '**/*Directions.*', + '**/*Binding.*' + ] + + def jClasses = subprojects.collect { proj -> + variants.collect { variant -> + "${proj.buildDir}/intermediates/javac/$variant/classes" + } + }.flatten() + def kClasses = subprojects.collect { proj -> + variants.collect { variant -> + "${proj.buildDir}/tmp/kotlin-classes/$variant" + } + }.flatten() + + def javaClasses = jClasses.collect { path -> + fileTree(dir: path, excludes: excludes) + } + def kotlinClasses = kClasses.collect { path -> + fileTree(dir: path, excludes: excludes) + } + + classDirectories.from = files([javaClasses, kotlinClasses]) + def sources = subprojects.collect { proj -> + variants.collect { variant -> + ["${proj.projectDir}/src/main/java", "${proj.projectDir}/src/main/kotlin", + "${proj.projectDir}/src/$variant/java", "${proj.projectDir}/src/$variant/kotlin"] + }.flatten() + }.flatten() + sourceDirectories.from = files(sources) + + def executions = subprojects.collect { proj -> + variants.collect { variant -> + def path = "${proj.buildDir}/jacoco/test${variant.capitalize()}UnitTest.exec" + printf('Collecting execution data from: %s\n', path) + if ((new File(path)).exists()) path else null + } + }.flatten() + executions.removeAll([null]) + + executionData.from = files(executions) + } +}