diff --git a/.gitea/actions/trivy-db-cache/action.yml b/.gitea/actions/trivy-db-cache/action.yml new file mode 100644 index 00000000..835b1b0e --- /dev/null +++ b/.gitea/actions/trivy-db-cache/action.yml @@ -0,0 +1,52 @@ +name: Restore the Trivy databases +description: >- + Restores Trivy's vulnerability database, and with java-db its Java index, from the runner's + cache. A run on main also saves the current copy. + +# scripts/ci/trivy-scan.sh downloaded the vulnerability database (133 MB, about 30 seconds) in every +# scan job, and the image scan also the Java index (952 MB, about two minutes of the 7-minute image +# job, release run 125). Trivy decides from a database's own metadata whether it is current and +# downloads a new one when it is not, so a restored copy changes how long a scan takes, not which +# advisories it knows. +# +# The keys carry a period because an entry is never overwritten: under a fixed key the first copy +# would stay forever. The vulnerability database gets a key a day; the Java index, which Trivy +# itself refreshes every three days, a key every three days, so its 952 MB lands in the runner's +# cache about twice a week instead of daily. Only main saves, the rule the JDK and Gradle caches +# follow (setup-java-gradle): a branch cannot decide what a later main run scans against. +inputs: + java-db: + description: Also restore Trivy's Java index, which only the image scan reads + default: "false" +runs: + using: composite + steps: + - id: period + shell: bash + run: | + echo "day=$(date -u +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" + echo "three-days=$(( $(date -u +%s) / 259200 ))" >> "${GITHUB_OUTPUT}" + - if: ${{ github.ref == 'refs/heads/main' }} + uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache@v4.3.0 + with: + path: ~/.cache/trivy/db + key: trivy-db-${{ runner.os }}-${{ steps.period.outputs.day }} + restore-keys: trivy-db-${{ runner.os }}- + - if: ${{ github.ref != 'refs/heads/main' }} + uses: https://github.com/actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache/restore@v4.3.0 + with: + path: ~/.cache/trivy/db + key: trivy-db-${{ runner.os }}-${{ steps.period.outputs.day }} + restore-keys: trivy-db-${{ runner.os }}- + - if: ${{ inputs.java-db == 'true' && github.ref == 'refs/heads/main' }} + uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache@v4.3.0 + with: + path: ~/.cache/trivy/java-db + key: trivy-java-db-${{ runner.os }}-${{ steps.period.outputs.three-days }} + restore-keys: trivy-java-db-${{ runner.os }}- + - if: ${{ inputs.java-db == 'true' && github.ref != 'refs/heads/main' }} + uses: https://github.com/actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache/restore@v4.3.0 + with: + path: ~/.cache/trivy/java-db + key: trivy-java-db-${{ runner.os }}-${{ steps.period.outputs.three-days }} + restore-keys: trivy-java-db-${{ runner.os }}- diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 5311e09a..0bac68b7 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -43,7 +43,8 @@ env: TESTCONTAINERS_REUSE_ENABLE: "false" jobs: - # Both main-branch stages in one Gradle run (build.gradle `strictLaneStages` says why). + # Both main-branch stages in one Gradle run, the integration stage first (build.gradle + # `strictLaneStages` says why). # mainCheck: environment contract, full-boot qualification, public-path baseline, transport and # messaging qualification, document-contract lanes, test-code analysis, the feature generator # round trip. integrationCheck: every integration-category strict lane, against real PostgreSQL, @@ -56,7 +57,7 @@ jobs: steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - uses: ./.gitea/actions/setup-java-gradle - - run: ./gradlew :mainCheck :integrationCheck --continue + - run: ./gradlew :integrationCheck :mainCheck --continue # The included build's own tests (TestKit for the convention plugins). The main task graph does # not reach them; `ci` already runs every plugin they test (owner decision 2026-11-07: main stage). @@ -109,6 +110,7 @@ jobs: timeout-minutes: 20 steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 + - uses: ./.gitea/actions/trivy-db-cache - run: bash scripts/ci/trivy-scan.sh filesystem # Experimental by design: the result is reported, never used to block anything. @@ -140,47 +142,72 @@ jobs: - uses: ./.gitea/actions/setup-java-gradle - run: ./gradlew :adapter:outbound:persistence-jpa:jpaPlatformContractTest -Pjpa.matrix.versions=${{ matrix.postgresql }} - # One HTTP transport per job, so a transport that stops satisfying the shared contract fails on its - # own row. `ci` runs the lane once over both. + # One HTTP transport per step, so a transport that stops satisfying the shared contract fails on its + # own step; `always()` runs the second after the first fails. One job rather than a matrix: each + # row is under a minute, most of it job start. `ci` runs the lane once over both. httpclient-transport: if: ${{ github.event_name != 'push' }} runs-on: ubuntu-latest timeout-minutes: 30 - strategy: - fail-fast: false - matrix: - transport: [apache, jdk] steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - uses: ./.gitea/actions/setup-java-gradle - - run: ./gradlew :adapter:outbound:httpclient:httpClientStableContractTest -Phttpclient.contract.transports=${{ matrix.transport }} + - name: apache + if: ${{ always() }} + run: ./gradlew :adapter:outbound:httpclient:httpClientStableContractTest -Phttpclient.contract.transports=apache + - name: jdk + if: ${{ always() }} + run: ./gradlew :adapter:outbound:httpclient:httpClientStableContractTest -Phttpclient.contract.transports=jdk # Sentinel promotion, Cluster redirects and TLS against real servers, every supported version. - # docs/redis/support-matrix.md says which lane produced which evidence; the job log carries the + # docs/redis/support-matrix.md says which lane produced which evidence; each step's log carries the # commit, the server version and the image digest. + # + # One job, a step per topology and version. As eleven matrix jobs each row paid the job start + # again (container, checkout, JDK, Gradle start and configuration: 26 of the 135 runner minutes + # of manual run 100 went to these rows, about a third of it start). `always()` runs every row + # after one fails, and the job's red names the failed step. The script stops its topology on + # exit, so the rows do not share a server. redis-topology: if: ${{ github.event_name != 'push' }} runs-on: ubuntu-latest - timeout-minutes: 30 - strategy: - fail-fast: false - matrix: - include: - - { topology: standalone, redis: "7.2" } - - { topology: standalone, redis: "7.4" } - - { topology: standalone, redis: "8.2" } - - { topology: sentinel, redis: "7.2" } - - { topology: sentinel, redis: "7.4" } - - { topology: sentinel, redis: "8.2" } - - { topology: cluster, redis: "7.2" } - - { topology: cluster, redis: "7.4" } - - { topology: cluster, redis: "8.2" } - - { topology: tls, redis: "7.4" } - - { topology: tls, redis: "8.2" } + timeout-minutes: 90 steps: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - uses: ./.gitea/actions/setup-java-gradle - - run: bash scripts/ci/redis-topology.sh ${{ matrix.topology }} ${{ matrix.redis }} + - name: standalone on Redis 7.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh standalone 7.2 + - name: standalone on Redis 7.4 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh standalone 7.4 + - name: standalone on Redis 8.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh standalone 8.2 + - name: sentinel on Redis 7.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh sentinel 7.2 + - name: sentinel on Redis 7.4 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh sentinel 7.4 + - name: sentinel on Redis 8.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh sentinel 8.2 + - name: cluster on Redis 7.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh cluster 7.2 + - name: cluster on Redis 7.4 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh cluster 7.4 + - name: cluster on Redis 8.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh cluster 8.2 + - name: tls on Redis 7.4 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh tls 7.4 + - name: tls on Redis 8.2 + if: ${{ always() }} + run: bash scripts/ci/redis-topology.sh tls 8.2 # The one fileserver environment a pull request cannot provide: a real NFSv4 server. fileserver-nfs-ambiguity: diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index fa082b97..fdf4ee97 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -42,5 +42,6 @@ jobs: - run: ./gradlew :prCheck # Plans every stage (--dry-run: nothing executes), so it cannot be a dependency of prCheck. - run: ./gradlew :verifyStrictLaneStages --dry-run + - uses: ./.gitea/actions/trivy-db-cache # Known High and Critical vulnerabilities and CISA KEV matches in the dependency tree. - run: bash scripts/ci/trivy-scan.sh filesystem diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 2b178cfc..bd306484 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -197,6 +197,10 @@ jobs: . # The SBOM is printed and kept in the log before the blocking scan, so the inventory of an image # that is refused still exists. A vulnerable image is never pushed: the push comes after. + # The image scan also reads Trivy's Java index (952 MB), the bulk of this job's download time. + - uses: ./.gitea/actions/trivy-db-cache + with: + java-db: "true" - name: Inventory and scan the release image run: | set -euo pipefail diff --git a/build-logic/AGENTS.md b/build-logic/AGENTS.md index 85a4cb4c..22483be7 100644 --- a/build-logic/AGENTS.md +++ b/build-logic/AGENTS.md @@ -26,7 +26,7 @@ registry, settings, build-logic, 루트 라이프사이클이 정하는 것을 ## 단계 job의 모양 - `verifyStrictLaneStages --dry-run`(PR)은 `explicitOnly`가 아닌 strict lane마다 `build.gradle`의 `strictLaneStages`가 선언한 단계 태스크 하나의 계획에 들어 있는지 본다(그래프 검사). -- 단계마다 선언한 workflow job은 step의 `run: ./gradlew <단계> <옵션>` 줄을 가지고(같은 job을 쓰는 단계는 선언한 `line`대로 한 줄을 나눠 쓸 수 있다: `./gradlew :mainCheck :integrationCheck --continue`), 다른 step `run:`도 셸 문법 없는 `./gradlew` 한 줄이나 `bash scripts/<이름>.sh` 한 줄이며, 선언 밖의 `if:`, 선언한 조건이 `!cancelled()`·`always()`가 아닌데 `needs:`, `continue-on-error`·`shell:`·`defaults:`, 따옴표 키·flow 형식, 이 빌드 밖의 `working-directory`가 없다. workflow는 선언한 이벤트로, 선언한 필터 한 줄만 달고 시작하고, PR 단계 job 하나가 이 검사를 돌린다(형식 검사, 셸을 해석하지 않는다). +- 단계마다 선언한 workflow job은 step의 `run: ./gradlew <단계> <옵션>` 줄을 가지고(같은 job을 쓰는 단계는 선언한 `line`대로 한 줄을 나눠 쓸 수 있다: `./gradlew :integrationCheck :mainCheck --continue`), 다른 step `run:`도 셸 문법 없는 `./gradlew` 한 줄이나 `bash scripts/<이름>.sh` 한 줄이며, 선언 밖의 `if:`, 선언한 조건이 `!cancelled()`·`always()`가 아닌데 `needs:`, `continue-on-error`·`shell:`·`defaults:`, 따옴표 키·flow 형식, 이 빌드 밖의 `working-directory`가 없다. workflow는 선언한 이벤트로, 선언한 필터 한 줄만 달고 시작하고, PR 단계 job 하나가 이 검사를 돌린다(형식 검사, 셸을 해석하지 않는다). - 단계를 더하거나 job을 바꾸면 `strictLaneStages`의 `stage` 줄과 workflow를 같은 커밋에서 고친다. ## 테스트 diff --git a/build.gradle b/build.gradle index 8df4fdb1..b3a0b3e7 100644 --- a/build.gradle +++ b/build.gradle @@ -209,6 +209,12 @@ tasks.register('verifyRepositoryLayout', Exec) { workingDir = repositoryRoot commandLine 'python3', 'scripts/check-repo-layout.py' } +tasks.register('verifyWorkDocs', Exec) { + group = 'verification' + description = 'Checks the work manual: size limits, no history IDs, playbook skeleton, relative links.' + workingDir = repositoryRoot + commandLine 'python3', 'scripts/check-work-docs.py' +} tasks.register('testDocumentChecks', Exec) { group = 'verification' description = 'Runs the tests of the scripts outside Gradle (document checker, hooks, ledger).' @@ -225,11 +231,12 @@ tasks.register('documentCheck', Exec) { tasks.register('prCheck') { group = 'verification' - description = 'The pull-request stage: ci, dependency locks, the Compose render, the layout and the documents.' + description = 'The pull-request stage: ci, dependency locks, the Compose render, the layout, the work manual and the documents.' dependsOn tasks.named('ci') dependsOn tasks.named('verifyDependencyLocks') dependsOn tasks.named('verifyComposeProfiles') dependsOn tasks.named('verifyRepositoryLayout') + dependsOn tasks.named('verifyWorkDocs') dependsOn tasks.named('documentCheck') } @@ -247,10 +254,15 @@ strictLaneStages { // main stage's analysis and the feature generator's nested build run while the integration // lanes take turns on the one real-server slot. Two jobs spent about 34 runner minutes on a push // (run 79), two of them compiling the same modules twice. + // integrationCheck comes first on the line because Gradle starts ready work in the order of + // the requested tasks: the integration lanes' compiles go first and the slot is busy from the + // first minute. Second on the line, the lanes waited about ten minutes behind the main stage's + // analysis and then ran one at a time on an idle machine (desktop 1,760 s, first on the line + // 1,484 s, same commit range). stage ':mainCheck', workflow: 'main.yml', event: 'push', filter: 'branches: [main]', job: 'main', - options: '--continue', line: ':mainCheck :integrationCheck' + options: '--continue', line: ':integrationCheck :mainCheck' stage ':integrationCheck', workflow: 'main.yml', event: 'push', filter: 'branches: [main]', job: 'main', - options: '--continue', line: ':mainCheck :integrationCheck' + options: '--continue', line: ':integrationCheck :mainCheck' stage ':performanceCheck', workflow: 'main.yml', event: 'schedule', job: 'performance', options: '--continue', condition: '${{ github.event_name != \'push\' }}' stage ':releaseCheck', workflow: 'release.yml', event: 'push', filter: 'tags: ["v*"]', job: 'release' diff --git a/docs/build.md b/docs/build.md index f23d30eb..3c2a19dd 100644 --- a/docs/build.md +++ b/docs/build.md @@ -29,7 +29,7 @@ Checkstyle은 **포매터가 표현할 수 없는 것만** — 네이밍과 몇 | `integrationCheck` | 선언된 strict integration lane을 실행. 대부분 container runtime이 필요. 입력이 필요한 lane(Redis topology: `-Predis.topology.mode`, AWS: 보호 자격 증명 env)은 입력이 없으면 빠지고 집계가 그 이유를 출력 | | `performanceCheck` | 선언된 strict performance lane(부하·종료·pool·자원 상한)을 실행. 실서버·container가 필요. 상한은 매번 단언하고 끄는 속성이 없다(`-Pperformance.assertions.enabled`가 `true`가 아니면 실패, skip된 테스트가 있어도 실패). `main.yml` `performance` job이 nightly에 다른 무거운 job 뒤에서 같은 명령으로 돌림 | | `verifyStrictLaneStages` | `--dry-run` 전용. `explicitOnly`가 아닌 strict lane이 `strictLaneStages`에 선언한 단계(`prCheck`·`mainCheck`·`integrationCheck`·`performanceCheck`·`releaseCheck`) 중 하나의 계획에 있는지, 단계마다 선언한 workflow job이 `./gradlew <단계>`를 정해진 한 줄로 조건 없이(또는 선언한 조건으로) 돌리는지 검사. 형식은 `build-logic/AGENTS.md` 「단계 job의 모양」. PR 단계가 돌림 | -| `prCheck` | PR 단계: `ci` + `verifyDependencyLocks` + compose 렌더링(`verifyComposeProfiles`) + 저장소 배치(`verifyRepositoryLayout`) + 문서 검사(`documentCheck`) | +| `prCheck` | PR 단계: `ci` + `verifyDependencyLocks` + compose 렌더링(`verifyComposeProfiles`) + 저장소 배치(`verifyRepositoryLayout`) + 작업 지침 분량·이력 ID(`verifyWorkDocs`) + 문서 검사(`documentCheck`) | | `ci` | 모든 leaf `check`(API surface 검사 포함, 소유자 결정 20) + `architectureCheck` + `qualityCheck` | | `mainCheck` | main 단계: `configContractCheck` + `qualificationCheck` + `verifyPublicPathSnapshot` + 전송·메시징 qualification 레인 + 각 leaf의 `mainCheck`(문서 대조 레인 `*DocumentContractTest`, objectstorage MinIO 레인) | | `releaseCheck` | tag 전용 검사: `verifyReleaseProvenance` + `verifyPublicPathSnapshot`(`ci`를 다시 돌리지 않음) | diff --git a/docs/ci-cd/template-vs-consumer.md b/docs/ci-cd/template-vs-consumer.md index 3cb6295a..63bd7d1f 100644 --- a/docs/ci-cd/template-vs-consumer.md +++ b/docs/ci-cd/template-vs-consumer.md @@ -17,7 +17,7 @@ | 대상 | 무엇을 지키는가 | | --- | --- | | `docs/design/**`, `docs/history/**` | 이 템플릿을 만든 과정의 설계서·계획서·납품 패키지·증거·학습 기록 | -| `main.yml`의 nightly 행렬 job(`jpa-postgresql`, `httpclient-transport`, `redis-topology`, `fileserver-nfs-ambiguity`, `notification-chaos`, `jpa-next`, `object-storage-aws`)과 `release.yml`의 영역별 release lane | 템플릿이 광고하는 지원 매트릭스의 근거. 서비스가 그 capability를 쓰면 남기고, 지운 capability의 job은 같이 지운다 | +| `main.yml`의 nightly job(`jpa-postgresql`, `httpclient-transport`, `redis-topology`, `fileserver-nfs-ambiguity`, `notification-chaos`, `jpa-next`, `object-storage-aws`)과 `release.yml`의 영역별 release lane | 템플릿이 광고하는 지원 매트릭스의 근거. 서비스가 그 capability를 쓰면 남기고, 지운 capability의 job은 같이 지운다 | ## Consumer 필수 (파생 프로젝트가 유지해야 한다) @@ -34,6 +34,7 @@ | `pr.yml` `done`의 Trivy step과 `main.yml`의 `vulnerabilities` job(`scripts/ci/trivy-scan.sh`) | Trivy와 CISA KEV | | `release.yml` | `releaseCheck`, 이미지 · SBOM · 서명 | | `scripts/verify.sh` | 사람·세션이 workflow와 같은 단계를 돌리는 진입점 | +| `prCheck`의 `verifyWorkDocs` | 작업 지침의 분량 상한·본문 이력 ID 0·playbook 뼈대(`scripts/check-work-docs.py`). 파생 서비스도 `docs/work/`와 `AGENTS.md`를 받으니 같은 상한을 지킨다 | | `prCheck`의 `documentCheck`·`testDocumentChecks` | 문서 규칙(`scripts/check-docs.py`: 언어·머리 블록·참조·숫자·지도·링크·문체)과 Gradle 밖 스크립트·편집 훅의 시험(`scripts/tests/`). 파생 서비스의 문서도 같은 규칙을 따른다(`docs/README.md`) | | `main.yml`의 `links` job | 문서의 외부 URL과 상대 링크(lychee) | | `scripts/check-repo-layout.py`(`prCheck`의 `verifyRepositoryLayout`) | 저장소 최상위 배치. 서비스가 최상위 항목을 더하면 허용 목록과 `AGENTS.md` 지도를 함께 고친다 | diff --git a/docs/ledger/estimates.jsonl b/docs/ledger/estimates.jsonl index 046214cc..a506c749 100644 --- a/docs/ledger/estimates.jsonl +++ b/docs/ledger/estimates.jsonl @@ -13,3 +13,5 @@ {"schema": 1, "kind": "actual", "task": "t2b-relayout", "transcript": "901b5cff-e758-490c-8e8c-5e47af313c26", "minutes": 253, "active_minutes": 159, "calls": 369, "output_tokens": 272872, "cache_read_tokens": 126767487, "max_context": 627122, "within": "p80", "result": "done", "commits": ["1388c06a", "6a792b81", "123fc0bf"], "why": "p50 위, p80 안. desktop 공유 잠금 대기(프론트 측정·게이트 약 2시간)를 10분 단위 대기 호출로 기다려 그 일부가 작업 중 시간에 들어갔다. 결정 수와 실패-고침 반복(2번)은 예측보다 적었다", "recorded_at": "2026-11-12T00:39+09:00"} {"schema": 1, "kind": "estimate", "task": "w2-be-ci-perf", "transcript": "a6b6b25f-a4f7-46c2-a746-5ab20a588c78", "started_at": "2026-11-11T12:30:40Z", "base": "66eaa982", "task_kind": "improve", "size": "large", "minutes": {"p30": 96, "p50": 144, "p80": 216}, "calls": {"p30": 295, "p50": 443, "p80": 649}, "output_tokens": {"p30": 270000, "p50": 405000, "p80": 594000}, "basis": "선례 large improve 4건(t2a 132분·374호출·37.5만, x3 110·346·27.2만, x2 99·330·30.4만, h3 68·270·34.6만). 이번은 결정 약 30(빨간 job 원인 8, 이미지 정책, 최적화 대책 10여, 목표치), runner 실행이 길어(main 수동 약 2시간, release 약 1시간) 실패-고침 반복 3~5번, 측정 스크립트를 새로 씀. 보정 전 200/300/450분·500/750/1100호출·50/75/110만에 장부 보정(시간 0.48·호출 0.59·출력 0.54)을 곱함. 2단계는 t2b 병합 대기라 대기 시간 제외", "recorded_at": "2026-11-11T21:36+09:00"} {"schema": 1, "kind": "actual", "task": "w2-be-ci-perf", "transcript": "a6b6b25f-a4f7-46c2-a746-5ab20a588c78", "minutes": 663, "active_minutes": 417, "calls": 464, "output_tokens": 438927, "cache_read_tokens": 256417797, "max_context": 911512, "within": "over", "result": "partial", "commits": ["ecc14004", "6325b518", "86488256", "c7aff0f4", "7054d179", "575aa1f7", "deeb1126", "96caf997", "cfc80ae8", "000a59ed", "5a95db45", "d237bacc", "7284b581", "14053060", "7dbf11ca", "2c180b90", "24dde586", "aeb60339", "083c6910"], "why": "시간이 p80을 넘었다: desktop 공유 잠금 대기자 10여 개(flock이 순서 없이 깨움)로 측정·검증이 2시간 넘게 밀렸고, runner 1대 대기열에서 늦게 풀린 job이 맨 뒤로 가 수동 실행 결과가 몇 시간씩 늦었다. 예측에 없던 결정: Gitea needs+if Blocked 재현(일회용 workflow 셋), Trivy가 처음 읽은 lockfile 라이선스와 이미지가 jar 라이선스를 못 읽는 것에 맞춘 판정 재설계. 결과는 partial: runner 초록은 NFS(소유자 sudo)·compose(수정 뒤 runner 미확인) 빼고 달성, 속도 목표 넷은 미달(캐시 효과는 병합 뒤, PG 컨테이너 159개 공유는 후속).", "recorded_at": "2026-11-12T08:34+09:00"} +{"schema": 1, "kind": "actual", "task": "w2-be-ci-perf", "correction": true, "transcript": "a6b6b25f-a4f7-46c2-a746-5ab20a588c78", "minutes": 1266, "active_minutes": 555, "calls": 556, "output_tokens": 534063, "cache_read_tokens": 301335415, "max_context": 963079, "within": "over", "result": "partial", "commits": ["ecc14004", "6325b518", "86488256", "c7aff0f4", "7054d179", "575aa1f7", "deeb1126", "96caf997", "cfc80ae8", "000a59ed", "5a95db45", "d237bacc", "7284b581", "14053060", "7dbf11ca", "2c180b90", "24dde586", "aeb60339", "083c6910", "335fc967", "9682c52c", "3e06a809", "d17f8bcf", "7db40c9b"], "why": "앞 actual 줄을 고친다. 그 뒤 총괄 지시 둘(새 main 위로, main.yml concurrency와 취소 증거)과 main 두 번 병합으로 작업 중 138분·호출 92가 더 들었다. 대부분 runner 대기열(PR run이 한 번에 2~4시간 뒤로 밀림)과 desktop 공유 잠금 대기였다. 결과는 여전히 partial: runner PR 130 초록·release gate 125 초록, NFS는 소유자 sudo, 속도 목표 넷은 미달(PR 13.5→12.0분/목표 8, release gate 45.6→32.5분/목표 35는 이미지 job 포함), 캐시 효과는 병합 뒤 측정.", "recorded_at": "2026-11-12T18:36+09:00"} +{"schema": 1, "kind": "estimate", "task": "w2-be-ci-perf-2", "transcript": "a6b6b25f-a4f7-46c2-a746-5ab20a588c78", "started_at": "2026-11-12T18:45+09:00", "base": "e7be517e", "task_kind": "improve", "size": "large", "minutes": {"p30": 150, "p50": 240, "p80": 400}, "calls": {"p30": 120, "p50": 200, "p80": 320}, "output_tokens": {"p30": 100000, "p50": 170000, "p80": 280000}, "basis": "직전 라운드 w2-be-ci-perf 실측 555분(p50 144의 3.9배, 대부분 runner·desktop 잠금 대기). 이번 판단 5개(B2·NFS·C2·job 합치기·main 줄 순서), desktop main 측정 1회(30분)+pr 1회, runner nightly 1회(2시간)+release 1회+PR 2회. 대기가 시간을 정한다", "recorded_at": "2026-11-12T18:58+09:00"} diff --git a/docs/work/operate.md b/docs/work/operate.md index 72312b7b..51d370e8 100644 --- a/docs/work/operate.md +++ b/docs/work/operate.md @@ -113,11 +113,10 @@ ssh desktop 'cd ~/workspace/<작업 이름> && git add -A && git write-tree' - 파생 서비스는 이 템플릿을 받아 도메인을 채운 repo다. 템플릿 변경을 두 방식으로 받는다: 기준 커밋을 적은 tracked snapshot에 3-way로 반영하거나(`template.lock.json`), `git merge upstream/main`을 한다. - 템플릿 쪽에서 할 일: 파생 서비스가 따라 고쳐야 하는 변경은 `docs/upgrade/`의 안내에 행을 더하고 커밋 제목에 `!`를 단다. 안내 문서 형식은 `docs/upgrade/2026-11-maturity-review.md`다. -- 파생 서비스가 유지할 게이트와 지워도 되는 템플릿 전용 게이트는 `docs/ci-cd/template-vs-consumer.md`다. +- 파생 서비스가 유지할 게이트와 지워도 되는 템플릿 전용 게이트는 `docs/ci-cd/template-vs-consumer.md`다. 파생 서비스 쪽 병합과 그 게이트는 그 repo의 일이고, 템플릿 세션은 파생 서비스 repo를 고치지 않는다. - 파생 서비스의 동기화는 루트 `CLAUDE.md`를 걸러낸다. 그래서 파생 서비스는 자기 `CLAUDE.md`에 `@AGENTS.md` 한 줄을 두고, 지도(`AGENTS.md`)에서 `docs/work/README.md`를 가리켜야 한다. `docs/work/`는 걸러지지 않는다. - `.claude/`의 추적 파일(`settings.json`의 권한과 훅, `rules/`, `skills/`, `agents/`)은 함께 넘어간다. 훅 본체는 `scripts/hooks/`다. 한 설정 단계에서 deny된 도구는 다른 단계(`settings.local.json`, 사용자 설정)의 allow로 풀리지 않는다(Claude Code 권한 문서 「Settings precedence」). 파생 서비스가 `.env` 읽기 차단 같은 권한을 바꾸려면 그 파일을 자기 repo에서 고친다. -- 파생 서비스 쪽 병합과 그 게이트는 그 repo의 일이다. 템플릿 세션이 파생 서비스 repo를 고치지 않는다. -- 파생 서비스는 **요청률 제한을 어디서 거는지** 배포 설계에 정한다: 앱은 기본 off(요청 빈도는 ingress/gateway 책임), 앞단에서 안 걸면 앱 내 redis limiter를 켠다. 자세와 켜는 법은 [docs/security/rate-limiting.md](../security/rate-limiting.md)(W4 BE-OBS-A). +- 파생 서비스는 **요청률 제한을 어디서 거는지** 배포 설계에 정한다: 앱은 기본 off(요청 빈도는 ingress/gateway 책임), 앞단에서 안 걸면 앱 내 redis limiter를 켠다. 자세와 켜는 법은 [docs/security/rate-limiting.md](../security/rate-limiting.md)다. ## 5. 완료 기준 diff --git a/docs/work/reference/gates.md b/docs/work/reference/gates.md index 1e76a01a..b9bd683b 100644 --- a/docs/work/reference/gates.md +++ b/docs/work/reference/gates.md @@ -17,13 +17,13 @@ Gradle 명령과 `scripts/verify.sh`는 모두 저장소 루트(Gradle 루트) | `docs` | `check-work-docs.py`, `check-docs.py`, `scripts/tests` 자기 시험, `check-repo-layout.py`(Gradle 없음, 노트북 가능) | `pr.yml`의 `prCheck` 안 | | `leaf ` | 그 leaf의 `check` | — | | `pr` | `./gradlew :prCheck`, `./gradlew :verifyStrictLaneStages --dry-run` | `pr.yml` `done` | -| `main` | `:mainCheck :integrationCheck --continue`, `-p build-logic test`, `scripts/ci/verify-configuration-cache.sh` | `main.yml`(push) | +| `main` | `:integrationCheck :mainCheck --continue`, `-p build-logic test`, `scripts/ci/verify-configuration-cache.sh` | `main.yml`(push) | | `nightly` | compose smoke 전부, 마지막에 `:performanceCheck --continue` | `main.yml`(schedule·수동) | | `release` | `:releaseCheck`(지금 커밋을 provenance로) | `release.yml` `release` | | `app` | `scripts/bootstrap-local.sh`(앱을 띄워 health와 기본 endpoint 확인) | — | | `round` | `pr` → `main` → `nightly` → `release`, 첫 실패에서 멈춘다 | — | -workflow에만 있는 job: `pr.yml` `done`의 마지막 step과 `main.yml`의 `vulnerabilities`(trivy, `scripts/ci/trivy-scan.sh`), `main.yml`의 `links`(lychee), nightly 행렬(`jpa-postgresql`·`httpclient-transport`·`redis-topology`·`fileserver-nfs-ambiguity`·`notification-chaos`·`jpa-next`), `release.yml`의 release lane과 이미지 job. `main.yml`의 `done`은 게이트가 아니다: nightly에 main에서 `:prCheck`를 한 번 더 돌려 빌드 캐시를 채우고, 같은 이름의 PR job이 그 캐시를 읽는다(setup-gradle이 job 이름으로 캐시를 찾는다). 도구를 내려받거나 runner 환경이 필요해 `verify.sh`에 넣지 않았다. 손으로 돌리는 법은 3절 (다)다. +workflow에만 있는 job: `pr.yml` `done`의 마지막 step과 `main.yml`의 `vulnerabilities`(trivy, `scripts/ci/trivy-scan.sh`), `main.yml`의 `links`(lychee), nightly job(`jpa-postgresql`·`httpclient-transport`·`redis-topology`·`fileserver-nfs-ambiguity`·`notification-chaos`·`jpa-next`), `release.yml`의 release lane과 이미지 job. `main.yml`의 `done`은 게이트가 아니다: nightly에 main에서 `:prCheck`를 한 번 더 돌려 빌드 캐시를 채우고, 같은 이름의 PR job이 그 캐시를 읽는다(setup-gradle이 job 이름으로 캐시를 찾는다). 도구를 내려받거나 runner 환경이 필요해 `verify.sh`에 넣지 않았다. 손으로 돌리는 법은 3절 (다)다. 게이트 하나씩: @@ -35,12 +35,13 @@ workflow에만 있는 job: `pr.yml` `done`의 마지막 step과 `main.yml`의 `v | `qualityCheck` | SpotBugs, FindSecBugs(운영 코드) | PR(`ci` 안) | `build.gradle` | | `testQualityCheck` | 같은 분석을 모든 테스트 source set에(`config/spotbugs/exclude-test.xml` 기준) | main(`mainCheck` 안) | `build.gradle` | | `ci` | leaf `check`(API surface 포함) + `architectureCheck` + `qualityCheck` | PR(`prCheck` 안) | `build.gradle` | -| `prCheck` | `ci` + `verifyDependencyLocks` + `verifyComposeProfiles`(compose lane이 선언대로 렌더링되는가) + `verifyRepositoryLayout`(`check-repo-layout.py`) + `documentCheck`(`check-docs.py`, 앞에 `scripts/tests` 자기 시험) | PR | `pr.yml` `done`: `./gradlew :prCheck` | +| `prCheck` | `ci` + `verifyDependencyLocks` + `verifyComposeProfiles`(compose lane이 선언대로 렌더링되는가) + `verifyRepositoryLayout`(`check-repo-layout.py`) + `verifyWorkDocs`(`check-work-docs.py`) + `documentCheck`(`check-docs.py`, 앞에 `scripts/tests` 자기 시험) | PR | `pr.yml` `done`: `./gradlew :prCheck` | | `verifyStrictLaneStages --dry-run` | `explicitOnly`가 아닌 strict lane이 단계 태스크 하나의 계획에 들어 있는가(그래프 검사), 단계마다 선언한 workflow job이 `./gradlew <단계>` 한 줄을 정해진 조건으로 돌리는가(형식 검사) | PR | `pr.yml` `done` 둘째 줄. 형식은 `build-logic/AGENTS.md` | | `python3 scripts/check-repo-layout.py` | 저장소 루트와 `src/` 최상위에 허용 목록 밖의 항목이 없는가, registry 경로가 허용 폴더 안인가. 아무도 가리키지 않는 compose·스크립트 파일은 경고 | PR(`prCheck` 안) | `verifyRepositoryLayout` | +| `python3 scripts/check-work-docs.py` | 작업 지침(루트 `AGENTS.md`·`CLAUDE.md`, `docs/work/`, `src/**/AGENTS.md`, `.claude/`)의 분량 상한, 본문 이력 ID 0, playbook 뼈대, 상대 링크 | PR(`prCheck` 안) | `verifyWorkDocs` | | `python3 scripts/check-docs.py` | 살아 있는 문서의 언어, 기록·ADR 머리 블록, 문서의 인라인 코드 경로·Gradle 경로가 지금 있는가, 복사한 숫자, 상대 링크(`docs/README.md` 「문서 검사」) | PR(`prCheck` 안) | `documentCheck` | -| `mainCheck` | `configContractCheck` + `qualificationCheck`(`testQualityCheck` 포함) + 공개 경로 스냅숏 + 전송·메시징 qualification lane + 생성 명령 왕복(`verifyFeatureScaffold`) + 모든 leaf의 `mainCheck`(document-contract lane 등) | main | `main.yml` `main`: `./gradlew :mainCheck :integrationCheck --continue` | -| `integrationCheck` | 선언된 strict integration lane 전체(실 컨테이너). 입력이 없는 lane은 빼고 이름을 댄다 | main·nightly | `main.yml` `main`: `./gradlew :mainCheck :integrationCheck --continue`(두 단계를 Gradle 한 번에. 한 번 컴파일하고, 직렬 lane이 도는 동안 나머지가 겹친다) | +| `mainCheck` | `configContractCheck` + `qualificationCheck`(`testQualityCheck` 포함) + 공개 경로 스냅숏 + 전송·메시징 qualification lane + 생성 명령 왕복(`verifyFeatureScaffold`) + 모든 leaf의 `mainCheck`(document-contract lane 등) | main | `main.yml` `main`: `./gradlew :integrationCheck :mainCheck --continue` | +| `integrationCheck` | 선언된 strict integration lane 전체(실 컨테이너). 입력이 없는 lane은 빼고 이름을 댄다 | main·nightly | `main.yml` `main`: `./gradlew :integrationCheck :mainCheck --continue`(두 단계를 Gradle 한 번에. 한 번 컴파일하고, 직렬 lane이 도는 동안 나머지가 겹친다. integration이 앞이라 lane이 첫 몇 분부터 슬롯을 쓴다) | | `performanceCheck` | 선언된 performance lane 전체(부하·종료·풀·자원 한계, 실 서버와 컨테이너). 상한을 매번 단언한다. 손으로 돌리든 workflow든 같은 상한이다 | nightly(다른 무거운 job 뒤: 파일 맨 끝 job이고 runner 하나가 job을 만든 순서대로 돈다. `needs`는 쓰지 않는다 — Gitea 1.27이 `needs`와 `if`를 함께 가진 job을 Blocked에 둔다) | `main.yml` `performance`. 5절 | | `releaseCheck` | 릴리스 provenance + 공개 경로 스냅숏. 커밋을 `GITHUB_SHA`·`GIT_SHA`·`-PgitRevision=`로 받고, 없으면 설계대로 실패한다 | 태그 | `release.yml` `release` | | `:app-bootstrap:verifyEnvKeys` | env 키 레지스트리와 profile YAML·`.env.example` | `mainCheck` 안(`configContractCheck`) | build-logic `ca.config-contract` | @@ -112,7 +113,7 @@ workflow에만 있는 job: `pr.yml` `done`의 마지막 step과 `main.yml`의 `v 1. 바뀐 파일 목록을 만든다: `git diff --name-only <기준 커밋> <합친 커밋>`. 2. 바뀐 영역의 job을 고른다: PostgreSQL major(`jpa-postgresql`, persistence-jpa), HTTP transport(`httpclient-transport`, httpclient), Redis topology(`redis-topology`, redis leaf 셋), NFS(`fileserver-nfs-ambiguity`, fileserver), 알림 chaos(`notification-chaos`), 릴리스 lane(`release.yml`의 같은 영역 job). -3. 그 job의 `run` 줄을 저장소 루트에서 그대로 돌린다. 행렬은 값마다 한 번이다. 스크립트 job(`scripts/ci/redis-topology.sh `)은 desktop에서도 같은 줄로 돈다. +3. 그 job의 `run` 줄을 저장소 루트에서 그대로 돌린다. 행렬은 값마다 한 번이다. `redis-topology`는 행렬이 아니라 행마다 step 하나이고, 그 `scripts/ci/redis-topology.sh ` 줄은 desktop에서도 같은 줄로 돈다. 4. 고르지 않은 job은 이름과 "바뀐 영역 아님"을 결과 표에 적는다. 5. 처음 켠 job이 이번 변경과 무관한 이전부터의 실패를 드러내면(예: 진입 문서만 바꿨는데 그 영역 job을 돌림), 기준 커밋에서 같은 실패인지 보고 「이전부터」로 적는다. 그 영역의 남은 문제로 넘기고 이번 변경 몫으로 세지 않는다. diff --git a/scripts/ci/redis-topology.sh b/scripts/ci/redis-topology.sh index 94aa747b..1aee77fe 100755 --- a/scripts/ci/redis-topology.sh +++ b/scripts/ci/redis-topology.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash # One Redis topology lane against a real server: start the Compose topology, run the leaves' # `redisTopologyTest` for it, print the evidence manifest, stop the topology. Called by the -# `redis-topology` nightly job of .gitea/workflows/main.yml (one call per matrix row); a person can -# run the same line on a machine with Docker. +# `redis-topology` nightly job of .gitea/workflows/main.yml (one step per row; the script stops its +# topology on exit, so the rows do not share a server); a person can run the same line on a machine +# with Docker. # # bash scripts/ci/redis-topology.sh # diff --git a/scripts/ci/trivy-scan.sh b/scripts/ci/trivy-scan.sh index b98b0bf9..92ae8459 100755 --- a/scripts/ci/trivy-scan.sh +++ b/scripts/ci/trivy-scan.sh @@ -15,7 +15,9 @@ # temporary directory): a checksum is a supply-chain claim that can be checked offline, an action # pinned to a commit is not. .trivyignore.yaml is the one suppression source; each entry carries a # reason and an expiry by policy (.github/dependency-vulnerability-policy.md). -# Optional mirrors: TRIVY_DOWNLOAD_BASE_URL, JQ_DOWNLOAD_BASE_URL, KEV_FEED_URL. +# Optional mirrors: TRIVY_DOWNLOAD_BASE_URL, JQ_DOWNLOAD_BASE_URL, KEV_FEED_URL. The workflows restore +# Trivy's databases into its default cache directory first (.gitea/actions/trivy-db-cache); Trivy +# still downloads a newer one when the restored copy's own metadata says it is out of date. set -euo pipefail readonly TRIVY_VERSION='0.71.2' diff --git a/scripts/verify.sh b/scripts/verify.sh index 6d5d386d..0e4c90e5 100755 --- a/scripts/verify.sh +++ b/scripts/verify.sh @@ -71,7 +71,7 @@ run_pr() { } run_main() { - gradle :mainCheck :integrationCheck --continue + gradle :integrationCheck :mainCheck --continue gradle -p build-logic test bash scripts/ci/verify-configuration-cache.sh } diff --git a/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupport.java b/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupport.java index 1a730490..788a978f 100644 --- a/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupport.java +++ b/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupport.java @@ -5,7 +5,10 @@ import com.zaxxer.hikari.HikariDataSource; import dev.caskeleton.adapter.outbound.persistence.testkit.postgresql.PostgreSqlContainerFactory; import dev.caskeleton.adapter.outbound.persistence.testkit.postgresql.PostgreSqlVersion; import java.sql.Connection; +import java.sql.DriverManager; import java.sql.SQLException; +import java.sql.Statement; +import java.util.EnumMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -17,9 +20,16 @@ import org.testcontainers.postgresql.PostgreSQLContainer; /** * Starts one PostgreSQL per selected Stable version and hands out data sources (design §40). * - *

The containers are shared for the JVM: the contracts verify server behaviour, which does not + *

The servers are shared for the JVM: the contracts verify server behaviour, which does not * change between test classes, and starting a server per class turns a three-version matrix into - * minutes of container startup. + * minutes of container startup. Each support gets a database of its own on that server, created by + * {@code start} and dropped by {@code close}, so tables, schemas and Flyway history do not cross + * classes. What the server holds for every database — roles — does: a contract that creates a role + * owns that name for the whole lane. + * + *

Until 2026-11-12 every {@code start} started a server of its own although this comment said + * they were shared: 75 servers in the platform contract lane and 36 in the migration lane, 181 and + * 71 seconds of container start (desktop, 2026-11-12), on the build's one real-server slot. * *

Docker absence throws rather than skipping. A skipped contract reports success for a database * nobody tested, and CI inherits that silence. @@ -30,8 +40,16 @@ public final class JpaPlatformContractSupport implements AutoCloseable { private static final java.security.SecureRandom PASSWORD_SOURCE = new java.security.SecureRandom(); + /** One server per Stable version, started on first use and stopped when the JVM exits. */ + private static final Map SERVERS = + new EnumMap<>(PostgreSqlVersion.class); + + /** Names each support's database; the server outlives every support, so names never repeat. */ + private static final AtomicInteger DATABASES = new AtomicInteger(); + private final PostgreSqlVersion version; private final PostgreSQLContainer container; + private final String database; /** * The pools this support owns, closed before the container stops. @@ -48,9 +66,11 @@ public final class JpaPlatformContractSupport implements AutoCloseable { private final AtomicInteger poolSequence = new AtomicInteger(); - private JpaPlatformContractSupport(PostgreSqlVersion version, PostgreSQLContainer container) { + private JpaPlatformContractSupport( + PostgreSqlVersion version, PostgreSQLContainer container, String database) { this.version = version; this.container = container; + this.database = database; } /** @@ -85,12 +105,47 @@ public final class JpaPlatformContractSupport implements AutoCloseable { return start(selected.get(0)); } - /** Starts one specific Stable version. */ + /** A fresh database on the shared server of one specific Stable version. */ public static JpaPlatformContractSupport start(PostgreSqlVersion version) { Objects.requireNonNull(version, "version"); - PostgreSQLContainer container = PostgreSqlContainerFactory.create(version); - container.start(); - return new JpaPlatformContractSupport(version, container); + PostgreSQLContainer server = server(version); + String database = "contract_" + DATABASES.incrementAndGet(); + administer(server, "create database " + database); + return new JpaPlatformContractSupport(version, server, database); + } + + private static synchronized PostgreSQLContainer server(PostgreSqlVersion version) { + PostgreSQLContainer server = SERVERS.get(version); + if (server == null) { + if (SERVERS.isEmpty()) { + // Testcontainers' reaper would remove the containers too, but it is the part a remote + // Docker host cannot always reach; stopping them here does not depend on it. + Runtime.getRuntime() + .addShutdownHook( + new Thread(JpaPlatformContractSupport::stopServers, "jpa-contract-servers")); + } + server = PostgreSqlContainerFactory.create(version); + server.start(); + SERVERS.put(version, server); + } + return server; + } + + private static synchronized void stopServers() { + SERVERS.values().forEach(PostgreSQLContainer::stop); + SERVERS.clear(); + } + + /** Runs one statement as the server's owning role, connected to the server's own database. */ + private static void administer(PostgreSQLContainer server, String sql) { + try (Connection connection = + DriverManager.getConnection( + server.getJdbcUrl(), server.getUsername(), server.getPassword()); + Statement statement = connection.createStatement()) { + statement.execute(sql); + } catch (SQLException failure) { + throw new IllegalStateException("PostgreSQL contract server refused: " + sql, failure); + } } /** The versions this run was asked to cover. */ @@ -132,7 +187,7 @@ public final class JpaPlatformContractSupport implements AutoCloseable { private HikariDataSource pool(String role, String username, String password, int maximumSize) { HikariConfig config = new HikariConfig(); - config.setJdbcUrl(container.getJdbcUrl()); + config.setJdbcUrl(jdbcUrl()); config.setUsername(username); config.setPassword(password); config.setMaximumPoolSize(maximumSize); @@ -148,9 +203,14 @@ public final class JpaPlatformContractSupport implements AutoCloseable { return dataSource().getConnection(); } - /** The running server's JDBC URL, for contracts that build their own pools. */ + /** This support's database on the running server, for contracts that build their own pools. */ public String jdbcUrl() { - return container.getJdbcUrl(); + return "jdbc:postgresql://" + + container.getHost() + + ":" + + container.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT) + + "/" + + database; } /** The container's owning role. */ @@ -192,9 +252,10 @@ public final class JpaPlatformContractSupport implements AutoCloseable { @Override public synchronized void close() { - // Pools first, container last. Stopping the server while a pool is still open leaves that - // pool retrying against an address nobody is listening on, and its housekeeping thread outlives - // the test that created it. + // Pools first, database last. Dropping the database under an open pool leaves that pool + // retrying against a database that is gone, and its housekeeping thread outlives the test that + // created it. `with (force)` ends a connection a contract opened outside the pools. The server + // stays for the next class. RuntimeException firstFailure = null; for (HikariDataSource pool : pools.values()) { try { @@ -208,7 +269,15 @@ public final class JpaPlatformContractSupport implements AutoCloseable { } } pools.clear(); - container.stop(); + try { + administer(container, "drop database if exists " + database + " with (force)"); + } catch (RuntimeException failure) { + if (firstFailure == null) { + firstFailure = failure; + } else { + firstFailure.addSuppressed(failure); + } + } if (firstFailure != null) { throw firstFailure; } diff --git a/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupportOwnershipTest.java b/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupportOwnershipTest.java index 19a98a05..37247114 100644 --- a/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupportOwnershipTest.java +++ b/src/adapter/outbound/persistence-jpa/src/postgresqlIntegrationTest/java/dev/caskeleton/adapter/outbound/persistence/platform/JpaPlatformContractSupportOwnershipTest.java @@ -4,6 +4,10 @@ import static org.assertj.core.api.Assertions.assertThat; import com.zaxxer.hikari.HikariDataSource; import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; import javax.sql.DataSource; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; @@ -66,8 +70,7 @@ class JpaPlatformContractSupportOwnershipTest { } @Test - @DisplayName("close shuts every pool before the container stops") - void closeShutsEveryPoolBeforeTheContainerStops() { + void closeShutsEveryPoolBeforeItsDatabaseIsDropped() { HikariDataSource owned; try (JpaPlatformContractSupport support = JpaPlatformContractSupport.start()) { owned = (HikariDataSource) support.dataSource(); @@ -75,10 +78,65 @@ class JpaPlatformContractSupportOwnershipTest { } assertThat(owned.isClosed()) - .as("stopping the container first leaves a live pool retrying against nothing") + .as("dropping the database first leaves a live pool retrying against nothing") .isTrue(); } + @Test + void aSecondSupportSharesTheServerButNotTheDatabase() { + // given + String first; + try (JpaPlatformContractSupport support = JpaPlatformContractSupport.start()) { + first = support.jdbcUrl(); + } + + // when + String second; + try (JpaPlatformContractSupport support = JpaPlatformContractSupport.start()) { + second = support.jdbcUrl(); + } + + // then + assertThat(List.of(serverOf(second), databaseOf(second).equals(databaseOf(first)))) + .as("one server per version for the JVM, a database of its own per support") + .containsExactly(serverOf(first), false); + } + + @Test + void closeDropsTheSupportsDatabase() throws SQLException { + // given + String closed; + try (JpaPlatformContractSupport support = JpaPlatformContractSupport.start()) { + closed = databaseOf(support.jdbcUrl()); + } + + // when + Boolean exists; + try (JpaPlatformContractSupport support = JpaPlatformContractSupport.start(); + Connection connection = support.connection(); + PreparedStatement statement = + connection.prepareStatement( + "select exists(select 1 from pg_database where datname = ?)")) { + statement.setString(1, closed); + try (ResultSet row = statement.executeQuery()) { + exists = row.next() ? row.getBoolean(1) : null; + } + } + + // then + assertThat(exists) + .as("a database left behind is one class's tables in the next class's server") + .isFalse(); + } + + private static String serverOf(String jdbcUrl) { + return jdbcUrl.substring(0, jdbcUrl.lastIndexOf('/')); + } + + private static String databaseOf(String jdbcUrl) { + return jdbcUrl.substring(jdbcUrl.lastIndexOf('/') + 1); + } + @Test @DisplayName("pools carry an identifiable name") void poolsCarryAnIdentifiableName() { diff --git a/src/adapter/outbound/redis-sdk/compose/README.md b/src/adapter/outbound/redis-sdk/compose/README.md index 793c28e5..2592f65f 100644 --- a/src/adapter/outbound/redis-sdk/compose/README.md +++ b/src/adapter/outbound/redis-sdk/compose/README.md @@ -6,7 +6,7 @@ 넷 모두 Redis 7.4에서 돌았고 증거는 `docs/redis/support-matrix.md`에 적혀 있다. `.gitea/workflows/main.yml`의 nightly `redis-topology` job이 매일 밤(그리고 손으로 실행할 때) 지원 버전 × topology 표 -전체를 행마다 `scripts/ci/redis-topology.sh `으로 돌린다. 같은 줄을 Docker가 있는 머신에서 +전체를 job 하나 안에서 행마다 step 하나(`scripts/ci/redis-topology.sh `)로 돌린다. 같은 줄을 Docker가 있는 머신에서 손으로 돌릴 수 있다. pull request마다 돌던 standalone lane은 2026-11-08에 nightly로 옮겼다(어댑터 컨테이너 lane은 main 단계, 소유자 결정 2026-11-07).