Update jacoco and github actions (#4639)

* Fix jacoco setup

* Fix task name

* Update CI yml file for codecov

* Fix syntax error

* Use all branch instead of just master

* Fix report upload issue

* Remove returnDefaultValues

* Add Github Action and Codecov badge
This commit is contained in:
Madhur Gupta 2021-09-20 18:09:54 +05:30 committed by GitHub
parent fea5abd802
commit b1f06ad9bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 6 deletions

61
jacoco.gradle Normal file
View file

@ -0,0 +1,61 @@
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.7"
}
android {
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
}
project.afterEvaluate {
android.applicationVariants.all { variant ->
def name = variant.name
def testTaskName = "test${name.capitalize()}UnitTest"
tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."
def fileFilter = ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*']
//java compiled classes
def javaTree = fileTree(
dir: "${buildDir}/intermediates/classes/${name}",
excludes: fileFilter
)
//kotlin compiled classes
def kotlinTree = fileTree(
dir: "${buildDir}/tmp/kotlin-classes/${name}",
excludes: fileFilter
)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([javaTree, kotlinTree]))
executionData.setFrom(fileTree(dir: "${buildDir}", includes: [
"jacoco/${testTaskName}.exec",
"outputs/code-coverage/connected/*coverage.ec"
]))
reports {
xml.enabled = true
html.enabled = true
}
}
}
}