diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml index d614b9c82..dc8453844 100644 --- a/.github/workflows/create-releases.yml +++ b/.github/workflows/create-releases.yml @@ -292,6 +292,9 @@ jobs: - name: Compile the openai-java-core project run: ./gradlew :openai-java-core:compileJava :openai-java-core:compileTestJava -x test + - name: Stop pre-GraalVM Gradle daemon + run: ./gradlew --stop + - name: Run the mock server run: ./scripts/mock --daemon @@ -462,6 +465,7 @@ jobs: ./gradlew publishAndReleaseToMavenCentral \ "${publish_exclusions[@]}" \ --stacktrace \ + --no-parallel \ --no-configuration-cache - name: Verify attested Maven artifacts diff --git a/buildSrc/src/test/kotlin/com/openai/gradle/GradleCacheTrustPolicyTest.kt b/buildSrc/src/test/kotlin/com/openai/gradle/GradleCacheTrustPolicyTest.kt index 8c4383023..d841de01a 100644 --- a/buildSrc/src/test/kotlin/com/openai/gradle/GradleCacheTrustPolicyTest.kt +++ b/buildSrc/src/test/kotlin/com/openai/gradle/GradleCacheTrustPolicyTest.kt @@ -227,6 +227,27 @@ class GradleCacheTrustPolicyTest { assertPublishingCachePolicy(workflow) } + @Test + fun `publishing releases obsolete daemons and serializes documentation generation`() { + val workflow = Path.of("../.github/workflows/create-releases.yml").readText() + assertPublishingRunnerStabilityPolicy(workflow) + + listOf( + workflow.replaceFirst( + " - name: Stop pre-GraalVM Gradle daemon\n" + + " run: ./gradlew --stop\n\n", + "", + ), + workflow.replaceFirst(" --no-parallel \\\n", ""), + ) + .forEach { poisonedWorkflow -> + assertTrue(poisonedWorkflow != workflow) + assertFailsWith { + assertPublishingRunnerStabilityPolicy(poisonedWorkflow) + } + } + } + @Test fun `publishing attests every released artifact before exposing signing secrets`() { val workflow = Path.of("../.github/workflows/create-releases.yml").readText() @@ -935,6 +956,33 @@ class GradleCacheTrustPolicyTest { assertPublishingProvenancePolicy(workflow) } + private fun assertPublishingRunnerStabilityPolicy(workflow: String) { + val publishSteps = parseWorkflow(workflow).job("publish").steps + val compilation = + publishSteps.indexOfFirst { it.name == "Compile the openai-java-core project" } + val daemonStop = publishSteps.indexOfFirst { it.name == "Stop pre-GraalVM Gradle daemon" } + val graalVm = publishSteps.indexOfFirst { it.name == "Set up GraalVM" } + + assertTrue( + compilation >= 0 && daemonStop > compilation && graalVm > daemonStop, + "Stop the build-JDK Gradle daemon before switching to GraalVM.", + ) + assertEquals("./gradlew --stop", publishSteps[daemonStop].run) + + val publication = + requireNotNull(publishSteps.single { it.name == "Publish to Maven Central" }.run) + val serializedInvocation = + "./gradlew publishAndReleaseToMavenCentral \\\n" + + " \"\${publish_exclusions[@]}\" \\\n" + + " --stacktrace \\\n" + + " --no-parallel \\\n" + + " --no-configuration-cache" + assertTrue( + publication.contains(serializedInvocation), + "Serialize Dokka publication tasks to keep the standard runner within memory limits.", + ) + } + private fun assertPublishingProvenancePolicy(workflow: String) { val parsedWorkflow = parseWorkflow(workflow) val publishJob = parsedWorkflow.job("publish")