Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Nov 1, 2023
1 parent c08b7ae commit a8e53e0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 51 deletions.
91 changes: 49 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,70 @@ plugins {
val publishedIncludedBuilds = listOf("runner-cli", "runner-gradle-classic", "runner-maven")
val gradlePluginIncludedBuilds = listOf("runner-gradle-classic")

addDependencyOnSameTaskOfIncludedBuilds("assemble")
addDependencyOnSameTaskOfIncludedBuilds("build")
addDependencyOnSameTaskOfIncludedBuilds("clean")
addDependencyOnSameTaskOfIncludedBuilds("check")
addDependencyOnSameTasksOfIncludedBuilds("assemble", "build", "clean", "check")

registerParentTaskOfIncludedBuilds("test", groupName = "verification")

registerParentTaskOfPublishedIncludedBuilds("apiCheck", groupName = "verification")
registerParentTaskOfPublishedIncludedBuilds("apiDump", groupName = "other")
registerParentGroupTasks("publishing", taskNames = listOf(
"publishAllPublicationsToMavenCentralRepository",
"publishAllPublicationsToProjectLocalRepository",
"publishAllPublicationsToSnapshotRepository",
"publishAllPublicationsToSpaceDevRepository",
"publishAllPublicationsToSpaceTestRepository",
"publishToMavenLocal"
)) {
it.name in publishedIncludedBuilds
}

registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToMavenCentralRepository", groupName = "publication")
registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToProjectLocalRepository", groupName = "publication")
registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSnapshotRepository", groupName = "publication")
registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSpaceDevRepository", groupName = "publication")
registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSpaceTestRepository", groupName = "publication")
registerParentTaskOfPublishedIncludedBuilds("publishToMavenLocal", groupName = "publication")
registerParentGroupTasks("verification", taskNames = listOf(
"test",
"apiCheck",
"apiDump"
))

registerParentTaskOfGradlePluginIncludedBuilds("publishPlugins", groupName = "publication")
registerParentTaskOfGradlePluginIncludedBuilds("validatePlugins", groupName = "plugin development")
registerParentGroupTasks("gradle plugin", taskNames = listOf(
"publishPlugins",
"validatePlugins"
)) {
it.name in gradlePluginIncludedBuilds
}

tasks.register("integrationTest") {
group = "verification"
description = "Runs integration tests of this project. Might take a while and require additional setup."
dependsOn(gradle.includedBuilds.single { it.name == "dokka-integration-tests" }.task(":integrationTest"))
}

fun addDependencyOnSameTaskOfIncludedBuilds(existingTaskName: String, filter: (IncludedBuild) -> Boolean = { true }) {
tasks.named(existingTaskName) {
dependsOn(includedBuildTasks(existingTaskName, filter))
}
dependsOn(includedBuildTasks("integrationTest") {
it.name == "dokka-integration-tests"
})
}

fun registerParentTaskOfPublishedIncludedBuilds(
taskName: String,
groupName: String
) = registerParentTaskOfIncludedBuilds(taskName, groupName) {
it.name in publishedIncludedBuilds
}

fun registerParentTaskOfGradlePluginIncludedBuilds(
taskName: String,
groupName: String
) = registerParentTaskOfIncludedBuilds(taskName, groupName) {
it.name in gradlePluginIncludedBuilds
fun addDependencyOnSameTasksOfIncludedBuilds(vararg taskNames: String) {
taskNames.forEach { taskName ->
tasks.named(taskName) {
dependsOn(includedBuildTasks(taskName))
}
}
}

fun registerParentTaskOfIncludedBuilds(
taskName: String,
fun registerParentGroupTasks(
groupName: String,
filter: (IncludedBuild) -> Boolean = { true }
) {
taskNames: List<String>,
includedBuildFilter: (IncludedBuild) -> Boolean = { true }
) = taskNames.forEach { taskName ->
tasks.register(taskName) {
group = groupName
description = "Runs $taskName tasks of included builds"
dependsOn(includedBuildTasks(taskName, filter))
description = "A parent task that calls tasks with the same name in all subprojects and included builds"

dependsOn(subprojectTasks(taskName), includedBuildTasks(taskName, includedBuildFilter))
}
}

fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean): List<TaskReference> =
gradle.includedBuilds.filter { it.name != "build-logic" }.filter(filter).map { it.task(":$taskName") }
fun subprojectTasks(taskName: String): List<String> =
subprojects
.filter { it.getTasksByName(taskName, false).isNotEmpty() }
.map { ":${it.path}:$taskName" }


fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean = { true }): List<TaskReference> =
gradle.includedBuilds
.filter { it.name != "build-logic" }
.filter(filter)
.mapNotNull { it.task(":$taskName") }
8 changes: 2 additions & 6 deletions dokka-integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ dependencies {
implementation(libs.jsoup)
}

val dokkaSubprojects = gradle.includedBuild("dokka")
val gradlePluginClassic = gradle.includedBuild("runner-gradle-classic")
val aggregatingProject = gradle.includedBuild("dokka")

tasks.integrationTest {
dependsOn(
dokkaSubprojects.task(":publishToMavenLocal"),
gradlePluginClassic.task(":publishToMavenLocal"),
)
dependsOn(aggregatingProject.task(":publishToMavenLocal"))

environment("DOKKA_VERSION", project.version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ index 3d9431be0..b60114bc2 100644
html_version=0.7.2
lincheck_version=2.18.1
-dokka_version=1.8.10
+dokka_version=1.9.20-SNAPSHOT
+dokka_version=non-existing-sanity-check
byte_buddy_version=1.10.9
reactor_version=3.4.1
reactive_streams_version=1.0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest()
.withTestKitDir(File("build", "gradle-test-kit").absoluteFile)
.withArguments(
listOfNotNull(
"-Pkotlin_version=${buildVersions.kotlinVersion}",
"-Pdokka_it_kotlin_version=${buildVersions.kotlinVersion}",
buildVersions.androidGradlePluginVersion?.let { androidVersion ->
"-Pdokka_it_android_gradle_plugin_version=$androidVersion"
Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/maven/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ tasks.integrationTest {
val mvn = mavenCliSetup.mvn
inputs.file(mvn)

environment("DOKKA_VERSION", project.version)

doFirst("workaround for https://github.com/gradle/gradle/issues/24267") {
environment("DOKKA_VERSION", project.version)
environment("MVN_BINARY_PATH", mvn.get().asFile.invariantSeparatorsPath)
}
}

0 comments on commit a8e53e0

Please sign in to comment.