Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove bootstrapAll task from service benchmarks project; move project inclusion logic to root settings.gradle.kts #1279

Merged
merged 1 commit into from
Apr 16, 2024
Merged
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
34 changes: 26 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,42 @@ include(":aws-runtime:aws-endpoint")
include(":aws-runtime:aws-http")
include(":services")
include(":tests")
include(":tests:benchmarks:service-benchmarks")
include(":tests:codegen:event-stream")
include(":tests:e2e-test-util")

// generated services
fun File.isServiceDir(): Boolean {
if (isDirectory) {
return toPath().resolve("build.gradle.kts").toFile().exists()
}
return false
}
val File.isServiceDir: Boolean
get() = isDirectory && toPath().resolve("build.gradle.kts").toFile().exists()

val String.isBootstrappedService: Boolean
get() = file("services/$this").isServiceDir

file("services").listFiles().forEach {
if (it.isServiceDir()) {
if (it.isServiceDir) {
include(":services:${it.name}")
}
}

// Service benchmarks project
val benchmarkServices = listOf(
// keep this list in sync with tests/benchmarks/service-benchmarks/build.gradle.kts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at a way to make this list sharable between settings.gradle.kts and build.gradle.kts, but couldn't find anything. I was hoping the by settings delegated property would work but it doesn't seem to be what we want here. https://docs.gradle.org/current/userguide/kotlin_dsl.html#project_properties


"s3",
"sns",
"sts",
"cloudwatch",
"cloudwatchevents",
"dynamodb",
"secretsmanager",
"iam",
)
if (benchmarkServices.all { it.isBootstrappedService }) {
include(":tests:benchmarks:service-benchmarks")
} else {
val missing = benchmarkServices.filterNot { it.isBootstrappedService }
logger.warn("Skipping :tests:benchmarks:service-benchmarks because these service(s) are not bootstrapped: $missing")
}

/**
* The following code enables to optionally include aws-sdk-kotlin dependencies in source form for easier
* development. By default, if `smithy-kotlin` exists as a directory at the same level as `aws-sdk-kotlin`
Expand Down
51 changes: 15 additions & 36 deletions tests/benchmarks/service-benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ application {
skipPublishing()

val requiredServices = setOf(
// keep this list in sync with <rootdir>/settings.gradle.kts

// Top 6 services called by Kotlin SDK customers as of 7/25/2023, in descending order of call volume,
// plus Secrets Manager which replaced Pinpoint after new API throttling limits broke our benchmark.
"s3",
Expand All @@ -31,48 +33,25 @@ val requiredServices = setOf(
"iam", // Create roles for STS::AssumeRole
)

val missingServices = requiredServices.filterNot { rootProject.file("services/$it/build.gradle.kts").exists() }

if (missingServices.isEmpty()) {
val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi")
val optinAnnotations = listOf("kotlin.RequiresOptIn", "aws.smithy.kotlin.runtime.InternalApi")

kotlin {
sourceSets {
all {
optinAnnotations.forEach { languageSettings.optIn(it) }
}
kotlin {
sourceSets {
all {
optinAnnotations.forEach { languageSettings.optIn(it) }
}

jvmMain {
dependencies {
api(libs.smithy.kotlin.runtime.core)
implementation(project(":aws-runtime:aws-core"))
implementation(libs.kotlinx.atomicfu)
implementation(libs.kotlinx.coroutines.core)
jvmMain {
dependencies {
api(libs.smithy.kotlin.runtime.core)
implementation(project(":aws-runtime:aws-core"))
implementation(libs.kotlinx.atomicfu)
implementation(libs.kotlinx.coroutines.core)

requiredServices.forEach { implementation(project(":services:$it")) }
}
requiredServices.forEach { implementation(project(":services:$it")) }
}
}
}
} else {
logger.warn(
"Skipping build for {} project, missing the following services: {}. To ensure this project builds, run the " +
"{}:bootstrapAll task.",
project.name,
missingServices.joinToString(", "),
project.path,
)

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
enabled = false
}
}

tasks.register("bootstrapAll") {
val bootstrapArg = requiredServices.joinToString(",") { "+$it" }
val bootstrapProj = project(":codegen:sdk")
bootstrapProj.ext.set("aws.services", bootstrapArg)
dependsOn(":codegen:sdk:bootstrap")
}

tasks.named<JavaExec>("run") {
Expand Down
Loading