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

Bump GE API spec version to 2024.1 #172

Merged
merged 8 commits into from
Apr 4, 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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ dependencies {
## Usage

The [`GradleEnterpriseApi`][9] interface represents the Gradle Enterprise REST API. It contains
the 6 APIs exactly as listed in the [REST API Manual][5]:
all the APIs exactly as listed in the [REST API Manual][5]:

```kotlin
interface GradleEnterpriseApi {
val buildsApi: BuildsApi
val buildCacheApi: BuildCacheApi
val projectsApi: projectsApi
val testsApi: TestsApi
val buildCacheApi: BuildCacheApi
val projectsApi: ProjectsApi
val metaApi: MetaApi
val testDistributionApi: TestDistributionApi
val authApi: AuthApi
// ...
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ plugins {
val localSpecPath = providers.gradleProperty("localSpecPath")
val remoteSpecUrl = providers.gradleProperty("remoteSpecUrl").orElse(
providers.gradleProperty("gradle.enterprise.version").map { geVersion ->
val specName = "gradle-enterprise-$geVersion-api.yaml"
val majorVersion = geVersion.substringBefore('.').toInt()
val specName = when {
majorVersion <= 2023 -> "gradle-enterprise-$geVersion-api.yaml"
else -> "develocity-$geVersion-api.yaml"
}
"https://docs.gradle.com/enterprise/api-manual/ref/$specName"
}
)
Expand Down Expand Up @@ -47,6 +51,7 @@ openApiGenerate {
invokerPackage.set("com.gabrielfeo.gradle.enterprise.api.internal")
additionalProperties.put("library", "jvm-retrofit2")
additionalProperties.put("useCoroutines", true)
cleanupOutput.set(true)
}

val postProcessGeneratedApi by tasks.registering(PostProcessGeneratedApi::class) {
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
group=com.gabrielfeo
artifact=gradle-enterprise-api-kotlin
version=2023.4.0
gradle.enterprise.version=2023.4
version=2024.1.0
gradle.enterprise.version=2024.1
org.gradle.jvmargs=-Xmx5g
org.gradle.caching=true
# Becomes default in Gradle 9.0
org.gradle.kotlin.dsl.skipMetadataVersionCheck=false
systemProp.scan.capture-build-logging=false
systemProp.scan.capture-test-logging=false
1 change: 0 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ tasks.named<Jar>("javadocJar") {
}

tasks.named<Test>("integrationTest") {
jvmArgs("-Xmx512m")
environment("GRADLE_ENTERPRISE_API_LOG_LEVEL", "DEBUG")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,32 @@ class BuildsApiExtensionsIntegrationTest {
}

@Test
fun getBuildsFlowPreservesParamsAcrossRequests() = runTest(timeout = 3.minutes) {
fun getBuildsFlowPreservesParamsAcrossRequests() = runTest(timeout = 6.minutes) {
api.buildsApi.getBuildsFlow(
since = 0,
query = "user:*",
models = listOf(BuildModelName.gradleAttributes),
allModels = true,
reverse = true,
).take(2000).collect()
buildsPerPage = 2,
).take(4).collect()
recorder.requests.forEach {
assertUrlParam(it, "query", "user:*")
assertUrlParam(it, "models", "gradle-attributes")
assertUrlParam(it, "allModels", "true")
assertUrlParam(it, "reverse", "true")
}
}

@Test
fun getBuildsFlowReplacesSinceForFromBuildAfterFirstRequest() = runTest {
api.buildsApi.getBuildsFlow(since = 1).take(2000).collect()
api.buildsApi.getBuildsFlow(since = 1, buildsPerPage = 2).take(10).collect()
assertReplacedForFromBuildAfterFirstRequest(param = "since" to "1")
}

@Test
fun getBuildsFlowReplacesFromInstantForFromBuildAfterFirstRequest() = runTest {
api.buildsApi.getBuildsFlow(fromInstant = 1).take(2000).collect()
api.buildsApi.getBuildsFlow(fromInstant = 1, buildsPerPage = 2).take(10).collect()
assertReplacedForFromBuildAfterFirstRequest(param = "fromInstant" to "1")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import retrofit2.create
*/
interface GradleEnterpriseApi {

val authApi: AuthApi
val buildsApi: BuildsApi
val buildCacheApi: BuildCacheApi
val projectsApi: ProjectsApi
Expand Down Expand Up @@ -79,6 +80,7 @@ internal class RealGradleEnterpriseApi(
)
}

override val authApi: AuthApi by lazy { retrofit.create() }
override val buildsApi: BuildsApi by lazy { retrofit.create() }
override val buildCacheApi: BuildCacheApi by lazy { retrofit.create() }
override val projectsApi: ProjectsApi by lazy { retrofit.create() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun BuildsApi.getBuildsFlow(
maxWaitSecs: Int? = null,
buildsPerPage: Int = API_MAX_BUILDS,
models: List<BuildModelName>? = null,
allModels: Boolean? = false,
): Flow<Build> {
return flow {
var builds = getBuilds(
Expand All @@ -45,6 +46,7 @@ fun BuildsApi.getBuildsFlow(
maxWaitSecs = maxWaitSecs,
maxBuilds = buildsPerPage,
models = models,
allModels = allModels,
)
emitAll(builds.asFlow())
while (builds.isNotEmpty()) {
Expand All @@ -55,6 +57,7 @@ fun BuildsApi.getBuildsFlow(
maxWaitSecs = maxWaitSecs,
maxBuilds = buildsPerPage,
models = models,
allModels = allModels,
)
emitAll(builds.asFlow())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FakeBuildsApi(
maxWaitSecs: Int?,
query: String?,
models: List<BuildModelName>?,
allModels: Boolean?,
): List<Build> {
getBuildsCallCount.value++
check((reverse ?: maxWaitSecs ?: query ?: models) == null) { "Not supported" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface FakeBuildsApiScaffold : BuildsApi {
override suspend fun getBuild(
id: String,
models: List<BuildModelName>?,
allModels: Boolean?,
availabilityWaitTimeoutSecs: Int?,
): Build {
TODO("Not yet implemented")
Expand All @@ -27,49 +28,45 @@ interface FakeBuildsApiScaffold : BuildsApi {
maxWaitSecs: Int?,
query: String?,
models: List<BuildModelName>?,
allModels: Boolean?,
): List<Build> {
TODO("Not yet implemented")
}

override suspend fun getGradleNetworkActivity(
override suspend fun getGradleArtifactTransformExecutions(
id: String,
availabilityWaitTimeoutSecs: Int?,
): GradleNetworkActivity {
): GradleArtifactTransformExecutions {
TODO("Not yet implemented")
}

override suspend fun getMavenDependencyResolution(
id: String,
availabilityWaitTimeoutSecs: Int?,
): MavenDependencyResolution {
override suspend fun getGradleAttributes(id: String, availabilityWaitTimeoutSecs: Int?): GradleAttributes {
TODO("Not yet implemented")
}

override suspend fun getGradleAttributes(
override suspend fun getGradleBuildCachePerformance(
id: String,
availabilityWaitTimeoutSecs: Int?,
): GradleAttributes {
): GradleBuildCachePerformance {
TODO("Not yet implemented")
}

override suspend fun getGradleBuildCachePerformance(
id: String,
availabilityWaitTimeoutSecs: Int?,
): GradleBuildCachePerformance {
override suspend fun getGradleDeprecations(id: String, availabilityWaitTimeoutSecs: Int?): GradleDeprecations {
TODO("Not yet implemented")
}

override suspend fun getGradleProjects(
override suspend fun getGradleNetworkActivity(
id: String,
availabilityWaitTimeoutSecs: Int?,
): List<GradleProject> {
): GradleNetworkActivity {
TODO("Not yet implemented")
}

override suspend fun getMavenAttributes(
id: String,
availabilityWaitTimeoutSecs: Int?,
): MavenAttributes {
override suspend fun getGradleProjects(id: String, availabilityWaitTimeoutSecs: Int?): List<GradleProject> {
TODO("Not yet implemented")
}

override suspend fun getMavenAttributes(id: String, availabilityWaitTimeoutSecs: Int?): MavenAttributes {
TODO("Not yet implemented")
}

Expand All @@ -80,10 +77,14 @@ interface FakeBuildsApiScaffold : BuildsApi {
TODO("Not yet implemented")
}

override suspend fun getMavenModules(
override suspend fun getMavenDependencyResolution(
id: String,
availabilityWaitTimeoutSecs: Int?,
): List<MavenModule> {
): MavenDependencyResolution {
TODO("Not yet implemented")
}

override suspend fun getMavenModules(id: String, availabilityWaitTimeoutSecs: Int?): List<MavenModule> {
TODO("Not yet implemented")
}
}
Loading