From d41db5ad4a66b81a5492700cfbd1ca4b45fb56ff Mon Sep 17 00:00:00 2001 From: Per Nyfelt Date: Sun, 15 Nov 2026 19:37:07 +0100 Subject: [PATCH] Tighten non-upload evidence test and log ignored upload digests The :core:check case in nonUploadGraphsIgnoreExportedUploadEvidence never scheduled releaseAllGuard (check only depends on the guard when bundleAll wires staging), so it passed vacuously. Drop it and assert the guard ran in every case, on both the fresh and the configuration-cache reuse run; the bundleAll case also asserts that the staged :core:check ran. When a release-preparation graph schedules releaseAllGuard without releaseAll, log at info level that exported upload digests were not checked, to help diagnose CI jobs where evidence was set but not applied. Co-Authored-By: Claude Opus 5.5 --- README.md | 5 +++-- .../plugin/release/CombinedReleaseRegistrar.groovy | 8 ++++++++ .../gradle/plugin/release/ModuleReleaseTest.groovy | 11 +++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9b82927..0b99126 100644 --- a/README.md +++ b/README.md @@ -325,8 +325,9 @@ in existing-bundle mode: normal uploads rebuild and re-sign artifacts, so an ear digest generally cannot match. Digest properties also come from project/user `gradle.properties` and `ORG_GRADLE_PROJECT_*` environment variables; remove or clear them before a normal release. Upload evidence is ignored when `releaseAll` is absent from the -task graph, including plain checks, signing checks and bundle-only runs. Source/version -and saved manifest hashes are rechecked. +task graph, including plain checks, signing checks and bundle-only runs; when such a run +schedules `releaseAllGuard`, an info-level message (`--info`) says the evidence was not +checked. Source/version and saved manifest hashes are rechecked. The uploader hashes and parses the same manifest bytes, and sends a private ZIP snapshot checked against the verified digest. The bundle directory must be writable for snapshot diff --git a/src/main/groovy/se/alipsa/gradle/plugin/release/CombinedReleaseRegistrar.groovy b/src/main/groovy/se/alipsa/gradle/plugin/release/CombinedReleaseRegistrar.groovy index ca5deaf..af36271 100644 --- a/src/main/groovy/se/alipsa/gradle/plugin/release/CombinedReleaseRegistrar.groovy +++ b/src/main/groovy/se/alipsa/gradle/plugin/release/CombinedReleaseRegistrar.groovy @@ -77,7 +77,15 @@ final class CombinedReleaseRegistrar { String planPath = project.absoluteProjectPath('releaseAllPlan') String releasePath = project.absoluteProjectPath('releaseAll') String bundlePath = project.absoluteProjectPath('bundleAll') + String guardPath = project.absoluteProjectPath('releaseAllGuard') project.gradle.taskGraph.whenReady { TaskExecutionGraph graph -> + if (!graph.hasTask(releasePath) && graph.hasTask(guardPath)) { + // Only release-preparation graphs realize releaseAll for this diagnostic. + ReleaseAllTask release = releaseAllTask.get() + if (release.expectedBundleSha256.getOrElse('') || release.expectedManifestSha256.getOrElse('')) { + project.logger.info('Upload evidence ignored: releaseAll is not scheduled, so expectedBundleSha256 and expectedManifestSha256 are not checked') + } + } if (graph.hasTask(planPath) && graph.hasTask(releasePath)) { throw new GradleException('Do not request releaseAllPlan and releaseAll in the same invocation; review the saved manifest, then run :releaseAll separately') } diff --git a/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy b/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy index a250ae4..ebfcfb5 100644 --- a/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy +++ b/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Timeout import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource +import org.gradle.testkit.runner.TaskOutcome import java.util.zip.ZipFile import static org.junit.jupiter.api.Assertions.* @@ -707,16 +708,22 @@ nexusReleasePlugin { } @ParameterizedTest - @ValueSource(strings = ['bundleAll', 'releaseAllSigningCheck', 'releaseAllGuard', ':core:check']) + @ValueSource(strings = ['bundleAll', 'releaseAllSigningCheck', 'releaseAllGuard']) void nonUploadGraphsIgnoreExportedUploadEvidence(String task) { withServer { String base, List requests -> existingFixture(base) run('releaseAllPlan') - String[] args = ['-Pexisting', '-Pexpected=not-an-upload-digest', '-PexpectedManifest=not-a-manifest-digest'] + // Every case schedules the guard, so passing proves it ignored the malformed evidence. + String[] args = ['-Pexisting', '-Pexpected=not-an-upload-digest', '-PexpectedManifest=not-a-manifest-digest', '--info'] def first = run(task, *args) assertNull(first.task(':releaseAll')) + assertEquals(TaskOutcome.SUCCESS, first.task(':releaseAllGuard')?.outcome) + // bundleAll stages modules, whose check tasks depend on the guard. + if (task == 'bundleAll') assertEquals(TaskOutcome.SUCCESS, first.task(':core:check')?.outcome) + assertTrue(first.output.contains('Upload evidence ignored: releaseAll is not scheduled'), first.output) def cached = run(task, *args) assertNull(cached.task(':releaseAll')) + assertEquals(TaskOutcome.SUCCESS, cached.task(':releaseAllGuard')?.outcome) assertTrue(cached.output.contains('Reusing configuration cache.')) assertFalse(requests.any { it.contains('/publisher/upload') }) }