Skip to content
Closed
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: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ dependencies {

tasks.test {
useJUnitPlatform()
workingDir(layout.projectDirectory)
inputs
.file(layout.projectDirectory.file("../scripts/detect-breaking-changes"))
.withPathSensitivity(PathSensitivity.RELATIVE)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.openai.gradle

import java.nio.file.Path
import kotlin.io.path.readText
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertFalse

class ApiCompatibilityCachePolicyTest {
@Test
fun `compatibility compilation always executes while production caching stays enabled`() {
val detector = Path.of("../scripts/detect-breaking-changes").readText()

assertFalse(
detector.contains("--no-build-cache"),
"The API compatibility detector must leave the build cache enabled for production compilation.",
)
assertContains(detector, "compileExternalApiCompatibilityKotlin")
assertContains(detector, "compileProposedApiCompatibilityKotlin")
assertContains(detector, "project.tasks.named(taskName).configure")
assertContains(detector, "task.outputs.upToDateWhen { false }")
assertContains(detector, "task.outputs.doNotCacheIf")
}
}
15 changes: 13 additions & 2 deletions scripts/detect-breaking-changes
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ gradle.beforeProject { project ->
System.getenv("PROPOSED_FIXTURE_SOURCE_ROOT"),
System.getenv("PROPOSED_DEPENDENCIES_FILE")
)

[
"compileExternalApiCompatibilityKotlin",
"compileProposedApiCompatibilityKotlin"
].each { taskName ->
project.tasks.named(taskName).configure { task ->
task.outputs.upToDateWhen { false }
task.outputs.doNotCacheIf(
"API compatibility compilation must always execute"
) { true }
}
}
}
}
}
Expand All @@ -305,8 +317,7 @@ GENERATED_TEST_SOURCE_ROOT="${GENERATED_TEST_SOURCE_ROOT}" \
./scripts/gradle \
--init-script "${COMPATIBILITY_INIT_SCRIPT}" \
:openai-java-core:compileExternalApiCompatibilityKotlin \
:openai-java-core:compileProposedApiCompatibilityKotlin \
--no-build-cache
:openai-java-core:compileProposedApiCompatibilityKotlin

validate_public_api_signatures() {
local manifest_path="$1"
Expand Down
Loading