consolidate jacoco coverage

This commit is contained in:
Milos Kozak 2022-02-09 22:45:05 +01:00
parent 8cc8f1681a
commit 8aa523ab0e
4 changed files with 97 additions and 34 deletions

View file

@ -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.

View file

@ -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
}

View file

@ -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 {

View file

@ -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)
}
}