Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,34 @@ jobs:
setup-rust: true
- name: Full Gradle Test
run: ./gradlew assembleDebug assembleAndroidTest assembleUnitTest test
jacoco:
runs-on: "ubuntu-latest"
steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v3.5.2
with:
submodules: 'recursive'
- name: Set up Build
uses: ./.github/actions/setup-build
with:
setup-gradle: true
setup-protoc: true
setup-rust: true
- name: Generate JaCoCo Report
run: ./gradlew jacocoTestReport
run: ./gradlew designcompose:jacocoDebugUnitTestReport
- name: Upload JaCoCo Report
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: jacoco-report
path: build/reports/jacoco/jacocoTestReport/html
path: designcompose/build/reports/jacoco/jacocoDebugUnitTestReport/html
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
files: designcompose/build/reports/jacoco/jacocoDebugUnitTestReport/jacocoDebugUnitTestReport.xml
flags: kotlin
build-maven-repo:
runs-on: "ubuntu-latest"
Expand Down
35 changes: 35 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 0 additions & 34 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,3 @@ for (projectName in listOf("tutorial-app", "helloworld-app", "cluster-demo", "me
project(projectName).plugins.apply("designcompose.conventions.roborazzi")
}
}

subprojects { apply(plugin = "jacoco") }

tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(subprojects.map { it.tasks.withType<Test>() })
dependsOn(subprojects.map { it.tasks.withType<JacocoReport>() })

val coreModules = listOf("annotation", "common", "designcompose")
val source =
files(
subprojects
.filter { it.name in coreModules }
.map {
val sourceSets = it.extensions.findByType(SourceSetContainer::class.java)
sourceSets?.findByName("main")?.allSource
}
)
sourceDirectories.setFrom(source)
classDirectories.setFrom(
files(
subprojects
.filter { it.name in coreModules }
.map {
val sourceSets = it.extensions.findByType(SourceSetContainer::class.java)
sourceSets?.findByName("main")?.output
}
)
)
executionData.setFrom(fileTree(project.rootDir) { include("**/build/jacoco/test.exec") })
reports {
xml.required.set(true)
html.required.set(true)
}
}
56 changes: 54 additions & 2 deletions designcompose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {
initWith(buildTypes.getByName("release"))
matchingFallbacks.add("release")
}
debug { enableUnitTestCoverage = true }
}

packaging {
Expand All @@ -69,10 +70,61 @@ android {
add("META-INF/LGPL2.1")
}
}
testOptions { unitTests { isIncludeAndroidResources = true } }
testOptions {
unitTests {
isIncludeAndroidResources = true
all { test ->
test.extensions.configure<JacocoTaskExtension> {
// These classes are not supposed to be accessible
excludes = listOf("jdk.internal.*")
isIncludeNoLocationClasses =
true // Include classes without location information
}
}
}
}
}

tasks.withType<Test> { jacoco { isEnabled = true } }
tasks.register<JacocoReport>("jacocoDebugUnitTestReport") {
group = "verification"
dependsOn(tasks.named("testDebugUnitTest"))

// Point Jacoco to the source code. This correctly finds both Java and Kotlin files.
val mainSourceSet = android.sourceSets.getByName("main").java.srcDirs
sourceDirectories.setFrom(files(mainSourceSet))

val jacocoExcludes =
listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
// Add other classes or packages to exclude from coverage as needed
)

// Point Jacoco to the classes that were generated by the compilation
classDirectories.setFrom(
files(
fileTree(layout.buildDirectory.dir("intermediates/javac/debug")) {
exclude(jacocoExcludes)
},
fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) {
exclude(jacocoExcludes)
},
)
)
// Collect execution data from .exec and .ec files generated during test execution
executionData.setFrom(
files(fileTree(layout.buildDirectory) { include(listOf("**/*.exec", "**/*.ec")) })
)
println(executionData.files.joinToString("\n"))

reports {
html.required.set(true)
xml.required.set(true)
}
}

// To simplify publishing of the entire SDK, make the DesignCompose publish tasks depend on the
// Gradle Plugin's publish tasks
Expand Down
Loading