From 58d243468bd6f8feda4b683eab54fe0ab89764f1 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 02:57:47 +0900 Subject: [PATCH 1/3] =?UTF-8?q?build(java-conventions):=20=EC=BB=A4?= =?UTF-8?q?=EB=B0=8B=20id=EB=A7=8C=20=EB=8B=A4=EB=A5=B8=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=EA=B0=80=20=EC=8B=9C=ED=97=98=EC=9D=84=20=EC=BA=90?= =?UTF-8?q?=EC=8B=9C=EC=97=90=EC=84=9C=20=EB=B0=9B=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: app-bootstrap의 bootBuildInfo가 main 자원에 쓰는 META-INF/build-info.properties에 build.revision(커밋 id)이 들어간다. 그 자원을 classpath로 받는 :app-bootstrap:test·architectureTest· checkstyleTest의 입력 지문이 커밋마다 바뀌어, main이 채운 캐시가 있어도 PR마다 다시 돈다(캐시가 찬 PR run 355의 :prCheck 94초 중 48초). jar manifest의 Build-Revision은 이미 runtime classpath 정규화로 뺐는데 build-info는 남아 있었다. 고친 것: ca.java-conventions의 runtime classpath 정규화에 properties("META-INF/build-info.properties")의 build.revision 무시를 더한다. 입력 지문만 바뀌고 bootJar와 /actuator/info의 값은 그대로다. build-logic 시험 둘을 더한다: build.revision만 바뀌면 classpath를 읽는 태스크가 UP-TO-DATE이고, build.version이 바뀌면 다시 돈다. 옆 manifest 주석의 「두 값 모두 커밋마다 바뀐다」도 바로잡는다(Implementation-Version은 commit id 유무로만 바뀐다). docs/build.md에 같은 내용을 적는다. 버린 것: - revision을 release 단계에서만 넣기: PR·main 빌드의 /actuator/info에서 revision이 빠진다. - bootBuildInfo 출력을 bootJar에만 넣기: 로컬 bootRun에 build-info가 없다. - app build.gradle에 정규화 한 줄: 같은 일을 하는 manifest 정규화가 ca.java-conventions에 있어 한곳에 둔다. 위험·한계: build.revision을 읽어 단언하는 시험이 생기면 낡은 결과를 다시 쓴다(지금 0건). 정규화는 모든 Java leaf에 걸리지만 그 파일은 app-bootstrap에만 있다. 검증(desktop, 트리 9a5d3e0d = 이 PR의 세 커밋): - 같은 트리에서 GITHUB_SHA만 바꿔 :prCheck 두 번: 둘째에 다시 돈 Test 태스크는 :app-bootstrap:systemTest 하나(늘 도는 SYSTEM lane). test·architectureTest·checkstyleMain·checkstyleTest· repositoryContractTest는 UP-TO-DATE. 기준 1d6fd34c는 test· architectureTest·checkstyleTest·repositoryContractTest·systemTest가 다시 돌았다. - 변이: 정규화 블록을 지우면 aNewCommitIdInBuildInfoLeavesA RuntimeClasspathReaderUpToDate가 실패한다(8개 중 1개 실패). - GITHUB_SHA를 준 :app-bootstrap:bootJar의 build-info.properties에 build.revision=444444444444가 있다. - -p build-logic check javadoc rc=0. Refs: design-docs ci/05-backend-ci-speed-handoff.md 4.2·6.2·7.2절 (BE-6) --- .../java/JavaConventionsPlugin.java | 17 ++++- .../PlatformModuleConventionTest.java | 64 +++++++++++++++++++ docs/build.md | 6 ++ src/bootstrap/app/build.gradle | 4 +- 4 files changed, 87 insertions(+), 4 deletions(-) diff --git a/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java b/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java index bf404d4c..07417e24 100644 --- a/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java +++ b/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java @@ -115,9 +115,10 @@ public final class JavaConventionsPlugin implements Plugin { "Implementation-Version", project.getVersion().toString(), "Build-Revision", buildRevision))); - // Both attributes change on every commit, and every test and SpotBugs task has this jar on its - // runtime classpath: without the normalization a CI build never reuses a cached test result - // (review O-4c). They describe the build, not the classes, so a runtime classpath ignores them. + // Build-Revision changes on every commit, and Implementation-Version whenever a build has a + // commit id or not (`-SNAPSHOT`). Every test and SpotBugs task has this jar on its runtime + // classpath: without the normalization a CI build never reuses a cached test result (review + // O-4c). They describe the build, not the classes, so a runtime classpath ignores them. project .getNormalization() .getRuntimeClasspath() @@ -126,6 +127,16 @@ public final class JavaConventionsPlugin implements Plugin { metaInf.ignoreAttribute("Implementation-Version"); metaInf.ignoreAttribute("Build-Revision"); }); + // The same commit id is `build.revision` in the build-info.properties that Spring Boot's + // bootBuildInfo writes into app-bootstrap's main resources, and that leaf's test, architecture + // and Checkstyle tasks have those resources on their classpath: without this every commit reran + // them. It is ignored only as an input; bootJar and /actuator/info still carry the value. + project + .getNormalization() + .getRuntimeClasspath() + .properties( + "META-INF/build-info.properties", + buildInfo -> buildInfo.ignoreProperty("build.revision")); project .getTasks() diff --git a/build-logic/src/test/java/dev/caskeleton/buildlogic/convention/PlatformModuleConventionTest.java b/build-logic/src/test/java/dev/caskeleton/buildlogic/convention/PlatformModuleConventionTest.java index 6911d241..435ee5c1 100644 --- a/build-logic/src/test/java/dev/caskeleton/buildlogic/convention/PlatformModuleConventionTest.java +++ b/build-logic/src/test/java/dev/caskeleton/buildlogic/convention/PlatformModuleConventionTest.java @@ -1,11 +1,14 @@ package dev.caskeleton.buildlogic.convention; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Files; import java.nio.file.Path; import org.gradle.testkit.runner.BuildResult; +import org.gradle.testkit.runner.BuildTask; import org.gradle.testkit.runner.GradleRunner; +import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -145,6 +148,67 @@ class PlatformModuleConventionTest { assertTrue(result.getOutput().contains("pinned=2.0.1 unpinned=null"), result.getOutput()); } + @Test + void aNewCommitIdInBuildInfoLeavesARuntimeClasspathReaderUpToDate() throws Exception { + // given: the reader has run once against one commit's build-info.properties. + runtimeClasspathReaderBuild(); + writeBuildInfo("111111111111", "0.0.1"); + runner("readRuntimeClasspath").build(); + writeBuildInfo("222222222222", "0.0.1"); + + // when + BuildResult result = runner("readRuntimeClasspath").build(); + + // then + assertEquals( + TaskOutcome.UP_TO_DATE, outcome(result, ":readRuntimeClasspath"), result.getOutput()); + } + + @Test + void anotherBuildInfoPropertyStillMakesARuntimeClasspathReaderRunAgain() throws Exception { + // given: the reader has run once; then the version changes and the commit id does not. + runtimeClasspathReaderBuild(); + writeBuildInfo("111111111111", "0.0.1"); + runner("readRuntimeClasspath").build(); + writeBuildInfo("111111111111", "0.0.2"); + + // when + BuildResult result = runner("readRuntimeClasspath").build(); + + // then + assertEquals(TaskOutcome.SUCCESS, outcome(result, ":readRuntimeClasspath"), result.getOutput()); + } + + /** + * A task that takes the main resources as a runtime classpath, the way a Test or Checkstyle task + * takes app-bootstrap's main output, which holds the build-info.properties bootBuildInfo writes. + */ + private void runtimeClasspathReaderBuild() throws Exception { + buildFile( + """ + plugins { id 'ca.platform-module' } + def marker = layout.buildDirectory.file('runtime-classpath-read.txt') + tasks.register('readRuntimeClasspath') { + inputs.files(tasks.named('processResources')) + .withNormalizer(ClasspathNormalizer) + .withPropertyName('classpath') + outputs.file(marker).withPropertyName('marker') + doLast { marker.get().asFile.text = 'read' } + } + """); + } + + private void writeBuildInfo(String revision, String version) throws Exception { + Path file = projectDir.resolve("src/main/resources/META-INF/build-info.properties"); + Files.createDirectories(file.getParent()); + Files.writeString(file, "build.revision=" + revision + "\nbuild.version=" + version + "\n"); + } + + private static TaskOutcome outcome(BuildResult result, String path) { + BuildTask task = result.task(path); + return task == null ? null : task.getOutcome(); + } + private void writeCatalog() throws Exception { Files.writeString( projectDir.resolve("gradle/libs.versions.toml"), diff --git a/docs/build.md b/docs/build.md index 2ef377d7..e83d983e 100644 --- a/docs/build.md +++ b/docs/build.md @@ -66,6 +66,12 @@ env 계약이고 `.env`는 로컬 실행 입력이다. `verifyEnvKeys`는 exampl `META-INF/build-info.properties`(`build.revision`)에 남긴다. 예전에는 version이 `..+`라 커밋마다 새 jar 이름이 생겼고 그 잔여물을 `ca.archive-hygiene`이 치웠는데, 둘 다 없앴다(리뷰 BUILD-O3-5). +- runtime classpath 입력에서는 빌드를 설명하는 값을 뺀다(`ca.java-conventions`의 정규화). + manifest의 `Build-Revision`(커밋 id)과 `Implementation-Version`(revision이 없으면 `-SNAPSHOT`이 + 붙는 버전), `build-info.properties`의 `build.revision`이다. 그래서 캐시를 쓰는 태스크(TEST· + ARCHITECTURE lane 등)는 커밋 id만 다른 빌드에서 캐시의 결과를 받는다. 매번 다시 도는 lane은 + `build-logic/AGENTS.md` 「lane 캐시와 성능 lane」이 정한다. jar와 실행 중 `/actuator/info`의 값은 + 그대로다. - `releaseCheck`가 실행하는 `verifyReleaseProvenance`(루트 `build.gradle`, revision 판정은 `ca.java-conventions`와 같은 함수)는 source revision이 없으면 실패하므로 추적 불가능한 산출물을 release로 취급할 수 없다. 예전 `ca.release-provenance` 플러그인은 없앴다(리뷰 BUILD-O3-5). diff --git a/src/bootstrap/app/build.gradle b/src/bootstrap/app/build.gradle index 3a451cea..296bb0a0 100644 --- a/src/bootstrap/app/build.gradle +++ b/src/bootstrap/app/build.gradle @@ -435,7 +435,9 @@ bootJar { // The deployable artifact names the release and the commit it was built from in // META-INF/build-info.properties (review BUILD-O3-5: provenance through Spring Boot's build info // rather than a revision in every leaf's jar name). `time` is excluded so an unchanged commit still -// produces an unchanged resource and cached tasks stay cached. +// produces an unchanged resource. The revision does change it on every commit; ca.java-conventions +// leaves `build.revision` out of every runtime classpath input, so the tests and checks that have +// these resources on their classpath stay cached. springBoot { buildInfo { excludes = ['time'] -- 2.54.0 From 7c0521421b9d0e9bc435d7b458344d45612a43e0 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 02:57:48 +0900 Subject: [PATCH 2/3] =?UTF-8?q?build(build-logic):=20-p=20build-logic=20?= =?UTF-8?q?=EC=8B=9C=ED=97=98=EC=9D=B4=20=EB=B9=8C=EB=93=9C=20=EC=BA=90?= =?UTF-8?q?=EC=8B=9C=EB=A5=BC=20=EC=93=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: main.yml build-logic job과 scripts/verify.sh main은 ./gradlew -p build-logic test로 돈다. 그러면 build-logic이 루트 빌드라 저장소 루트 gradle.properties의 org.gradle.caching=true가 걸리지 않고, TestKit 시험이 push마다 전부 다시 돈다(run 356: 6 executed, :test 30초). 고친 것: build-logic/gradle.properties에 org.gradle.caching=true를 둔다. build-logic/AGENTS.md 테스트 절에 그 이유와 「시험이 저장소 파일을 읽게 되면 test 입력으로 선언한다」를 한 줄로 적는다. 버린 것: - job 줄에 --build-cache: CI만 캐시를 쓰고 desktop·노트북은 다르게 돈다. - main job Gradle 줄에 :build-logic:test 붙이기: verifyStrictLaneStages의 줄 형식 검사를 고쳐야 한다. 위험·한계: TestKit 시험이 선언 안 된 저장소 파일을 읽으면 캐시가 낡은 결과를 낸다. 지금은 없다: build-logic/src/test의 시험은 모두 @TempDir에 fixture를 쓴다. 환경 변수는 Test 입력이 아니다. RELEASE_VERSION이 비어 있어야 통과하는 시험이 하나 있지만(PlatformModuleConventionTest) main.yml과 verify.sh는 그 값을 주지 않는다. 검증(desktop): -p build-logic test → clean → test에서 둘째가 :compileJava·:test FROM-CACHE(3 from cache). 기준 1d6fd34c는 6 executed. main 클래스 하나의 줄 번호를 밀면 :test가 다시 돈다. Refs: design-docs ci/05-backend-ci-speed-handoff.md 4.4·6.3·7.2절 (BE-8) --- build-logic/AGENTS.md | 1 + build-logic/gradle.properties | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 build-logic/gradle.properties diff --git a/build-logic/AGENTS.md b/build-logic/AGENTS.md index ebaa148e..2abbf61a 100644 --- a/build-logic/AGENTS.md +++ b/build-logic/AGENTS.md @@ -38,3 +38,4 @@ registry, settings, build-logic, 루트 라이프사이클이 정하는 것을 ## 테스트 - `./gradlew -p build-logic test --console=plain`(저장소 루트에서). build-logic은 Spotless 대상이 아니다. 편집 훅도 이 폴더의 Java를 포맷하지 않는다. +- `-p build-logic`으로 돌면 저장소 루트 `gradle.properties`가 걸리지 않는다. 빌드 캐시는 `build-logic/gradle.properties`가 켠다. 그래서 시험은 입력이 같으면 캐시에서 온다. 시험의 fixture는 모두 `@TempDir`에 쓴다. 시험이 저장소 파일을 읽게 되면 그 파일을 `test` 입력으로 선언한다. diff --git a/build-logic/gradle.properties b/build-logic/gradle.properties new file mode 100644 index 00000000..80dcf391 --- /dev/null +++ b/build-logic/gradle.properties @@ -0,0 +1,5 @@ +# Read only when build-logic is the build being run (`./gradlew -p build-logic test`, main.yml's +# `build-logic` job). Then the repository root's gradle.properties is not, and without this line the +# TestKit tests ran from scratch on every push. When the main build includes build-logic, the root's +# settings apply and they enable the same cache. +org.gradle.caching=true -- 2.54.0 From 72268f3028c83f6933dcc5e9d9bfca33b1d968e7 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 03:17:09 +0900 Subject: [PATCH 3/3] =?UTF-8?q?build(app-bootstrap):=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EC=86=8C=20=EA=B3=84=EC=95=BD=20=EC=8B=9C=ED=97=98=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EC=97=90=EC=84=9C=20python=20=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=EC=BD=94=EB=93=9C=EB=A5=BC=20=EB=BA=80=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: repositoryContractTest의 입력에 scripts/**가 있다. 같은 :prCheck 안의 루트 testDocumentChecks(python3 -m unittest)가 scripts/ 아래 __pycache__/*.pyc를 쓴다. 그래서 지문을 딴 뒤 생긴 파일 때문에 같은 트리의 다음 실행이 다시 돈다(desktop --info: 「scripts/__pycache__/…pyc has been added」). .pyc에는 원본 수정 시각이 들어 새 checkout마다 내용도 다르다. runner PR run 339~386은 캐시가 찬 run(345·355)에서도 이 lane을 실행했다. 고친 것: repositoryContractExcludes에 **/__pycache__/**와 **/*.pyc를 더한다. git이 무시하는 파일이라 추적 파일은 하나도 빠지지 않는다. 이 목록을 같이 쓰는 documentContract·architectureTest·publicPathSnapshot 입력은 .pyc를 포함하지 않았다. 버린 것: testDocumentChecks에 python3 -B. 노트북 verify.sh docs나 손으로 돈 python이 worktree에 남긴 .pyc는 못 막는다. 위험·한계: 이 lane이 .pyc를 읽는 계약은 없다(src 아래 시험에 pyc· __pycache__ 0건). 검증(desktop, 트리 9a5d3e0d): GITHUB_SHA만 바꾼 둘째 :prCheck --info에서 repositoryContractTest UP-TO-DATE(바뀐 입력 줄 0). 첫 실행 뒤 scripts 아래 .pyc 16개. - scripts/verify.sh pr --no-cache rc=0: :prCheck 6분, 530 executed· FROM-CACHE 0, 시험 7269(실패 0, 건너뜀 35). - scripts/verify.sh main --no-cache rc=0: 바깥 빌드 19분 5초 446 executed· from cache 0, -p build-logic test, 설정 캐시 검사. 시험 1977(실패 0, 건너뜀 19). Refs: design-docs ci/05-backend-ci-speed-handoff.md 7.2절 (BE-6 완료 기준 1) --- src/bootstrap/app/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/app/build.gradle b/src/bootstrap/app/build.gradle index 296bb0a0..d518cf32 100644 --- a/src/bootstrap/app/build.gradle +++ b/src/bootstrap/app/build.gradle @@ -342,7 +342,11 @@ dependencies { // capture ban — that must stop a merge, not be found after one. def repositoryRootForContractTests = rootProject.projectDir // Other checkouts of this repository that a developer machine keeps under .claude/worktrees are not inputs. -def repositoryContractExcludes = ['**/build/**', '**/.gradle/**', '**/node_modules/**', '.claude/worktrees/**'] +// Nor is the Python bytecode Git ignores: the root testDocumentChecks writes it under scripts/ in the +// same build, so with it the lane's fingerprint changed between two runs of one tree and on every +// fresh checkout (the files carry their source's modification time). +def repositoryContractExcludes = ['**/build/**', '**/.gradle/**', '**/node_modules/**', '.claude/worktrees/**', + '**/__pycache__/**', '**/*.pyc'] def repositoryContractInputs = files( fileTree(repositoryRootForContractTests) { // docs/registries/** are machine contracts, not prose: a malformed registry must fail -- 2.54.0