Merge branch 'develop' into renovate/io.nlopez.compose.rules-detekt-0.x
This commit is contained in:
commit
628149ff62
43 changed files with 309 additions and 325 deletions
176
build.gradle.kts
176
build.gradle.kts
|
|
@ -1,7 +1,5 @@
|
|||
import com.google.devtools.ksp.gradle.KspTask
|
||||
import kotlinx.kover.api.KoverTaskExtension
|
||||
import org.apache.tools.ant.taskdefs.optional.ReplaceRegExp
|
||||
import org.jetbrains.kotlin.cli.common.toBooleanLenient
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
|
|
@ -41,7 +39,7 @@ plugins {
|
|||
alias(libs.plugins.ktlint)
|
||||
alias(libs.plugins.dependencygraph)
|
||||
alias(libs.plugins.sonarqube)
|
||||
alias(libs.plugins.kover)
|
||||
alias(libs.plugins.kover) apply false
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean").configure {
|
||||
|
|
@ -164,177 +162,7 @@ allprojects {
|
|||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "kover")
|
||||
}
|
||||
|
||||
// https://kotlin.github.io/kotlinx-kover/
|
||||
// Run `./gradlew koverMergedHtmlReport` to get report at ./build/reports/kover
|
||||
// Run `./gradlew koverMergedReport` to also get XML report
|
||||
koverMerged {
|
||||
enable()
|
||||
|
||||
filters {
|
||||
classes {
|
||||
excludes.addAll(
|
||||
listOf(
|
||||
// Exclude generated classes.
|
||||
"*_ModuleKt",
|
||||
"anvil.hint.binding.io.element.*",
|
||||
"anvil.hint.merge.*",
|
||||
"anvil.hint.multibinding.io.element.*",
|
||||
"anvil.module.*",
|
||||
"com.airbnb.android.showkase*",
|
||||
"io.element.android.libraries.designsystem.showkase.*",
|
||||
"io.element.android.x.di.DaggerAppComponent*",
|
||||
"*_Factory",
|
||||
"*_Factory_Impl",
|
||||
"*_Factory$*",
|
||||
"*_Module",
|
||||
"*_Module$*",
|
||||
"*Module_Provides*",
|
||||
"Dagger*Component*",
|
||||
"*ComposableSingletons$*",
|
||||
"*_AssistedFactory_Impl*",
|
||||
"*BuildConfig",
|
||||
// Generated by Showkase
|
||||
"*Ioelementandroid*PreviewKt$*",
|
||||
"*Ioelementandroid*PreviewKt",
|
||||
// Other
|
||||
// We do not cover Nodes (normally covered by maestro, but code coverage is not computed with maestro)
|
||||
"*Node",
|
||||
"*Node$*",
|
||||
// Exclude `:libraries:matrix:impl` module, it contains only wrappers to access the Rust Matrix SDK api, so it is not really relevant to unit test it: there is no logic to test.
|
||||
"io.element.android.libraries.matrix.impl.*",
|
||||
"*Presenter\$present\$*",
|
||||
// Forked from compose
|
||||
"io.element.android.libraries.designsystem.theme.components.bottomsheet.*",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
annotations {
|
||||
excludes.addAll(
|
||||
listOf(
|
||||
"*Preview",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
projects {
|
||||
excludes.addAll(
|
||||
listOf(
|
||||
":anvilannotations",
|
||||
":anvilcodegen",
|
||||
":samples:minimal",
|
||||
":tests:testutils",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Run ./gradlew koverMergedVerify to check the rules.
|
||||
verify {
|
||||
// Does not seems to work, so also run the task manually on the workflow.
|
||||
onCheck.set(true)
|
||||
// General rule: minimum code coverage.
|
||||
rule {
|
||||
name = "Global minimum code coverage."
|
||||
target = kotlinx.kover.api.VerificationTarget.ALL
|
||||
bound {
|
||||
minValue = 65
|
||||
// Setting a max value, so that if coverage is bigger, it means that we have to change minValue.
|
||||
// For instance if we have minValue = 20 and maxValue = 30, and current code coverage is now 31.32%, update
|
||||
// minValue to 25 and maxValue to 35.
|
||||
maxValue = 75
|
||||
counter = kotlinx.kover.api.CounterType.INSTRUCTION
|
||||
valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE
|
||||
}
|
||||
}
|
||||
// Rule to ensure that coverage of Presenters is sufficient.
|
||||
rule {
|
||||
name = "Check code coverage of presenters"
|
||||
target = kotlinx.kover.api.VerificationTarget.CLASS
|
||||
overrideClassFilter {
|
||||
includes += "*Presenter"
|
||||
excludes += "*Fake*Presenter"
|
||||
excludes += "io.element.android.appnav.loggedin.LoggedInPresenter$*"
|
||||
// Some options can't be tested at the moment
|
||||
excludes += "io.element.android.features.preferences.impl.developer.DeveloperSettingsPresenter$*"
|
||||
excludes += "*Presenter\$present\$*"
|
||||
}
|
||||
bound {
|
||||
minValue = 85
|
||||
counter = kotlinx.kover.api.CounterType.INSTRUCTION
|
||||
valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE
|
||||
}
|
||||
}
|
||||
// Rule to ensure that coverage of States is sufficient.
|
||||
rule {
|
||||
name = "Check code coverage of states"
|
||||
target = kotlinx.kover.api.VerificationTarget.CLASS
|
||||
overrideClassFilter {
|
||||
includes += "^*State$"
|
||||
excludes += "io.element.android.appnav.root.RootNavState*"
|
||||
excludes += "io.element.android.libraries.matrix.api.timeline.item.event.OtherState$*"
|
||||
excludes += "io.element.android.libraries.matrix.api.timeline.item.event.EventSendState$*"
|
||||
excludes += "io.element.android.libraries.matrix.api.room.RoomMembershipState*"
|
||||
excludes += "io.element.android.libraries.matrix.api.room.MatrixRoomMembersState*"
|
||||
excludes += "io.element.android.libraries.push.impl.notifications.NotificationState*"
|
||||
excludes += "io.element.android.features.messages.impl.media.local.pdf.PdfViewerState"
|
||||
excludes += "io.element.android.features.messages.impl.media.local.LocalMediaViewState"
|
||||
excludes += "io.element.android.features.location.impl.map.MapState*"
|
||||
excludes += "io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState*"
|
||||
excludes += "io.element.android.libraries.designsystem.swipe.SwipeableActionsState*"
|
||||
excludes += "io.element.android.features.messages.impl.timeline.components.ExpandableState*"
|
||||
excludes += "io.element.android.features.messages.impl.timeline.model.bubble.BubbleState*"
|
||||
excludes += "io.element.android.libraries.maplibre.compose.CameraPositionState*"
|
||||
excludes += "io.element.android.libraries.maplibre.compose.SaveableCameraPositionState"
|
||||
excludes += "io.element.android.libraries.maplibre.compose.SymbolState*"
|
||||
excludes += "io.element.android.features.ftue.api.state.*"
|
||||
excludes += "io.element.android.features.ftue.impl.welcome.state.*"
|
||||
}
|
||||
bound {
|
||||
minValue = 90
|
||||
counter = kotlinx.kover.api.CounterType.INSTRUCTION
|
||||
valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE
|
||||
}
|
||||
}
|
||||
// Rule to ensure that coverage of Views is sufficient (deactivated for now).
|
||||
rule {
|
||||
name = "Check code coverage of views"
|
||||
target = kotlinx.kover.api.VerificationTarget.CLASS
|
||||
overrideClassFilter {
|
||||
includes += "*ViewKt"
|
||||
}
|
||||
bound {
|
||||
// TODO Update this value, for now there are too many missing tests.
|
||||
minValue = 0
|
||||
counter = kotlinx.kover.api.CounterType.INSTRUCTION
|
||||
valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When running on the CI, run only debug test variants
|
||||
val ciBuildProperty = "ci-build"
|
||||
val isCiBuild = if (project.hasProperty(ciBuildProperty)) {
|
||||
val raw = project.property(ciBuildProperty) as? String
|
||||
raw?.toBooleanLenient() == true || raw?.toIntOrNull() == 1
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if (isCiBuild) {
|
||||
allprojects {
|
||||
afterEvaluate {
|
||||
tasks.withType<Test>().configureEach {
|
||||
extensions.configure<KoverTaskExtension> {
|
||||
val enabled = name.contains("debug", ignoreCase = true)
|
||||
isDisabled.set(!enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
apply(plugin = "org.jetbrains.kotlinx.kover")
|
||||
}
|
||||
|
||||
// Register quality check tasks.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue