Skip to content

Commit

Permalink
Migrate "When running on the CI, run only debug test variants".
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Jan 9, 2024
1 parent 3b06576 commit 80c69e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
21 changes: 21 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.android.build.api.variant.FilterConfiguration.FilterType.ABI
import extension.allFeaturesImpl
import extension.allLibrariesImpl
import extension.allServicesImpl
import org.jetbrains.kotlin.cli.common.toBooleanLenient

plugins {
id("io.element.android-compose-application")
Expand Down Expand Up @@ -229,6 +230,26 @@ dependencies {
}
}

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
}

kover {
// When running on the CI, run only debug test variants
if (isCiBuild) {
excludeTests {
// Disable instrumentation for debug test tasks
tasks(
"testDebugUnitTest",
)
}
}
}

// https://kotlin.github.io/kotlinx-kover/
// Run `./gradlew :app:koverHtmlReport` to get report at ./app/build/reports/kover
// Run `./gradlew :app:koverXmlReport` to get XML report
Expand Down
24 changes: 0 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.google.devtools.ksp.gradle.KspTask
import org.apache.tools.ant.taskdefs.optional.ReplaceRegExp
import org.jetbrains.kotlin.cli.common.toBooleanLenient

buildscript {
dependencies {
Expand Down Expand Up @@ -166,29 +165,6 @@ allprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
}

// 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 {
/* TODO
extensions.configure<KoverTaskExtension> {
val enabled = name.contains("debug", ignoreCase = true)
disabledForProject.set(!enabled)
}
*/
}
}
}
}

// Register quality check tasks.
tasks.register("runQualityChecks") {
project.subprojects {
Expand Down

0 comments on commit 80c69e7

Please sign in to comment.