build: 템플릿 밖에서 혼자 빌드·배포되는 Gradle 루트를 만든다

옮겨 온 메시징 19개 모듈은 템플릿의 src/settings.gradle·build-logic·
카탈로그·registry에 기대고 있어 이 repo만으로는 빌드되지 않는다.
repo 루트를 Gradle 루트로 하는 단독 빌드를 만든다.

- build-logic/: grpc-library main 2e880c7의 줄인 사본(템플릿
  22df3525에서 복사, 템플릿 2959eff0까지의 변경도 같은 내용)에서
  gRPC BOM 규칙(ca.grpc-platform-module)만 뺐다. 배포 플러그인
  ca.library-publishing과 서명 키 해석(SigningKeys)은 그대로다.
  출처·뺀 것·고친 것은 build-logic/UPSTREAM.md.
- settings.gradle·build.gradle·gradle.properties: group
  dev.cakit.messaging, 단계 태스크 ci·mainCheck·releaseCheck와
  배포(release·releaseRehearsal·verifySigningKey)는 grpc-library와
  같은 모양이다. 메시징만 다른 점: Buf가 없고, 성능 lane이 없고,
  mainCheck와 releaseCheck가 브로커 인증 증거 게이트
  (verifyMessagingCertificationEvidence)를 부른다. 템플릿은 이 게이트를
  따로 messaging-certification.yml로 돌렸다. 그 workflow는 지운다.
- config/: registry 19행(source_path만 messaging/<leaf>로), 메시징
  클래스만 남긴 SpotBugs 제외 목록, 이미지 셋(postgres-16, kafka,
  toxiproxy, 모두 digest 고정), checkstyle 사본.
- gradle/libs.versions.toml: 메시징이 쓰는 항목만(avro, cloudevents,
  protobuf 4.33.2, toxiproxy, jmh)과 kafka-clients가 끌고 오는 취약
  버전을 덮는 pinned-lz4-java·pinned-snappy-java.
- 저장소 계약 테스트: MessagingPublicSurfaceContractTest(템플릿
  app-bootstrap에서 이력째 옮김)와 새 MessagingSettingsOwnerContractTest
  (app.messaging 주인은 starter 하나)를 messaging-testkit의
  repositoryContractTest lane에 둔다. check에 들어가 PR 단계에서 돈다.
- messaging-kafka: 인증 manifest 경로를 새 배치로 고친다.

버린 대안: 계약 테스트를 build-logic 테스트로 두는 안. 빌드 플러그인
시험과 모듈 계약이 섞이고, 소스·build.gradle을 입력으로 선언하는
기존 lane 장치를 쓸 수 없다.

위험: 이 커밋 단독으로는 lockfile을 다시 쓰지 않았다(뒤 커밋에서
desktop에서 쓴다). 패키지는 아직 dev.caskeleton.messaging이다.

검증: desktop ./gradlew projects rc=0(19개 모듈 포함).

Refs: design-docs repo-structure/05-library-repos.md 4·10.3·13.1절
This commit is contained in:
DongHyeonka
2026-11-08 16:11:52 +09:00
parent f593229fda
commit 2e9298ec33
87 changed files with 13862 additions and 78 deletions
+175
View File
@@ -0,0 +1,175 @@
#!/usr/bin/env bash
# Checks the release signing secrets before anything is signed, without printing them.
#
# scripts/release/check-signing-key.sh [expected fingerprint]
#
# Reads SIGNING_KEY (an ASCII-armoured PGP secret key) and SIGNING_PASSWORD from the environment and
# prints only shapes and verdicts: line and character counts, whether the armour lines and the blank
# line after BEGIN are where OpenPGP puts them, whether the base64 body decodes and its CRC24 matches,
# the first packet's tag, whether gpg imports it, the imported key's fingerprint (public), and whether
# SIGNING_PASSWORD signs with it. No value, line or fragment of either secret is ever printed; do not
# add `set -x` here.
#
# Why it exists: Gradle's signing reports any of these problems as one "Could not read PGP secret
# key", and the cause sits in a secret nobody can look at in the job log (v1.0.0 release run 9).
# Exit codes: 0 = the key would sign, 1 = a check failed (the line says which), 2 = usage.
set -euo pipefail
expected=${1:-}
fail=0
if [ -z "${SIGNING_KEY:-}" ]; then
echo "check-signing-key: SIGNING_KEY is empty or not set"
exit 1
fi
[ -n "${SIGNING_PASSWORD:-}" ] || echo "check-signing-key: SIGNING_PASSWORD is empty (only right for a key without a passphrase)"
# The passphrase's shape only: a pasted value often carries a line break or spaces the key was not
# protected with, and Gradle uses the value as given.
python3 - <<'PY' || fail=1
import os, sys
p = os.environ.get("SIGNING_PASSWORD", "")
print(f"password shape: {len(p)} characters, line breaks {p.count(chr(10))}, CR {p.count(chr(13))},"
f" leading whitespace {'yes' if p[:1].isspace() else 'no'}, trailing whitespace {'yes' if p[-1:].isspace() else 'no'},"
f" non-ASCII characters {sum(1 for c in p if ord(c) > 127)}")
if "-----BEGIN PGP" in p or len(p) > 1000:
print("PROBLEM: SIGNING_PASSWORD holds a PGP key block (or something as long), not the passphrase."
" Put in only the passphrase chosen when the key was made.")
sys.exit(1)
PY
home=$(mktemp -d)
trap 'rm -rf "$home"' EXIT
chmod 700 "$home"
KEY_OUT=$home/key.asc EXPECTED_FINGERPRINT=$expected python3 - <<'PY' || fail=1
import base64, os, re, sys
key = os.environ["SIGNING_KEY"]
BEGIN = "-----BEGIN PGP PRIVATE KEY BLOCK-----"
END = "-----END PGP PRIVATE KEY BLOCK-----"
problems = []
print(f"shape: {len(key)} characters, {key.count(chr(10)) + 1} lines,"
f" CR {'present' if chr(13) in key else 'absent'},"
f" literal backslash-n sequences {key.count(chr(92) + 'n')},"
f" non-ASCII characters {sum(1 for c in key if ord(c) > 127)},"
f" leading whitespace {'yes' if key[:1].isspace() else 'no'},"
f" trailing whitespace {'yes' if key[-1:].isspace() else 'no'}")
stripped = key.strip()
compact = re.sub(r"\s", "", key)
if "-----BEGIN" not in key and re.fullmatch(r"[A-Za-z0-9+/]+={0,2}", compact or "x"):
try:
unwrapped = base64.b64decode(compact).decode("utf-8")
except Exception:
unwrapped = ""
if unwrapped.strip().startswith("-----BEGIN PGP PRIVATE KEY BLOCK-----"):
print("form: base64 of an armoured key file on one value; the build unwraps it (SigningKeys), so the checks below read the unwrapped text")
key = unwrapped
stripped = key.strip()
print(f"unwrapped shape: {len(key)} characters, {key.count(chr(10)) + 1} lines")
if re.fullmatch(r"(0x)?[0-9A-Fa-f]{8}|(0x)?[0-9A-Fa-f]{16}|[0-9A-Fa-f]{40}", stripped):
expected = os.environ.get("EXPECTED_FINGERPRINT", "")
same = " (the release key's fingerprint)" if expected and stripped.upper() == expected.upper() else ""
print(f"PROBLEM: SIGNING_KEY holds a {len(stripped)}-hex-digit key ID or fingerprint{same}, not the key."
" Put in the output of `gpg --armor --export-secret-keys <fingerprint>` instead, BEGIN to END lines.")
sys.exit(1)
lines = key.replace("\r\n", "\n").replace("\r", "\n").split("\n")
while lines and lines[-1].strip() == "":
lines.pop()
if "\n" not in key.replace("\r", "\n"):
problems.append("the value is one line: the newlines were lost (paste the file as is, with its line breaks)")
first = lines[0].strip() if lines else ""
last = lines[-1].strip() if lines else ""
print(f"armour: first line is BEGIN {'yes' if first == BEGIN else 'no'}, last line is END {'yes' if last == END else 'no'}")
if first != BEGIN:
kind = "a PUBLIC key block" if "PUBLIC KEY BLOCK" in first else "something else"
problems.append(f"the value does not start with the BEGIN PGP PRIVATE KEY BLOCK line (it starts with {kind})")
if last != END:
problems.append("the value does not end with the END PGP PRIVATE KEY BLOCK line (cut short?)")
body = lines[1:-1] if first == BEGIN and last == END else lines
headers = []
while body and ":" in body[0] and body[0].strip():
headers.append(body.pop(0))
blank_after = bool(body) and body[0].strip() == ""
print(f"armour headers: {len(headers)}, blank line after them {'yes' if blank_after else 'no'}")
if not blank_after:
problems.append("no blank line between the BEGIN line (and its headers) and the base64 body")
data = [l.strip() for l in body if l.strip()]
checksum = data.pop() if data and data[-1].startswith("=") else None
lengths = [len(l) for l in data]
full = sum(1 for n in lengths[:-1] if n == lengths[0]) if lengths else 0
print(f"body: {len(data)} base64 lines, first {lengths[0] if lengths else 0} characters wide,"
f" {full + (1 if lengths else 0)} of {len(data)} lines that width or the last,"
f" checksum line {'present' if checksum else 'absent'}")
if lengths and any(n != lengths[0] for n in lengths[:-1]):
problems.append("base64 lines of different widths before the last one (lines joined, split or cut)")
joined = "".join(data)
bad = sum(1 for c in joined if not re.match(r"[A-Za-z0-9+/=]", c))
if bad:
problems.append(f"{bad} characters outside the base64 alphabet in the body")
try:
raw = base64.b64decode(joined, validate=False)
except Exception as error:
raw = b""
problems.append(f"the body does not decode as base64 ({type(error).__name__})")
if raw:
def crc24(data):
crc = 0xB704CE
for byte in data:
crc ^= byte << 16
for _ in range(8):
crc <<= 1
if crc & 0x1000000:
crc ^= 0x1864CFB
return crc & 0xFFFFFF
if checksum:
try:
stated = int.from_bytes(base64.b64decode(checksum[1:]), "big")
match = stated == crc24(raw)
except Exception:
match = False
print(f"CRC24 of the decoded body matches the checksum line: {'yes' if match else 'no'}")
if not match:
problems.append("the CRC24 checksum does not match: the base64 body was changed (a line lost, added or edited)")
header = raw[0]
tag = (header & 0x3F) if header & 0x40 else ((header & 0x3C) >> 2)
names = {5: "secret key", 6: "public key", 7: "secret subkey"}
print(f"first packet: tag {tag} ({names.get(tag, 'not a key packet')}), {len(raw)} bytes decoded")
if not header & 0x80 or tag != 5:
problems.append("the first packet is not a secret key packet (tag 5)")
for problem in problems:
print(f"PROBLEM: {problem}")
with open(os.environ["KEY_OUT"], "w", encoding="utf-8") as out:
out.write(key)
sys.exit(1 if problems else 0)
PY
if [ -s "$home/key.asc" ] && GNUPGHOME="$home" gpg --batch --quiet --import "$home/key.asc" >/dev/null 2>&1; then
fingerprint=$(GNUPGHOME="$home" gpg --batch --with-colons --list-secret-keys 2>/dev/null | awk -F: '/^fpr/{print $10; exit}')
echo "gpg import: ok, secret key fingerprint ${fingerprint:-none}"
if [ -n "$expected" ] && [ "${fingerprint:-}" != "$expected" ]; then
echo "PROBLEM: the imported key is not the release key ${expected}"
fail=1
fi
printf 'signing check\n' > "$home/message"
# gpg reads only the first line of the file; the shape line above says whether there is more.
printf '%s' "${SIGNING_PASSWORD:-}" > "$home/passphrase"
if GNUPGHOME="$home" gpg --batch --pinentry-mode loopback --passphrase-file "$home/passphrase" \
--status-fd 3 --local-user "${fingerprint:-none}" --detach-sign --output "$home/message.sig" \
"$home/message" >/dev/null 2>&1 3>"$home/status"; then
echo "signing with SIGNING_PASSWORD: ok"
else
# gpg's status keywords only (BAD_PASSPHRASE, MISSING_PASSPHRASE, ERROR …): no values.
status=$(awk '$1 == "[GNUPG:]" {print $2}' "$home/status" | sort -u | tr '\n' ' ')
echo "PROBLEM: SIGNING_PASSWORD does not unlock the key for signing (gpg status: ${status:-none})"
fail=1
fi
else
echo "PROBLEM: gpg cannot import SIGNING_KEY"
fail=1
fi
exit "$fail"
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
"""Checks a staged release (build/staging-repository) file by file before anything is uploaded.
check-staging.py <repository dir> <group> <version> signed|unsigned <artifact>...
For every module: the jar, sources and javadoc jars, POM and Gradle module file, each with its
.md5/.sha1/.sha256/.sha512 checksum (and .asc when signed), and every dependency in the POM and the
module file carries a version. The last check is the publishing trap the design names: the modules
declare most dependencies without a version and let a BOM fill it, and a published file written
from the declarations would leave consumers nothing to resolve. For the SBOM artifact
(messaging-library): its POM and the CycloneDX JSON.
"""
import json
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
CHECKSUMS = (".md5", ".sha1", ".sha256", ".sha512")
POM = "{http://maven.apache.org/POM/4.0.0}"
def expect(path: Path, signed: bool, problems: list[str]) -> None:
if not path.is_file():
problems.append(f"missing {path.name}")
return
for suffix in CHECKSUMS + ((".asc",) if signed else ()):
if not path.with_name(path.name + suffix).is_file():
problems.append(f"missing {path.name}{suffix}")
def unversioned_pom(pom: Path) -> list[str]:
root = ET.parse(pom).getroot()
out = []
for dependency in root.iter(f"{POM}dependency"):
version = dependency.findtext(f"{POM}version")
if not version or not version.strip():
out.append(f"{dependency.findtext(f'{POM}groupId')}:{dependency.findtext(f'{POM}artifactId')}")
return out
def unversioned_module(module: Path) -> list[str]:
data = json.loads(module.read_text(encoding="utf-8"))
out = []
for variant in data.get("variants", []):
for dependency in variant.get("dependencies", []):
version = dependency.get("version") or {}
if not any(version.get(k) for k in ("requires", "strictly", "prefers")):
out.append(f"{variant['name']}: {dependency['group']}:{dependency['module']}")
return out
def main() -> int:
if len(sys.argv) < 6:
print(__doc__, file=sys.stderr)
return 2
repository, group, version, signing = Path(sys.argv[1]), sys.argv[2], sys.argv[3], sys.argv[4]
signed = signing == "signed"
failed = False
for artifact in sys.argv[5:] + ["messaging-library"]:
directory = repository / group.replace(".", "/") / artifact / version
base = directory / f"{artifact}-{version}"
problems: list[str] = []
if artifact == "messaging-library":
expect(base.with_name(base.name + ".pom"), signed, problems)
expect(base.with_name(base.name + "-cyclonedx.json"), signed, problems)
else:
for suffix in (".jar", "-sources.jar", "-javadoc.jar", ".pom", ".module"):
expect(base.with_name(base.name + suffix), signed, problems)
pom, module = base.with_name(base.name + ".pom"), base.with_name(base.name + ".module")
if pom.is_file():
problems += [f"POM dependency without a version: {d}" for d in unversioned_pom(pom)]
if module.is_file():
problems += [f"module dependency without a version: {d}" for d in unversioned_module(module)]
if problems:
failed = True
print(f"{group}:{artifact}:{version}", file=sys.stderr)
for problem in problems:
print(f" - {problem}", file=sys.stderr)
else:
print(f"staged: {group}:{artifact}:{version}{' (signed)' if signed else ''}")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# The release's software bill of materials: one CycloneDX JSON for the version, from the committed
# lockfiles of the published modules (build-logic is a build tool and is not shipped). Made before
# the blocking vulnerability check, so a failed release can still say what it would have shipped.
#
# scripts/release/sbom.sh <output file>
set -euo pipefail
root=$(git rev-parse --show-toplevel)
output=${1:?usage: sbom.sh <output file>}
mkdir -p "$(dirname "$output")"
trivy=$("$root/scripts/tool.sh" trivy)
cd "$root"
"$trivy" fs --skip-version-check --format cyclonedx --skip-dirs build-logic --output "$output" .
python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d.get("bomFormat")=="CycloneDX" and d.get("components"), "empty SBOM"; print("sbom:", len(d["components"]), "components")' "$output"
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# After `publish`: every module's maven-metadata.xml, fetched anonymously, lists the new version.
# Anonymous on purpose: consumers (the backend template, its image build) read without a token, so a
# package only the owner can read is not published.
#
# scripts/release/verify-published.sh <repository url> <group> <version> <artifact>...
set -euo pipefail
url=${1:?}; group=${2:?}; version=${3:?}; shift 3
[ $# -gt 0 ] || { echo "verify-published: no artifacts named" >&2; exit 2; }
path=${group//.//}
missing=0
for artifact in "$@"; do
metadata=$(curl --fail --show-error --silent --location --retry 3 "$url/$path/$artifact/maven-metadata.xml" || true)
if grep -q "<version>$version</version>" <<<"$metadata"; then
echo "published: $group:$artifact:$version"
else
echo "verify-published: $group:$artifact:$version is not in $url/$path/$artifact/maven-metadata.xml" >&2
missing=1
fi
done
exit "$missing"
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# The release's dependency gate over the committed lockfiles, the backend template's policy:
# 1. HIGH and CRITICAL fail.
# 2. MEDIUM and LOW are reported and do not fail.
# 3. Any finding listed in the CISA Known Exploited Vulnerabilities catalog fails, whatever its
# severity. An unreachable or malformed catalog fails too: a cross-check that did not run must
# not read as "no match".
# Suppressions: .trivyignore.yaml only (each entry with a statement and an expiry).
#
# scripts/release/vulnerability-scan.sh <report directory>
set -euo pipefail
root=$(git rev-parse --show-toplevel)
out=${1:?usage: vulnerability-scan.sh <report directory>}
mkdir -p "$out"
trivy=$("$root/scripts/tool.sh" trivy)
cd "$root"
"$trivy" fs --skip-version-check --scanners vuln --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml .
"$trivy" fs --skip-version-check --scanners vuln --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml .
"$trivy" fs --skip-version-check --scanners vuln --severity CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN --exit-code 0 \
--ignorefile .trivyignore.yaml --format json --output "$out/trivy-all.json" .
kev_url=${KEV_FEED_URL:-https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json}
if ! curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
"$kev_url" --output "$out/kev.json"; then
echo "vulnerability-scan: KEV feed unavailable ($kev_url); set KEV_FEED_URL to an approved mirror." >&2
exit 1
fi
python3 - "$out/trivy-all.json" "$out/kev.json" <<'PY'
import json, re, sys
findings, kev = (json.load(open(p, encoding="utf-8")) for p in sys.argv[1:3])
ids = kev.get("vulnerabilities")
if not isinstance(ids, list) or not ids or kev.get("count") != len(ids):
sys.exit("vulnerability-scan: KEV feed is malformed, empty or count-inconsistent")
catalog = {v.get("cveID") for v in ids}
if not all(isinstance(c, str) and re.fullmatch(r"CVE-\d{4}-\d{4,}", c) for c in catalog):
sys.exit("vulnerability-scan: KEV feed holds an invalid cveID")
results = findings.get("Results")
if not isinstance(results, list) or not results:
sys.exit("vulnerability-scan: Trivy found no lockfile to scan")
found = {v["VulnerabilityID"] for r in results for v in (r.get("Vulnerabilities") or [])}
hits = sorted(found & catalog)
if hits:
sys.exit("vulnerability-scan: CISA KEV-listed vulnerability found regardless of severity: " + ", ".join(hits))
print(f"vulnerability-scan: {len(found)} finding(s) below HIGH, none in the KEV catalog ({len(catalog)} entries).")
PY
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Prints the path of a pinned, checksum-verified tool binary, downloading it once into
# ${TOOL_CACHE:-~/.cache/messaging-library}/<tool>-<version>/.
#
# scripts/tool.sh trivy
#
# A tool is a native binary, not a Maven artifact, so Gradle cannot resolve it; this is the one place
# that says which version and which bytes. A download whose SHA-256 differs from the one written here
# fails and leaves nothing behind. Exit codes: 0 = path printed, 1 = download or checksum failed,
# 2 = usage or unsupported machine.
set -euo pipefail
tool=${1:-}
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) arch=amd64 ;;
Linux-aarch64 | Linux-arm64) arch=arm64 ;;
*) echo "tool.sh: unsupported machine $(uname -s)-$(uname -m)" >&2; exit 2 ;;
esac
case "$tool" in
trivy)
# Trivy 0.71.2, the version and checksums the backend template's dependency-vulnerability.yml pins.
version=0.71.2
[ "$arch" = amd64 ] && asset="trivy_${version}_Linux-64bit.tar.gz" || asset="trivy_${version}_Linux-ARM64.tar.gz"
[ "$arch" = amd64 ] \
&& sha256=0510e71e2fd39bf863856d499c8dc19feb4e7336546394c502a8f5cc7ab27460 \
|| sha256=fe1c7106e15a5365d485b098a8c338f91e3b7ba71cb0e4963b98a3a098763cfc
url="${TRIVY_DOWNLOAD_BASE_URL:-https://github.com/aquasecurity/trivy/releases/download/v${version}}/${asset}"
archive=1
;;
*) echo "usage: scripts/tool.sh trivy" >&2; exit 2 ;;
esac
dir="${TOOL_CACHE:-$HOME/.cache/messaging-library}/${tool}-${version}"
binary="$dir/$tool"
if [ ! -x "$binary" ]; then
mkdir -p "$dir"
tmp=$(mktemp "$dir/.download.XXXXXX")
trap 'rm -f "$tmp"' EXIT
curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 "$url" --output "$tmp"
if ! printf '%s %s\n' "$sha256" "$tmp" | sha256sum -c - >/dev/null 2>&1; then
echo "tool.sh: $asset does not match the pinned SHA-256 $sha256" >&2
exit 1
fi
if [ "$archive" = 1 ]; then
tar -xzf "$tmp" -C "$dir" "$tool"
else
mv "$tmp" "$binary"
fi
chmod 0755 "$binary"
fi
printf '%s\n' "$binary"
+20 -16
View File
@@ -3,18 +3,20 @@
#
# scripts/verify.sh <단계> [--on here|<호스트>] [--log <이름>]
#
# 단계 무엇 채우는 곳
# docs 루트 지침·장부 검사 run_docs(뼈대에 기본 검사가 있다)
# unit 빠른 단위 시험 run_unit
# pr PR 전에 통과해야 하는 게이트 묶음 run_pr
# app 앱을 띄워 health와 기본 기능을 직접 확인 run_app
# 단계 무엇 Gradle
# docs 루트 지침·장부 검사 (없음)
# unit 모듈 check 전부(단위 시험·정적 분석·lane 포함) checkAll
# pr PR 단계 = pr.yml ci, verifyStrictLaneStages --dry-run
# main main 단계 = main.yml(Docker 필요) mainCheck
# release release.yml에서 올리기 직전까지(Docker 필요, 비밀 값 없이) releaseRehearsal
# 라이브러리라 띄울 앱이 없다. 템플릿 뼈대의 `app` 단계는 두지 않는다.
#
# --on <호스트>: 지금 작업 트리(커밋 안 된 변경 포함)를 패치로 그 호스트에 옮긴다. 기준 커밋에서 새 worktree를
# 만들어 패치를 적용하고, 트리 해시가 여기와 같은지 본 뒤 잠금 아래에서 같은 단계를 돌리고 worktree를 지운다.
# push하지 않는다. 기준 커밋은 원격 checkout이 fetch로 받을 수 있어야 한다(기본: origin/main과 갈라진 곳).
# 환경 변수: VERIFY_HOST(--on 기본값, 없으면 here), VERIFY_REMOTE_REPO(원격 checkout, 기본 ~/workspace/<repo 이름>),
# VERIFY_BASE_REF(기본 origin/main), VERIFY_LOCK(기본 /tmp/claude-gates/heavy.lock), VERIFY_SSH(기본 ssh).
# 종료 코드: 단계의 종료 코드. 2 = 사용법, 3 = 아직 채우지 않은 단계, 4 = 원격 준비 실패.
# 종료 코드: 단계의 종료 코드. 2 = 사용법, 4 = 원격 준비 실패.
set -euo pipefail
ROOT=$(git rev-parse --show-toplevel)
@@ -23,15 +25,10 @@ TMP_FILES=()
trap '[ ${#TMP_FILES[@]} -eq 0 ] || rm -f "${TMP_FILES[@]}"' EXIT # 빈 배열 + set -u는 옛 bash에서 오류다
usage() {
sed -n '2,19p' "$0" | sed 's/^# \{0,1\}//' >&2
sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//' >&2
exit 2
}
todo() {
echo "verify: '$1' 단계는 아직 정하지 않았다. scripts/verify.sh의 run_$1을 채운다." >&2
return 3
}
# ---------------------------------------------------------------- 단계 본문(프로젝트가 채운다)
run_docs() {
@@ -56,17 +53,24 @@ for n, line in enumerate(open(sys.argv[1], encoding="utf-8"), 1):
return "$rc"
}
run_unit() { todo unit; }
run_unit() { ./gradlew checkAll --console=plain; }
run_pr() { run_docs && run_unit && todo pr; }
run_pr() { run_docs && ./gradlew ci --console=plain && ./gradlew verifyStrictLaneStages --dry-run --console=plain; }
run_app() { todo app; }
run_main() { ./gradlew mainCheck --console=plain; }
# releaseCheck needs a release version and a commit id. The rehearsal uses 0.0.0 unless
# RELEASE_VERSION is given: a version no release tag (v1.0.0 onward) will ever name.
run_release() {
RELEASE_VERSION=${RELEASE_VERSION:-0.0.0} GIT_SHA=${GIT_SHA:-$(git rev-parse HEAD)} \
./gradlew releaseRehearsal --console=plain
}
# ---------------------------------------------------------------- 실행 위치
run_here() {
case "$1" in
docs | unit | pr | app) "run_$1" ;;
docs | unit | pr | main | release) "run_$1" ;;
*) usage ;;
esac
}