From e9ee917fcbbaa2880ccdf323794c1984d1eaa577 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 00:44:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ci(main):=20main=20push=EB=8F=84=20PR?= =?UTF-8?q?=EC=9A=A9=20=EB=B9=8C=EB=93=9C=20=EC=BA=90=EC=8B=9C=EB=A5=BC=20?= =?UTF-8?q?=EC=B1=84=EC=9A=B0=EA=B3=A0=20=EB=AC=B8=EC=84=9C=EB=A7=8C=20?= =?UTF-8?q?=EB=B0=94=EA=BE=BC=20push=EB=8A=94=20=EA=B1=B4=EB=84=88?= =?UTF-8?q?=EB=9B=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: main.yml의 done(PR 단계를 main에서 한 번 더 돌려 PR이 읽는 빌드 캐시를 채우는 job, 게이트 아님)이 nightly·수동 run에서만 돈다. 빌드 입력을 바꾼 병합 뒤에는 다음 nightly까지 PR마다 그 변경이 건드린 태스크를 다시 돈다. 11-19 build-logic 변경 뒤 PR run 347·350의 :prCheck는 9:26·12:09였다(캐시가 찬 날 1:35~2:04). nightly 353 직후 PR은 from cache 266(2.1분)이었고, main이 움직이며 207·191·190(6.0분)으로 떨어졌다. 고친 것: done을 push에서도 돌린다. 문서만 바꾼 push는 checkout 뒤 `건너뜀: done — …` 한 줄로 끝난다. 판정은 scripts/ci/done-build-inputs.py가 한다. 문서(docs/·.claude/ 아래, 소스 세트 밖 *.md)를 뺀 추적 파일의 경로· mode·blob id로 키를 만들고, 가장 최근 표식의 키와 같을 때만 건너뛴다. 표식은 main에서 성공한 done job이 끝에 남기는 작은 캐시 항목이다. actions/cache가 run마다 새 키로 setup-gradle 저장 뒤에 저장하고, 다음 job은 접두 restore로 가장 최근 것을 받는다. 그래서 가장 최근 표식과 가장 최근 Gradle 항목은 같은 job에서 나온다. 버린 것: - (가) push마다 무조건 돈다: 문서 push마다 1:34~2:10을 쓴다(11-05 뒤 main 병합 38건 중 4건, 11-18에는 push 9건 중 5건). - (다) main job 줄에 :prCheck를 붙이고 build-cache를 따로 저장: 캐시 키· 복원 설계가 커진다. - github.event.before와 비교(초안 HEAD^1 비교의 개선안): 앞 push run이 concurrency로 취소된 뒤 문서 push가 오면 건너뛰어 채우기가 nightly까지 밀린다. - 입력 키마다 표식(lookup-only): K1→K2→K1 되돌림에서 최신 Gradle 항목은 K2인데 K1 표식을 보고 건너뛴다. 위험·한계: - 코드 push마다 main run +1:34~2:10, 전역 빌드 입력을 바꾼 push는 약 10분(nightly done이 그만큼 준다). main push p50 19.6분(11-18~19). - runner 캐시(5.0G = 상한 5GB, 두 repo가 같이 씀)에 코드 push마다 Gradle 항목이 하나 더 생긴다. 밀려남이 늘 수 있다. - 표식은 그 Gradle 항목이 남았는지 모른다. 저장 실패나 밀려남이면 다음 코드 push·nightly까지 PR이 캐시를 못 받는다. 판정은 같다. - 문서를 입력으로 선언한 PR 시험(registry·runbook·ADR·API surface 기준)은 그 문서만 바꾼 push 뒤 다음 PR에서 다시 돈다. - 병합 뒤 runner 로그로 볼 것: 표식 restore 줄, post 순서(setup-gradle 저장 뒤 표식 저장), 문서 push의 건너뜀 줄. 검증: - desktop scripts/verify.sh pr --no-cache(트리 7370dd73, 기준 5b00b7eb): :prCheck rc=0 5분 46초, 530 executed·FROM-CACHE 0, 시험 7269개(실패 0, 건너뜀 35). :verifyStrictLaneStages --dry-run rc=0. - desktop scripts/verify.sh main --no-cache(같은 트리): rc=0. :integrationCheck :mainCheck 23분, 446 executed·from cache 0(안쪽 :verifyFeatureScaffold 생성 왕복 빌드만 자기 캐시를 씀), -p build-logic test, verify-configuration-cache.sh. 시험 1975개(실패 0, 건너뜀 19). - 노트북 scripts/verify.sh docs rc=0(scripts 시험 185개). - test_done_build_inputs 14개, 변이 15개(문서 규칙 셋, 키에서 mode·blob id 빼기, 문서를 키에 넣기, 출력 없이 rc 0, 비 push 건너뜀, 표식 없이 건너뜀, 표식 다시 쓰기 빼기, 표식 경로, 도는 조건, job 단위 if, 표식 step의 main 조건, 고정 표식 키, EVENT 없음) 모두 실패로 잡힘. - desktop --dry-run: :prCheck 783개와 :integrationCheck :mainCheck 742개가 겹치는 317개는 모두 컴파일·리소스·jar이고 시험·검사는 겹치지 않는다. Refs: design-docs ci/05-backend-ci-speed-handoff.md 4.1·6.1·7.1절 (BE-5) --- .gitea/workflows/main.yml | 70 +++++-- docs/work/reference/gates.md | 2 +- scripts/ci/done-build-inputs.py | 103 ++++++++++ scripts/tests/test_done_build_inputs.py | 259 ++++++++++++++++++++++++ 4 files changed, 414 insertions(+), 20 deletions(-) create mode 100644 scripts/ci/done-build-inputs.py create mode 100644 scripts/tests/test_done_build_inputs.py diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 9a372cd3..c4b17cd1 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -2,10 +2,12 @@ # happened — but it fails loudly, after the change it reports on (owner decision 2026-09-16). # # On every push to main: the main stage, the container lanes, the build-logic tests, configuration -# cache, links and the dependency scan. Nightly (and on a manual run) also the jobs that need a matrix -# or an environment the stage tasks do not have, and last the performance lanes, which need a -# machine nothing else is using: the runner takes one job at a time, and the performance job is the -# last one in this file (owner decision 2026-11-07; the job says why not `needs`). +# cache, links, the dependency scan, and the pull-request stage once more to fill the build cache +# (`done`, not a gate; it stops early when only documentation changed since the last one that got +# through). Nightly (and on a manual run) also the jobs that need a matrix or an environment the +# stage tasks do not have, and last the performance lanes, which need a machine nothing else is +# using: the runner takes one job at a time, and the performance job is the last one in this file +# (owner decision 2026-11-07; the job says why not `needs`). # # Which lanes a stage means is decided by its Gradle task (build.gradle). The stage jobs (`main` # for the main and integration stages, `performance`) run them as one line; @@ -131,6 +133,51 @@ jobs: - uses: ./.gitea/actions/setup-java-gradle - run: ./gradlew :adapter:outbound:httpclient:test -Phttp3.tests.enabled=true + # Not a gate: the pull-request stage once more, on main, so that a pull request finds main's + # results in the build cache and runs only what its change touches. setup-gradle keys its cache by + # job name and a job first restores the newest entry of its own name, so this job is named after + # pr.yml's one job. Main saves, a pull request only reads (.gitea/actions/setup-java-gradle). + # + # On every push, not only nightly. With one save a night, a pull request reran what the day's + # merges had changed until the next night, and nearly everything after a build-logic change + # (2026-11-19: 69 tasks from cache and 9 to 12 minutes of :prCheck, against 266 and under 2 right + # after the nightly). This job restores the newest entry, so it reruns only what changed since. + # + # A push stops after checkout with one `건너뜀:` line when its build inputs (every file but the + # documentation; scripts/ci/done-build-inputs.py says which) have the key the newest marker holds, + # and runs otherwise. A marker is a small entry holding the inputs' key of a `done` job on main + # that succeeded; actions/cache saves it at the end of that job, after setup-gradle's save when + # Gradle ran, so the newest marker and the newest Gradle entry come from the same job. After a run + # that changed the build inputs and did not get through, or after a revert of a change whose run + # did, the newest marker holds other inputs and the push runs, documentation only or not; so does + # an answer that is missing. The marker cannot tell whether that Gradle entry is still there + # (setup-gradle only warns when it cannot save, and the cache limit can push the large entry out + # first): then pull requests miss until the next code push or the nightly. Nightly and manual runs + # always run; on main they leave a marker too. + done: + runs-on: ubuntu-latest + timeout-minutes: 75 + steps: + - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 + # A key of its own each run: a saved key is never written again, so the restore falls back by + # prefix to the newest marker, and a rerun of a run that got through finds its own. The + # repository is in the key, ended by a `/` no repository name has, in case the runner's cache + # is shared with other repositories. + - if: ${{ github.ref == 'refs/heads/main' }} + uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache@v4.3.0 + with: + path: build/done-cache-marker + key: done-marker-${{ github.repository }}/${{ github.run_id }} + restore-keys: done-marker-${{ github.repository }}/ + - id: inputs + env: + EVENT: ${{ github.event_name }} + run: python3 scripts/ci/done-build-inputs.py + - if: ${{ steps.inputs.outputs.run != 'false' }} + uses: ./.gitea/actions/setup-java-gradle + - if: ${{ steps.inputs.outputs.run != 'false' }} + run: ./gradlew :prCheck + # --------------------------------------------------------------------------------------------- # Nightly and manual runs only. @@ -329,21 +376,6 @@ jobs: - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - run: bash scripts/run-compose-runtime-smoke.sh --matrix src/bootstrap/app/compose-lanes/compose-profile-contracts.json - # Not a gate: the pull-request stage once more, on main, so that a pull request finds main's - # results in the build cache and runs only what its change touches. setup-gradle keys its cache by - # job name and a job first restores the newest entry of its own name, so this job is named after - # pr.yml's one job. Main saves, a pull request only reads (.gitea/actions/setup-java-gradle). - # Nightly and manual runs only: a push does not wait for it, and a pull request after a day's - # merges reruns the modules those changed. - done: - if: ${{ github.event_name != 'push' }} - runs-on: ubuntu-latest - timeout-minutes: 75 - steps: - - uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - - uses: ./.gitea/actions/setup-java-gradle - - run: ./gradlew :prCheck - # Load, slow-client, shutdown, pool and resource bounds. Last, after every other heavy job of the # run, so the bounds are measured on a runner that is not building something else. # diff --git a/docs/work/reference/gates.md b/docs/work/reference/gates.md index 2eeff877..71cd899a 100644 --- a/docs/work/reference/gates.md +++ b/docs/work/reference/gates.md @@ -23,7 +23,7 @@ Gradle 명령과 `scripts/verify.sh`는 모두 저장소 루트(Gradle 루트) | `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 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절 (다)다. +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`은 게이트가 아니다: main push와 nightly마다 main에서 `:prCheck`를 한 번 더 돌려 빌드 캐시를 채우고, 같은 이름의 PR job이 그 캐시를 읽는다(setup-gradle이 job 이름으로 캐시를 찾는다). 그래서 PR은 main이 마지막으로 채운 결과와 입력이 다른 태스크만 다시 돈다. push의 빌드 입력(문서를 뺀 모든 추적 파일. 문서는 `docs/`·`.claude/` 아래와 소스 세트 밖 `*.md`)이 가장 최근에 성공한 `done` job과 같으면 checkout 뒤 `건너뜀: done — …` 한 줄을 남기고 `:prCheck`를 돌지 않는다. 성공한 job은 끝에 자기 빌드 입력 키를 담은 작은 표식 캐시 항목을 남기고, 다음 job은 가장 최근 표식과 지금 키가 같을 때만 건너뛴다(`scripts/ci/done-build-inputs.py`). 빌드 입력을 바꾼 run이 끝까지 가지 못했으면 다음 push는 문서만 바꿨어도 돈다. 끝까지 간 변경을 되돌린 push도 돈다(가장 최근 표식은 되돌리기 전 입력이다). 표식은 그 job의 Gradle 캐시 항목이 아직 남았는지는 모른다: 저장이 실패했거나 캐시 상한에 밀려났으면 다음 코드 push나 nightly까지 PR이 캐시를 못 받는다. nightly·수동 run은 늘 돈다. 도구를 내려받거나 runner 환경이 필요해 `verify.sh`에 넣지 않았다. 손으로 돌리는 법은 3절 (다)다. 게이트 하나씩: diff --git a/scripts/ci/done-build-inputs.py b/scripts/ci/done-build-inputs.py new file mode 100644 index 00000000..465eefe2 --- /dev/null +++ b/scripts/ci/done-build-inputs.py @@ -0,0 +1,103 @@ +"""Says whether main.yml's `done` job would put anything new in the build cache on this run. + +Called by the `done` job of .gitea/workflows/main.yml, after checkout and the marker restore, before +Java and Gradle are set up. That job is not a gate: it runs the pull-request stage on main so that a +pull request finds main's results in the build cache (docs/work/reference/gates.md). The marker is a +small cache entry that every job on main that gets through saves at its end, after the Gradle cache +when it ran Gradle, holding the key of the build inputs it had. The restore brings back the newest. + +The build inputs are every tracked file but the documentation: paths under docs/ or .claude/, and +Markdown files outside a source set (`/src//`, where a Markdown file is a resource or +test fixture). Their key is a digest of their paths, modes and blob ids at HEAD. A push skips, with +one `건너뜀:` line, exactly when the newest marker holds the same key; anything else runs, and so +does a run that is not a push. After a run that changed the build inputs and did not get through, +the next push runs even if it changed documentation only. A push that reverts a change whose run got +through runs too: the newest marker holds the inputs from before the revert. Running is the safe side. + +What the marker cannot tell: whether that job's Gradle entry is still in the cache (setup-gradle only +warns when it cannot save, and the cache limit can push the large entry out first). Then pull +requests miss until the next code push or the nightly, which always runs. A few pull-request tests +declare documents under docs/ as inputs (registries, runbooks, ADRs, API surface baselines; +`git grep -n docs/ -- '*.gradle'` shows where); after a push that changed only those, the next pull +request reruns those tests. The cache changes how long a run takes, never what it decides. + +Writes `run=true` or `run=false` to $GITHUB_OUTPUT, prints one line, and writes this run's key to the +marker file for the cache step to save. Fails when $GITHUB_OUTPUT is not set or Git cannot list HEAD, +so the job stops with an error instead of deciding without a key. + + EVENT= GITHUB_OUTPUT= python3 scripts/ci/done-build-inputs.py +""" + +from __future__ import annotations + +import hashlib +import os +import subprocess +import sys +from pathlib import Path + +JOB = "done" +# The path main.yml's marker step restores and saves. Relative to the checkout, so the cache version, +# which hashes the path as written, is the same in every run; build/ is ignored, so no check sees it. +MARKER = Path("build/done-cache-marker") + + +def is_documentation(path: str) -> bool: + if path.startswith(("docs/", ".claude/")): + return True + if "/src/" in path: + return False + return path.endswith(".md") + + +def tracked_entries() -> list[tuple[str, str]]: + """(path, `mode type id`) for every tracked file at HEAD.""" + listing = subprocess.run(["git", "ls-tree", "-r", "-z", "--full-tree", "HEAD"], capture_output=True, check=True) + entries = [] + for line in listing.stdout.decode("utf-8", "surrogateescape").split("\0"): + if line: + meta, path = line.split("\t", 1) + entries.append((path, meta)) + return entries + + +def build_inputs_key() -> str: + inputs = [f"{meta}\t{path}" for path, meta in tracked_entries() if not is_documentation(path)] + digest = hashlib.sha256("\0".join(inputs).encode("utf-8", "surrogateescape")).hexdigest() + return f"{JOB}-build-inputs-{digest}" + + +def newest_marker() -> str: + """The key the newest marker holds, or '' when the restore found none.""" + try: + return MARKER.read_text(encoding="utf-8").strip() + except FileNotFoundError: + return "" + + +def decide(event: str, key: str, marker: str) -> tuple[bool, str]: + """(run, the line to print).""" + if event != "push": + return True, f"{JOB}: {event or '이벤트 없음'} run이라 :prCheck를 돈다 (빌드 입력 {key})" + if marker == key: + return False, f"건너뜀: {JOB} — 가장 최근에 끝까지 간 {JOB} job과 빌드 입력(문서를 뺀 파일)이 같다 ({key})" + return True, f"{JOB}: 빌드 입력 {key}가 가장 최근 표식 {marker or '(없음)'}과 달라 :prCheck를 돈다" + + +def main() -> int: + output = os.environ.get("GITHUB_OUTPUT") + if not output: + print(f"{JOB}: GITHUB_OUTPUT가 없어 판정을 넘길 수 없다", file=sys.stderr) + return 1 + key = build_inputs_key() + run, line = decide(os.environ.get("EVENT", ""), key, newest_marker()) + MARKER.parent.mkdir(parents=True, exist_ok=True) + MARKER.write_text(f"{key}\n", encoding="utf-8") + with open(output, "a", encoding="utf-8") as stream: + stream.write(f"run={'true' if run else 'false'}\n") + print(line) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/tests/test_done_build_inputs.py b/scripts/tests/test_done_build_inputs.py new file mode 100644 index 00000000..6ce3e5c5 --- /dev/null +++ b/scripts/tests/test_done_build_inputs.py @@ -0,0 +1,259 @@ +"""scripts/ci/done-build-inputs.py의 시험. 키가 문서를 뺀 파일만 따르는지, 가장 최근 표식과 같은 push만 건너뛰는지, +main.yml `done`이 그 판정·표식 파일을 그대로 쓰는지 본다. + +workflow는 checkout을 기본 깊이 1로 하므로, 그 깊이로 clone한 사본에서도 같은 키인지 본다. + + python3 -m unittest discover -s scripts/tests +""" + +from __future__ import annotations + +import importlib.util +import os +import re +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +SCRIPT = ROOT / "scripts/ci/done-build-inputs.py" +WORKFLOW = ROOT / ".gitea/workflows/main.yml" +_spec = importlib.util.spec_from_file_location("done_build_inputs", SCRIPT) +done_build_inputs = importlib.util.module_from_spec(_spec) +sys.modules["done_build_inputs"] = done_build_inputs +_spec.loader.exec_module(done_build_inputs) + +# The developer's global git settings (hooks, signing) must not reach the throwaway repositories. +GIT_ENV = { + **os.environ, + "GIT_CONFIG_GLOBAL": os.devnull, + "GIT_CONFIG_NOSYSTEM": "1", + "GIT_AUTHOR_NAME": "test", + "GIT_AUTHOR_EMAIL": "test@example.invalid", + "GIT_COMMITTER_NAME": "test", + "GIT_COMMITTER_EMAIL": "test@example.invalid", +} + + +class Repository: + """A throwaway repository with a source file, a script and a document on main, ignoring build/ as this one does.""" + + def __init__(self) -> None: + self._directory = tempfile.TemporaryDirectory() + self.root = Path(self._directory.name) / "origin" + self.git("init", "-q", "-b", "main", str(self.root), cwd=Path(self._directory.name)) + self.write("src/adapter/inbound/web/src/main/java/Web.java", "class Web {}\n") + self.write("scripts/check.sh", "true\n") + self.write("docs/guide.md", "# guide\n") + self.write(".gitignore", "build/\n") + self.commit("first") + + def git(self, *args: str, cwd: Path | None = None) -> str: + return subprocess.run(["git", *args], cwd=cwd or self.root, env=GIT_ENV, check=True, + capture_output=True, text=True).stdout.strip() + + def write(self, path: str, text: str) -> None: + target = self.root / path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(text, encoding="utf-8") + + def commit(self, message: str) -> None: + self.git("add", "-A") + self.git("commit", "-q", "--allow-empty", "-m", message) + + def shallow_clone(self) -> Path: + target = Path(self._directory.name) / "depth-1" + self.git("clone", "-q", "--depth=1", "--branch", "main", self.root.as_uri(), str(target), + cwd=Path(self._directory.name)) + return target + + def run_script(self, event: str = "push", marker: str | None = None, cwd: Path | None = None, + output: bool = True) -> subprocess.CompletedProcess[str]: + """Runs the script as the job does: `marker` is what the restore brought back, None for nothing.""" + where = cwd or self.root + marker_file = where / done_build_inputs.MARKER + if marker is None: + marker_file.unlink(missing_ok=True) + else: + marker_file.parent.mkdir(parents=True, exist_ok=True) + marker_file.write_text(f"{marker}\n", encoding="utf-8") + env = {key: value for key, value in GIT_ENV.items() if key not in ("GITHUB_OUTPUT", "EVENT")} + env["EVENT"] = event + if output: + self.output_file.write_text("", encoding="utf-8") + env["GITHUB_OUTPUT"] = str(self.output_file) + return subprocess.run([sys.executable, str(SCRIPT)], cwd=where, env=env, capture_output=True, text=True) + + @property + def output_file(self) -> Path: + return Path(self._directory.name) / "github-output" + + def decide(self, event: str = "push", marker: str | None = None) -> tuple[str, list[str]]: + """(the GITHUB_OUTPUT text, the printed lines).""" + result = self.run_script(event, marker) + if result.returncode != 0: + raise AssertionError(result.stderr) + return self.output_file.read_text(encoding="utf-8"), result.stdout.splitlines() + + def key(self, cwd: Path | None = None) -> str: + """The key this run writes to the marker file for the save.""" + result = self.run_script(cwd=cwd) + if result.returncode != 0: + raise AssertionError(result.stderr) + return ((cwd or self.root) / done_build_inputs.MARKER).read_text(encoding="utf-8").strip() + + def close(self) -> None: + self._directory.cleanup() + + +class DocumentationPathTest(unittest.TestCase): + def test_documents_and_guidance_are_documentation(self) -> None: + for path in ("docs/guide.md", "docs/registries/env-keys.yaml", "docs/ledger/estimates.jsonl", + ".claude/settings.json", ".claude/skills/desktop-gates/SKILL.md", "README.md", "AGENTS.md", + "src/adapter/inbound/web/README.md", "src/adapter/inbound/web/AGENTS.md", + "build-logic/AGENTS.md", ".github/dependency-vulnerability-policy.md"): + with self.subTest(path=path): + self.assertTrue(done_build_inputs.is_documentation(path)) + + def test_everything_the_build_or_a_workflow_reads_is_not(self) -> None: + for path in ("src/adapter/inbound/web/src/main/java/Web.java", + "src/bootstrap/app/src/test/resources/developer-experience/broken-readme.md", + "build-logic/src/main/resources/notes.md", "build.gradle", "settings.gradle", + "gradle/libs.versions.toml", "gradle/modules.json", "config/checkstyle/checkstyle.xml", + ".gitea/workflows/main.yml", "scripts/ci/done-build-inputs.py", "Dockerfile", "compose/app.yml", + ".tool-versions"): + with self.subTest(path=path): + self.assertFalse(done_build_inputs.is_documentation(path)) + + +class KeyTest(unittest.TestCase): + def setUp(self) -> None: + self.repo = Repository() + self.addCleanup(self.repo.close) + self.first = self.repo.key() + + def test_a_change_to_documents_only_keeps_the_key(self) -> None: + self.repo.write("docs/guide.md", "# guide, again\n") + self.repo.write(".claude/rules/docs.md", "# rule\n") + self.repo.write("src/adapter/inbound/web/README.md", "# web\n") + self.repo.commit("docs") + + self.assertEqual(self.first, self.repo.key()) + + def test_a_change_to_any_build_input_changes_the_key(self) -> None: + changes = { + "source": lambda: self.repo.write("src/adapter/inbound/web/src/main/java/Web.java", "final class Web {}\n"), + "new file": lambda: self.repo.write("gradle/libs.versions.toml", "[versions]\n"), + "source-set document": lambda: self.repo.write( + "src/bootstrap/app/src/test/resources/developer-experience/broken-readme.md", "# fixture\n"), + "mode": lambda: (self.repo.root / "scripts/check.sh").chmod(0o755), + "moved into docs": lambda: self.repo.git("mv", "scripts/check.sh", "docs/check.sh"), + } + for name, change in changes.items(): + with self.subTest(change=name): + before = self.repo.key() + change() + self.repo.commit(name) + self.assertNotEqual(before, self.repo.key()) + + def test_a_clone_one_commit_deep_has_the_same_key(self) -> None: + self.repo.write("src/adapter/inbound/web/src/main/java/Web.java", "final class Web {}\n") + self.repo.commit("code") + + self.assertEqual(self.repo.key(), self.repo.key(cwd=self.repo.shallow_clone())) + + def test_the_key_has_its_name_and_a_sha256_digest(self) -> None: + self.assertRegex(self.first, r"^done-build-inputs-[0-9a-f]{64}$") + + +class DecisionTest(unittest.TestCase): + def setUp(self) -> None: + self.repo = Repository() + self.addCleanup(self.repo.close) + self.first = self.repo.key() + + def test_a_push_with_the_newest_markers_inputs_skips_with_one_skip_line(self) -> None: + self.repo.write("docs/guide.md", "# guide, again\n") + self.repo.commit("docs") + + output, printed = self.repo.decide(marker=self.first) + + self.assertEqual("run=false\n", output) + self.assertEqual([f"건너뜀: done — 가장 최근에 끝까지 간 done job과 빌드 입력(문서를 뺀 파일)이 같다 ({self.first})"], + printed) + + def test_a_push_with_other_inputs_or_no_marker_runs(self) -> None: + self.repo.write("src/adapter/inbound/web/src/main/java/Web.java", "final class Web {}\n") + self.repo.commit("code") + for marker in (self.first, None, ""): + with self.subTest(marker=marker): + output, printed = self.repo.decide(marker=marker) + self.assertEqual("run=true\n", output) + self.assertEqual(1, len(printed)) + self.assertIn(":prCheck를 돈다", printed[0]) + + def test_a_revert_runs_because_the_newest_marker_is_the_reverted_change(self) -> None: + self.repo.write("src/adapter/inbound/web/src/main/java/Web.java", "final class Web {}\n") + self.repo.commit("code") + reverted = self.repo.key() + self.repo.git("revert", "--no-edit", "HEAD") + + self.assertEqual(self.first, self.repo.key()) + self.assertEqual("run=true\n", self.repo.decide(marker=reverted)[0]) + + def test_a_scheduled_or_manual_run_always_runs(self) -> None: + for event in ("schedule", "workflow_dispatch", ""): + with self.subTest(event=event): + self.assertEqual("run=true\n", self.repo.decide(event=event, marker=self.first)[0]) + + def test_it_leaves_its_own_key_in_the_marker_file_for_the_save(self) -> None: + self.repo.write("src/adapter/inbound/web/src/main/java/Web.java", "final class Web {}\n") + self.repo.commit("code") + + self.repo.decide(marker=self.first) + + marker = (self.repo.root / done_build_inputs.MARKER).read_text(encoding="utf-8") + self.assertNotEqual(f"{self.first}\n", marker) + self.assertRegex(marker, r"^done-build-inputs-[0-9a-f]{64}\n$") + + def test_without_an_output_file_or_a_repository_it_fails(self) -> None: + self.assertNotEqual(0, self.repo.run_script(output=False).returncode) + with tempfile.TemporaryDirectory() as elsewhere: + self.assertNotEqual(0, self.repo.run_script(cwd=Path(elsewhere)).returncode) + + +class WorkflowWiringTest(unittest.TestCase): + """main.yml's `done` restores the newest marker where the script reads it, and runs unless the script says skip.""" + + def setUp(self) -> None: + text = WORKFLOW.read_text(encoding="utf-8") + match = re.search(r"^ done:\n(?P(?: .*\n|\n)+)", text, re.MULTILINE) + self.assertIsNotNone(match, "main.yml has no `done` job") + self.job = match.group("body") + + def test_the_marker_is_restored_on_main_before_the_script_at_the_path_it_reads(self) -> None: + marker = (" - if: ${{ github.ref == 'refs/heads/main' }}\n" + " uses: https://github.com/actions/cache@") + script = (" - id: inputs\n env:\n EVENT: ${{ github.event_name }}\n" + " run: python3 scripts/ci/done-build-inputs.py\n") + self.assertIn(marker, self.job) + self.assertIn(script, self.job) + self.assertLess(self.job.index(marker), self.job.index(script)) + self.assertIn(f" path: {done_build_inputs.MARKER.as_posix()}\n", self.job) + # A key per run, so the save is never refused and the restore takes the newest marker by prefix. + # `/` ends the repository name, so another repository whose name starts with this one never matches. + self.assertIn(" key: done-marker-${{ github.repository }}/${{ github.run_id }}\n", self.job) + self.assertIn(" restore-keys: done-marker-${{ github.repository }}/\n", self.job) + + def test_gradle_runs_unless_the_script_said_skip(self) -> None: + run = "${{ steps.inputs.outputs.run != 'false' }}" + self.assertEqual([run, run], re.findall(r"^ - if: (\$\{\{ steps\..*)$", self.job, re.MULTILINE)) + self.assertIn(f" - if: {run}\n uses: ./.gitea/actions/setup-java-gradle\n", self.job) + self.assertIn(f" - if: {run}\n run: ./gradlew :prCheck\n", self.job) + self.assertNotRegex(self.job, r"(?m)^ if:", "a job-level condition would skip the whole job quietly") + + +if __name__ == "__main__": + unittest.main() -- 2.54.0 From 9b76a3b4a864595811c57f0c35517e9c921959ea Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 00:44:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?docs(ledger):=20#52=EA=B0=80=20=EA=B3=A0?= =?UTF-8?q?=EC=B9=9C=20links=20=ED=9D=94=EB=93=A4=EB=A6=BC=20=EC=A4=84?= =?UTF-8?q?=EC=97=90=20fixed=5Fby=EB=A5=BC=20=EC=B1=84=EC=9A=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 11-19 run 362 links(lychee) 시간 초과 줄의 fixed_by를 「백엔드 #52」로 채운다. #52는 9709404d로 병합됐고, 그 main run 388의 links job은 success(8초)였다. --- docs/ledger/flaky-tests.jsonl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ledger/flaky-tests.jsonl b/docs/ledger/flaky-tests.jsonl index a65ddd51..62073d1c 100644 --- a/docs/ledger/flaky-tests.jsonl +++ b/docs/ledger/flaky-tests.jsonl @@ -6,4 +6,4 @@ {"date": "2026-11-13", "test": "MinioS3ManagedObjectProviderContractTest#initializationError", "category": "fixed-time", "first_run": "304", "verdict": "재현 안 됨(desktop 1코어 기아 3회 통과, 첫 createBucket 최대 1.94초/acquire 2초)", "quarantined_until": "", "fixed_by": "백엔드 #49"} {"date": "2026-11-13", "test": "MinioManagedObjectFaultTest#connectionCutProducesABoundedFailureAndRecoveryWithoutMutationReplay", "category": "fixed-time", "first_run": "310", "verdict": "desktop 1코어 기아 3회 중 3회 실패(첫 createBucket 3.2~3.8초/apiCallTimeout 2초)", "quarantined_until": "", "fixed_by": "백엔드 #49"} {"date": "2026-11-18", "test": "InboxRedeliveryIntegrationTest#initializationError", "category": "concurrency-order", "first_run": "330", "verdict": "runner 같은 날 3회 중 1회 실패(nightly 324·main 327 통과). Kafka 기동 반복문이 복사가 끝나기 전의 스크립트를 실행해 exit 126(testcontainers-java #11682). lane 반복은 돌리지 않았다. docker CLI 탐침으로 부하 아래 원래 반복문 100회 중 0회 실패, sleep 뺀 반복문 50회 중 42회 실패(모두 exit 126, Text file busy)", "quarantined_until": "", "fixed_by": "백엔드 #50"} -{"date": "2026-11-19", "test": "main.yml links (lychee) — man7.org openat2.2, jdbc.postgresql.org documentation/ssl·use", "category": "external", "first_run": "362", "verdict": "외부 사이트 시간 초과 3건, 오류 0건(기본 재시도 3회를 다 씀). 다음 run 367은 시간 초과 0. 노트북 curl 9회 모두 200(0.4~1.3초)으로 재현 안 됨. 링크는 살아 있다", "quarantined_until": "", "fixed_by": ""} +{"date": "2026-11-19", "test": "main.yml links (lychee) — man7.org openat2.2, jdbc.postgresql.org documentation/ssl·use", "category": "external", "first_run": "362", "verdict": "외부 사이트 시간 초과 3건, 오류 0건(기본 재시도 3회를 다 씀). 다음 run 367은 시간 초과 0. 노트북 curl 9회 모두 200(0.4~1.3초)으로 재현 안 됨. 링크는 살아 있다", "quarantined_until": "", "fixed_by": "백엔드 #52"} -- 2.54.0