From d9d1cfb55af99a35592f36dde07e39ab52177a48 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 8 Nov 2026 14:08:07 +0900 Subject: [PATCH] =?UTF-8?q?ci(buf):=20=EC=84=A0=EC=96=B8=ED=95=9C=20?= =?UTF-8?q?=EA=B9=A8=EC=A7=80=EB=8A=94=20schema=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EB=A7=8C=20bufBreaking=EC=9D=84=20=ED=86=B5=EA=B3=BC=EC=8B=9C?= =?UTF-8?q?=ED=82=A8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bufBreaking은 기준(PR이면 merge base, main이면 직전 커밋)과 schema를 비교해 깨짐이면 무조건 실패했다. 그래서 일부러 깨는 변경(바로 앞 커밋의 proto 패키지 이름 바꾸기 같은 것)은 PR도 병합 뒤 main도 빨갛게 만들고, 통과시킬 길이 기준을 손으로 바꾸는 것뿐이었다. 기준과 HEAD 사이 커밋 하나가 `BREAKING CHANGE:` 꼬리말로 선언하면 통과시킨다. 커밋 규칙이 이미 깨지는 변경에 요구하는 표시이고, 그 표시가 MAJOR 버전의 근거다(docs/work/release.md 2절). 선언 없는 깨짐은 전처럼 실패하고, 고치는 길(되돌리기 또는 선언)을 말한다. 버린 대안: 첫 릴리스 전에는 검사를 끄기(태그 뒤의 첫 깨짐을 놓친다), 마지막 릴리스 태그와 비교(한 번 선언한 깨짐 뒤로 다음 릴리스까지 모든 PR이 빨개진다). 검증(desktop): HEAD c8f8721(BREAKING CHANGE 선언)과 기준 bbe49ac — 깨짐을 알리고 rc=0. 같은 트리에 꼬리말 없는 메시지로 바꾼 버리는 사본 — rc=1과 안내. gates.md 4절에 규칙을 적었다. --- scripts/buf.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/buf.sh b/scripts/buf.sh index eeda901..7c1a494 100755 --- a/scripts/buf.sh +++ b/scripts/buf.sh @@ -14,6 +14,7 @@ # (or when a local clone has no origin/main) # A baseline without grpc/grpc-contract/buf.yaml has nothing to be compatible with, and the check # says so and passes. A baseline Git cannot find fails: a shallow clone cannot answer the question. +# A break passes only when a commit between the baseline and HEAD declares it (`BREAKING CHANGE:`). set -euo pipefail root=$(git rev-parse --show-toplevel) @@ -55,7 +56,18 @@ case "${1:-}" in exit 0 fi echo "buf.sh: breaking against ${commit:0:12}" - "$buf" breaking --against "$root/.git#ref=$commit,subdir=$module" + if "$buf" breaking --against "$root/.git#ref=$commit,subdir=$module"; then + exit 0 + fi + # A breaking change passes only when a commit in the range declares it (commit rules: `!` in + # the title and a `BREAKING CHANGE:` trailer), which is also what makes it a MAJOR version + # (docs/work/release.md 2절). An undeclared one fails, so a wire break cannot slip in unnoticed. + if git log --format=%B "$commit..HEAD" | grep -q '^BREAKING CHANGE:'; then + echo "buf.sh: the schema breaks against ${commit:0:12}, and a commit in ${commit:0:12}..HEAD declares BREAKING CHANGE; passing." + exit 0 + fi + echo "buf.sh: breaking schema change against ${commit:0:12} that no commit declares. Undo it, or declare it (title '!', trailer 'BREAKING CHANGE:') and release it as MAJOR." >&2 + exit 1 ;; *) echo "usage: scripts/buf.sh lint|breaking" >&2