Files
grpc-library/build.gradle
T
DongHyeonka 8cf1a2109f build(quality)!: 테스트 코드 정적 분석을 게이트에 넣고 발견을 고친다
문제: qualityCheck는 spotbugsMain만 돈다. main 밖 source set(test,
testFixtures, integrationTest, systemTest 등)의 SpotBugs 태스크 111개는
어느 게이트에도 없었고, 돌려 보니 53개가 실패했다(발견 300건). 그중
동시성 테스트 7건은 CountDownLatch.await의 시간 초과를 무시하고 다음
단계로 가서 순서를 확인하지 않은 채 통과했다. 2개는 분석 classpath에
없는 클래스 때문에 분석이 불완전했다.

방법:
- leaf마다 testQualityCheck를 두고 main 빌드는 mainCheck, optional 빌드는
  ci에 넣었다. PR 게이트에 넣지 않은 것은 테스트 코드가 배포되지 않고
  전체 실행이 ci만큼 걸려서다.
- 테스트용 제외 목록 config/spotbugs/exclude-test.xml. 패턴 전체 제외는
  이유가 모든 테스트 클래스에 성립하는 것만(보안 범주, 내부 상태 노출,
  생성자 예외, 반환값 null 역참조, 아키텍처 위반 fixture). 나머지 30건은
  클래스·메서드로 좁히고 이유를 달았다.
- 24건은 코드로 고쳤다: await 결과 단언, 공유 변수 원자성, 닫지 않은
  Statement, SQLException을 삼키던 upsert 테스트, 만료 없는 키에서 NPE가
  나던 Redis fake. 쓰는 곳이 없던 web-fileserver 테스트 helper 2개는
  지웠다.
- 모든 SpotBugs 태스크가 그 source set의 runtime classpath로 분석하고
  분석이 불완전하면 실패한다. SpotBugs 플러그인이 나중에 생긴 source
  set의 태스크를 등록하면서 classpath를 덮어써서 설정을 평가 뒤에
  등록한다. 그 자리에 의존성을 더하는 우회는 버렸다.

위험·한계: 파생 서비스는 자기 테스트 코드의 SpotBugs 발견이 mainCheck를
막는다(업그레이드 안내 B-40). mainCheck가 그만큼 길어진다(main 빌드 테스트
태스크 100개).

검증: ci, 두 빌드 verifyStrictLaneStages --dry-run, mainCheck(testQualityCheck
100개 포함, 3분 10초 → 8분 33초), :integrationCheck, -p optional-platforms
ci(testQualityCheck 포함) integrationCheck performanceCheck,
:performanceCheck, :releaseCheck(-PgitRevision), verify-compose-profile-
contracts(18 lane) 첫 실행 통과. 고친 컨테이너 테스트는 클래스별로 따로
실행해 통과.

Refs: docs/reviews/2026-11-03-rereview/README.md 14절
BREAKING CHANGE: mainCheck(optional 빌드는 ci)가 테스트 source set의
SpotBugs·FindSecBugs 발견에 실패한다. 고치거나 config/spotbugs/
exclude-test.xml에 이유를 단 좁은 Match를 더한다.
2026-11-04 08:11:15 +09:00

93 lines
5.0 KiB
Groovy

plugins {
id 'ca.architecture'
// Every strict lane of this build belongs to a stage a workflow executes, checked here exactly
// as in the main build: the main build's check cannot see this build's lanes, and while only it
// applied the plugin, grpcPerformanceTest ran nowhere (review 2026-11-03 RR-06-03).
id 'ca.strict-lane-stages'
}
// No `ca.release-provenance` any more: each gRPC leaf's `ca.java-conventions` derives its version
// and `sourceRevision` from the same -PreleaseVersion/-PgitRevision (GIT_SHA, GITHUB_SHA) inputs the
// main build reads, so one commit produces one version scheme in both builds (review BUILD-O3-5).
tasks.register('resolveAndLockAll') {
group = 'build setup'
description = 'Regenerates dependency locks for every optional gRPC leaf (requires --write-locks).'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:resolveAndLockAll" }
}
tasks.register('checkAll') {
group = 'verification'
description = 'Runs every gRPC optional-platform leaf check.'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:check" }
}
tasks.register('qualityCheck') {
group = 'verification'
description = 'Runs production-bytecode static analysis for every optional-platform leaf.'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:qualityCheck" }
}
// SpotBugs + FindSecBugs over the test source sets (config/spotbugs/exclude-test.xml). This build has
// no main stage, and the run is short (eleven tasks), so it joins `ci`.
tasks.register('testQualityCheck') {
group = 'verification'
description = 'Runs test-code static analysis for every optional-platform leaf.'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:testQualityCheck" }
}
tasks.register('ci') {
group = 'verification'
description = 'Runs the optional gRPC platform verification surface.'
dependsOn tasks.named('checkAll')
dependsOn tasks.named('qualityCheck')
dependsOn tasks.named('testQualityCheck')
// architectureCheck, not only the direction gate: it also runs verifyNoIgnoredSourcePackages, so
// a gRPC source Git would drop fails this build's ci the way it fails the main build's.
dependsOn tasks.named('architectureCheck')
}
// A strict integration lane that no workflow invokes is not coverage; it is a file that looks like
// coverage. `grpc-operation-ledger-jpa` declares a Testcontainers PostgreSQL lane that certifies the
// atomic `INSERT ... ON CONFLICT DO NOTHING` claim the whole durable-idempotency contract rests on,
// and until this aggregate existed `ci` reached `checkAll`, `qualityCheck` and the dependency
// verifier only — none of which runs a lane whose category is INTEGRATION.
//
// Kept out of `ci`: every lane here starts a container, and `ci` is the per-PR gate for this build.
// The caller is integration-main.yml, the stage that owns container-backed lanes.
tasks.register('integrationCheck') {
group = 'verification'
description = 'Runs every optional-platform leaf integration test lane. Needs a container runtime.'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:integrationTestLaneCheck" }
}
// The performance stage of this build: grpcPerformanceTest. It asserts the shape of a measurement
// (ordered percentiles, a gate that reads them) with a generous budget, not a number, so it can run
// on a shared runner. integration-main.yml's performance-check job runs it next to the main build's
// `:performanceCheck`; before this aggregate it ran when somebody asked for it by name, which was
// nobody (review 2026-11-03 RR-06-03).
tasks.register('performanceCheck') {
group = 'verification'
description = 'Runs every optional-platform leaf performance test lane.'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:performanceTestLaneCheck" }
}
// The tag-only stage of this build: the hermetic strict lanes (the three gRPC certification lanes).
// Their tests already run inside each leaf's `test`; the lanes add the one thing `test` cannot say —
// that a tag still selects something — which is worth asserting once per release tag. release.yml
// runs this aggregate instead of naming the lanes, so a lane added here is in the release gate
// without a workflow edit.
tasks.register('releaseCheck') {
group = 'verification'
description = 'Runs every optional-platform leaf hermetic strict test lane (the release gate).'
dependsOn subprojects.findAll { it.childProjects.isEmpty() }.collect { "${it.path}:testLaneCheck" }
}
// The stages this build's strict lanes may belong to, executed by workflows as
// `./gradlew -p optional-platforms <stage>` from `src`. A command counts when it starts in this
// directory (working-directory joined with -p), which the plugin reads from where this build is.
strictLaneStages {
stage ':ci', ':integrationCheck', ':performanceCheck', ':releaseCheck'
workflowDirectory = layout.projectDirectory.dir('../../.github/workflows')
}