I am trying to integrate the code coverage tool Coveralls.io in my Android project. I am using JaCoCo for generating the coverage reports and the Coveralls Gradle plugin to upload them. My GitHub Action workflow completes successfully, but the coverage report is not appearing on Coveralls.io.
Here is a summary of my setup:
JaCoCo: Used for generating code coverage reports.
Coveralls Gradle Plugin: Used for uploading the reports to Coveralls.io.
GitHub Actions: Used for CI/CD.
The GitHub Action workflow runs without any errors, but when I check Coveralls.io, I don't see the report.
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Execute unit tests
run: ./gradlew createDebugCoverageReport
- name: Report Coveralls
run: ./gradlew coverallsJacoco
build.gradle:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
jacoco
alias(libs.plugins.coveralls.jacoco)
}
android {
namespace = "io.demo.coveralldemo"
compileSdk = 34
defaultConfig {
applicationId = "io.demo.coveralldemo"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
testOptions {
unitTests.all {
}
unitTests.isReturnDefaultValues = true
}
buildTypes {
debug {
enableUnitTestCoverage = true
isMinifyEnabled = false
}
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation (libs.androidx.core.testing)
}
apply("$rootDir/jacoco.gradle.kts")
coverallsJacoco {
reportPath = "${buildDir}/reports/coverage/test/debug/index.html"
}
jacoco.gradle.kts :
apply(plugin = "jacoco")
tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(tasks["testDebugUnitTest"])
reports {
xml.required.set(true)
html.required.set(true)
}
val fileFilter = listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*"
)
val debugTree = fileTree(mapOf("dir" to "$buildDir/intermediates/javac/debug", "excludes" to fileFilter))
val mainSrc = "$projectDir/src/main/java"
sourceDirectories.setFrom(files(mainSrc))
classDirectories.setFrom(files(debugTree))
executionData.setFrom(fileTree(mapOf("dir" to "$buildDir", "includes" to listOf(
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
))))
}
Build Log:
It keeps giving error,
"There have been no builds for this repo."
After changing the report format from HTML to XML, it started showing the coverage report.