From ae189b678b0a1d2781d04235ce0321dd9090f930 Mon Sep 17 00:00:00 2001 From: Gian <47775302+gpunto@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:51:47 +0100 Subject: [PATCH 1/2] Configure coverage through convention plugins --- build.gradle.kts | 23 +++++-- gradle/libs.versions.toml | 6 +- scripts/coverage.gradle | 137 -------------------------------------- scripts/sonar.gradle | 28 -------- 4 files changed, 18 insertions(+), 176 deletions(-) delete mode 100644 scripts/coverage.gradle delete mode 100644 scripts/sonar.gradle diff --git a/build.gradle.kts b/build.gradle.kts index b14ba51890..57f59892a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,6 @@ buildscript { } } -@Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.stream.project) alias(libs.plugins.stream.android.application) apply false @@ -44,14 +43,29 @@ plugins { alias(libs.plugins.hilt) apply false alias(libs.plugins.play.publisher) apply false alias(libs.plugins.baseline.profile) apply false - alias(libs.plugins.sonarqube) apply false - alias(libs.plugins.kover) apply false } streamProject { spotless { excludePatterns = setOf("**/generated/**") } + + coverage { + includedModules = setOf( + "stream-video-android-core", + "stream-video-android-ui-compose", + ) + sonarCoverageExclusions = listOf( + "**/*.mp3", + "**/*.webp", + "**/generated/**", + "**/io/getstream/video/android/core/model/**" + ) + koverClassExclusions = listOf( + "io.getstream.android.video.generated.*", + "io.getstream.video.android.core.model.*" + ) + } } subprojects { @@ -171,9 +185,6 @@ tasks.register("printAllArtifacts") { // return File(teamPropsDir, propsFile) //} -apply(from = "${rootDir}/scripts/sonar.gradle") -apply(from = "${rootDir}/scripts/coverage.gradle") - afterEvaluate { println("Running Add Pre Commit Git Hook Script on Build") exec { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6136de49a5..1465b02ecf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,10 +7,8 @@ minSdk = "24" allureKotlin = "2.4.0" androidGradlePlugin = "8.5.2" cameraCamera2 = "1.3.4" -kover = "0.8.3" -sonarqube = "6.0.1.5171" spotless = "6.21.0" -streamConventions = "0.3.0" +streamConventions = "0.4.0" mavenPublish = "0.34.0" kotlin = "1.9.25" ksp = "1.9.25-1.0.20" @@ -244,8 +242,6 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi kotlin-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatabilityValidator" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } -kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover"} -sonarqube = { id = "org.sonarqube", version.ref = "sonarqube"} spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } stream-project = { id = "io.getstream.project", version.ref = "streamConventions" } stream-android-application = { id = "io.getstream.android.application", version.ref = "streamConventions" } diff --git a/scripts/coverage.gradle b/scripts/coverage.gradle deleted file mode 100644 index 48968fe0de..0000000000 --- a/scripts/coverage.gradle +++ /dev/null @@ -1,137 +0,0 @@ -ext.coverageModules = [ - 'stream-video-android-core', - 'stream-video-android-ui-core', - 'stream-video-android-ui-xml', - 'stream-video-android-ui-compose', -] - -ext.koverClassExcludes = [ - '*R', - '*R$*', - '*BuildConfig', - '*Manifest*', - '*Composable*', - "io.getstream.android.video.generated.*", - "io.getstream.video.android.core.model.*" -] -ext.koverAnnotationExcludes = [ - 'androidx.compose.ui.tooling.preview.Preview' -] - -def configureKoverReports(project) { - project.kover { - reports { - verify { - warningInsteadOfFailure = true - } - filters { - excludes { - classes(rootProject.ext.koverClassExcludes as String[]) - annotatedBy(rootProject.ext.koverAnnotationExcludes as String[]) - } - } - } - } -} - -def coverageModulesWithTests = subprojects.findAll { - rootProject.ext.coverageModules.contains(it.name) && file("${it.projectDir}/src/test").exists() -} -println("\nSetting up coverage for:\n${coverageModulesWithTests.join("\n")}\n") - -// Configure code coverage for modules with tests -subprojects { - def isCoverageModule = coverageModulesWithTests.collect {it.name}.contains(name) - - sonar { - skipProject = !isCoverageModule - } - - if (isCoverageModule) { - apply plugin: "org.jetbrains.kotlinx.kover" - - afterEvaluate { - def isAndroidModule = plugins.hasPlugin("com.android.library") || plugins.hasPlugin("com.android.application") - def hasPaparazziPlugin = plugins.hasPlugin("app.cash.paparazzi") - - if (isAndroidModule) { - android { - buildTypes { - debug { - testCoverageEnabled = true - enableUnitTestCoverage = true - } - } - } - } - - // Determine the appropriate test task name based on module type and plugins - def testTaskName = isAndroidModule - ? (hasPaparazziPlugin ? "verifyPaparazziDebug" : "testDebugUnitTest") - : "test" - - tasks.register("testCoverage") { - group = "verification" - description = "Run module-specific tests" - dependsOn(testTaskName) - } - - kover { - currentProject { - // Variant configuration for aggregated coverage - createVariant("coverage") { - if (isAndroidModule) { - add(["debug"], true) - } else { - add(["jvm"], true) - } - } - } - configureKoverReports(project) - } - } - } -} - -// Configure root project to aggregate coverage reports -apply plugin: "org.jetbrains.kotlinx.kover" - -// Specify the projects that should be included in the aggregate coverage report -coverageModulesWithTests.each { project -> dependencies { kover(project) } } - -// Aggregate all submodules' testCoverage + merged reports -tasks.register("testCoverage") { - group = "verification" - description = "Run all tests in all modules and generate merged coverage report" - - dependsOn coverageModulesWithTests.collect { ":${it.name}:testCoverage" } - - finalizedBy("koverXmlReportCoverage", "koverHtmlReportCoverage") -} - -kover { - currentProject { - // Variant configuration for aggregated coverage (needs to be defined in the root project too) - createVariant("coverage") {} - } - configureKoverReports(project) -} - -sonar { - properties { - property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/kover/reportCoverage.xml" - - def sources = coverageModulesWithTests.collect { project -> - "${project.projectDir}/src/main/kotlin" - }.join(",") - property "sonar.sources", sources - - def tests = coverageModulesWithTests.collect { project -> - [ - "${project.projectDir}/src/androidTest/kotlin", - "${project.projectDir}/src/test/kotlin" - ] - }.flatten().join(",") - property "sonar.tests", tests - } -} diff --git a/scripts/sonar.gradle b/scripts/sonar.gradle deleted file mode 100644 index 9ed895e194..0000000000 --- a/scripts/sonar.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: "org.sonarqube" - -ext.sonar = [ - excludeFilter : [ - '**/test/**', - '**/androidTest/**', - '**/R.class', - '**/R2.class', - '**/R$*.class', - '**/BuildConfig.*', - '**/Manifest*.*', - '**/*.mp3', - '**/*.webp', - "**/generated/**", - "**/io/getstream/video/android/core/model/**" - ] -] - -sonar { - properties { - property("sonar.host.url", "https://sonarcloud.io") - property("sonar.token", "${System.getenv("SONAR_TOKEN")}") - property("sonar.organization", "getstream") - property("sonar.projectKey", "GetStream_stream-video-android") - property("sonar.projectName", "stream-video-android") - property "sonar.exclusions", rootProject.ext.sonar.excludeFilter.join(",") - } -} From c23c5f14a6b79cf8e361eb176d33741a275ba8df Mon Sep 17 00:00:00 2001 From: Gian <47775302+gpunto@users.noreply.github.com> Date: Thu, 27 Nov 2025 09:57:32 +0100 Subject: [PATCH 2/2] Attempt to address flaky tests --- .../video/android/mock/StreamPreviewDataUtils.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt b/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt index e9fd65590c..4cd6986a92 100644 --- a/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt +++ b/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt @@ -143,16 +143,11 @@ public val previewMemberListState: List val participants = arrayListOf() previewCall.state.clearParticipants() previewUsers.forEach { user -> - val sessionId = if (user == previewUsers.first()) { - previewCall.sessionId - } else { - UUID.randomUUID().toString() - } participants.add( MemberState( user = user, - createdAt = OffsetDateTime.now(), - updatedAt = OffsetDateTime.now(), + createdAt = OffsetDateTime.MIN, + updatedAt = OffsetDateTime.MIN, custom = emptyMap(), role = "admin", ),