Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: gradle check
- name: gradle test
uses: ./.github/actions/build
with:
args: 'check compileIntegrationTestKotlin'
args: 'test compileIntegrationTestKotlin'
# artifact-name: 'Test reports (${{matrix.runner}})'
# path-to-upload: '**/build/reports/tests/**'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'Update examples'
on:
push:
tags: [ '*' ]
workflow_call:
workflow_dispatch:

defaults:
run:
Expand Down
12 changes: 11 additions & 1 deletion examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@file:Suppress("HasPlatformType")

plugins {
base
}

val exampleTestTasks = ArrayList<TaskProvider<*>>()

exampleTestTasks += tasks.register<Exec>("runExampleScript") {
Expand Down Expand Up @@ -32,8 +38,12 @@ exampleTestTasks += notebooks.map { notebook ->
}
}

tasks.register("runAll") {
val runAll = tasks.register("runAll") {
group = "Application"
description = "Runs everything in 'examples' directory"
dependsOn(exampleTestTasks)
}

tasks.named("check") {
dependsOn(runAll)
}
4 changes: 4 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ kotlin {
}
}

tasks.named("check") {
dependsOn("integrationTest")
}

java {
consistentResolution {
useRuntimeClasspathVersions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import kotlin.test.Test
class GradleEnterpriseApiIntegrationTest {

@Test
fun canFetchBuildsWithDefaultInstance() = runTest {
fun canFetchBuildsWithDefaultConfig() = runTest {
env = RealEnv
keychain = RealKeychain(RealSystemProperties)
val builds = GradleEnterpriseApi.buildsApi.getBuilds(since = 0, maxBuilds = 1)
val api = GradleEnterpriseApi.newInstance()
val builds = api.buildsApi.getBuilds(since = 0, maxBuilds = 1)
assertEquals(1, builds.size)
GradleEnterpriseApi.shutdown()
api.shutdown()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,22 @@ interface GradleEnterpriseApi {
* The default, companion instance of the Gradle Enterprise API client. See
* [GradleEnterpriseApi].
*/
companion object DefaultInstance : GradleEnterpriseApi by RealGradleEnterpriseApi() {
companion object {

/**
* Create a new instance of `GradleEnterpriseApi` with new options.
* Create a new instance of `GradleEnterpriseApi` with a custom `Config`.
*/
fun newInstance(config: Config): GradleEnterpriseApi {
fun newInstance(config: Config = Config()): GradleEnterpriseApi {
return RealGradleEnterpriseApi(config)
}
}

}

internal class RealGradleEnterpriseApi(
customConfig: Config? = null,
override val config: Config,
) : GradleEnterpriseApi {

override val config by lazy {
customConfig ?: Config()
}

private val okHttpClient by lazy {
buildOkHttpClient(config = config)
}
Expand Down