ci(buf): 선언한 깨지는 schema 변경만 bufBreaking을 통과시킨다
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절에 규칙을 적었다.
This commit is contained in:
+13
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user