ci!: workflow를 pr·main·release 셋으로 접고 단계 job 모양만 검사한다
workflow 15개(+ composite action, jq 설치 스크립트)가 모듈 모양으로 나뉘어 있었고, 그것을 읽는 판독기(ShellScript·WorkflowGradleInvocations· TaskSelectors, 운영 3,283줄과 그 시험 1,814줄)가 리뷰 라운드마다 새 셸 모양으로 결함을 냈다. 그런데 Gitea에서는 Actions가 꺼져 있어 workflow는 한 번도 돌지 않았다(design-docs repo-structure/03-ci.md 2.1·3.4절). 소유자가 정한 B안(같은 문서 7절, 11절 ①~⑧)대로 바꾼다. - .gitea/workflows/pr.yml: `gradle` job이 `./gradlew :prCheck`와 `./gradlew :verifyStrictLaneStages --dry-run` 두 줄, `vulnerabilities` (trivy), 필수 검사 하나 `done`. - main.yml: push마다 mainCheck·integrationCheck·build-logic 시험· configuration cache·lychee·trivy·http3(권고). nightly·수동 실행에서 PostgreSQL major·HTTP transport·Redis topology 행렬, NFS, 알림 chaos, jpa-next, compose smoke, 마지막에 `needs`로 performanceCheck. - release.yml: releaseCheck와 기존 release lane, 이미지를 이 Gitea 레지스트리에 올리고 cosign 키 쌍으로 서명한다. 수동 실행은 push·서명 앞까지 돈다. upload/download-artifact를 쓰지 않는다. JPA 승격은 `needs: jpa-release-gate`가 대신한다. - 새 집계 `prCheck` = ci + verifyDependencyLocks + compose 렌더링 + 저장소 배치 + 문서 검사(Exec). workflow와 verify.sh가 같은 한 줄을 쓴다. - verifyStrictLaneStages: 그래프 검사(모든 strict lane이 선언한 단계의 계획에 있다)는 그대로 두고, workflow 쪽은 고정 문자열 형식 검사로 바꾼다. 단계마다 workflow·이벤트·필터·job·옵션·조건을 build.gradle에 선언하고, 그 job의 step이 `run: ./gradlew <단계> <옵션>`을 가지며 다른 run도 셸 문법 없는 ./gradlew 한 줄이고, 선언 밖의 if:, 조건 없는 needs:, continue-on-error·shell:·defaults:, 따옴표 키·flow 형식, 다른 working-directory, 선언 밖의 이벤트 필터가 없는지 본다. PR 단계 job 하나는 이 검사 자신을 돌려야 한다. 셸 해석 코드와 그 시험을 지운다 (build-logic 운영 코드 −3,167줄, 시험 −2,231줄). 우회 입력 21가지를 TestKit 시험으로 둔다. - scripts/verify.sh <단계>: 사람·세션의 진입점. 무거운 단계는 지금 작업 트리를 패치로 desktop에 보내 잠금 아래에서 돌린다(operate.md 4.1절의 손 절차). scripts/ci/는 workflow가 부르는 trivy·Redis topology·포트 포워더·configuration cache 스크립트다. - workflow를 읽는 시험(DeveloperExperienceContractTest, JpaRelease RenderingTest, FileserverDocumentationCoverageTest)과 입력 선언을 .gitea로 옮기고, keyless 서명 시험을 키 쌍 서명 시험으로 바꾼다. - 문서: gates.md·operate.md·docs/ci-cd·AGENTS.md(검증 절)·build-logic AGENTS.md(셸 규칙 문단을 세 줄로)·leaf 문서의 workflow 참조, docs/upgrade B-57~B-61. 버린 것: workflow 하나에 if:로 단계를 나누기(파일만 보고 단계를 알 수 없다), 레지스트리에서 생성(같은 정보의 셋째 사본), 바뀐 모듈만 돌리기 (결정 30과 충돌). 판독기를 남기고 고치기는 6라운드 13건이 반증했다. 위험: PR이 어댑터 컨테이너 lane과 Redis standalone lane을 더는 막지 않는다(main·nightly에서 빨갛게 된다. 소유자 결정 ②). main push는 ci를 다시 돌리지 않는다. 성능 lane은 매 push가 아니라 nightly에서만 돈다. `.github/workflows/messaging-certification.yml`은 메시징 분리 작업이 지우므로 남겼다(.gitea가 있으면 Gitea가 읽지 않는다). 서명·push는 secret이 없어 실제 태그로는 돌려 보지 않았다. BREAKING CHANGE: workflow 파일 위치와 이름, strictLaneStages 문법, 릴리스 레지스트리·서명 방식이 바뀌었다. docs/upgrade/2026-11-maturity- review.md B-57~B-61을 따른다.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
head 기록(docs/design, docs/history, docs/adr)의 .md는 맨 위에
|
||||
머리 블록이 있다. 상태는 종류별 고정 어휘, 작성일은 날짜, 요약은 한국어, 현재
|
||||
정본과 대체됨이 가리키는 경로는 지금 있다.
|
||||
reference 살아 있는 문서의 인라인 코드 안 repo 경로(src/, docs/, scripts/, compose/, .github/로
|
||||
reference 살아 있는 문서의 인라인 코드 안 repo 경로(src/, docs/, scripts/, compose/, .github/, .gitea/로
|
||||
시작. 2026-11-07에 지운 infra/ 아래 경로도 본다)와 Gradle 경로(:a:b)가 지금 트리와
|
||||
registry에 있다. 「있다」는 git이 아는 파일(추적 + 무시되지 않은 새 파일)과 그 위 폴더다. 디스크에만
|
||||
있는 것(git mv가 남긴 빈 폴더 등)은 새 checkout에 없으므로 세지 않는다. 기록의 「현재 정본」·「대체됨」
|
||||
@@ -125,7 +125,7 @@ TOKEN = re.compile(r"[^\s가-힣]+")
|
||||
WORD = re.compile(r"^[(\[\"'“‘*_]*[A-Za-z][a-z]*(?:['’][a-z]+)?(?:-[a-z]+)*[)\]\"'”’*_.,;:!?…]*$")
|
||||
|
||||
# --- 참조
|
||||
PATH_ROOTS = ("src/", "docs/", "scripts/", "compose/", "infra/", ".github/")
|
||||
PATH_ROOTS = ("src/", "docs/", "scripts/", "compose/", "infra/", ".github/", ".gitea/")
|
||||
PLACEHOLDER = re.compile(r"[*?<>{}\[\]$…]|\.\.\.|YYYY|NNN|[가-힣]")
|
||||
LINE_SUFFIX = re.compile(r"(?::\d+(?:[-,]\d+)*)+$")
|
||||
# 모든 leaf에 있는 소스 세트 이름(src/test, src/main/java)은 어느 leaf의 것인지 문장이 정한다.
|
||||
@@ -148,7 +148,7 @@ VERSION = re.compile(r"(?<![\w.§])v?\d+\.\d+\.\d+(?:[.-][A-Za-z][A-Za-z0-9]*)*(
|
||||
SPRING_BOOT_CELL = re.compile(r"^Spring Boot(?:\s+(?:BOM|버전))?$")
|
||||
CELL_MARKUP = re.compile(r"[*_`]")
|
||||
LINK_TEXT = re.compile(r"\[([^\]\n]*)\]\([^)\s]*\)")
|
||||
# 상대 링크: 살아 있는 문서의 `[글](경로)`가 이 트리의 파일·폴더를 가리킨다. lychee(link-check.yml)는 PR에서
|
||||
# 상대 링크: 살아 있는 문서의 `[글](경로)`가 이 트리의 파일·폴더를 가리킨다. lychee(main.yml links)는 main에서
|
||||
# 정해진 경로만 보고, 그 밖의 문서(`src/**/AGENTS.md`, `.claude/**`, 루트 `AGENTS.md`)의 상대 링크는 이 검사만 본다.
|
||||
LINK_TARGET = re.compile(r"\[[^\]\n]*\]\(([^)\s]+)\)")
|
||||
URL_SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*:", re.I)
|
||||
|
||||
@@ -39,7 +39,8 @@ REGISTRY = "src/config/architecture/modules.json"
|
||||
ROOT_ALLOWED = {
|
||||
# 폴더
|
||||
".claude": "Claude Code 세션 설정(추적: settings.json의 권한·훅, rules·skills·agents)",
|
||||
".github": "workflow와 공용 action",
|
||||
".gitea": "Gitea Actions workflow(pr·main·release)와 공용 action",
|
||||
".github": "CODEOWNERS, PR 템플릿, 의존성 취약점 정책",
|
||||
"compose": "compose.yaml이 마운트하는 보조 파일",
|
||||
"docs": "문서",
|
||||
"scripts": "Gradle 밖 검사·실행 스크립트",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Forwards 127.0.0.1:<port> to <host>:<port> for each port given, until killed.
|
||||
|
||||
Called by scripts/ci/redis-topology.sh when it runs inside a CI job container. The runner's job
|
||||
container does not share the network of the Docker daemon that starts the Compose lanes, so the
|
||||
daemon's published ports are on the daemon host, not on the job's localhost — while the Redis lanes
|
||||
are built around localhost: the cluster announces 127.0.0.1 in its redirects and the TLS lane's
|
||||
certificate names localhost. Forwarding keeps those lanes exactly as they run on a workstation.
|
||||
|
||||
python3 scripts/ci/forward-ports.py <host> <port>...
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
|
||||
|
||||
async def pipe(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
|
||||
try:
|
||||
while data := await reader.read(65536):
|
||||
writer.write(data)
|
||||
await writer.drain()
|
||||
except (ConnectionError, asyncio.CancelledError):
|
||||
pass
|
||||
finally:
|
||||
writer.close()
|
||||
|
||||
|
||||
async def serve(host: str, port: int) -> asyncio.base_events.Server:
|
||||
async def handle(client_reader, client_writer):
|
||||
try:
|
||||
upstream_reader, upstream_writer = await asyncio.open_connection(host, port)
|
||||
except OSError:
|
||||
client_writer.close()
|
||||
return
|
||||
await asyncio.gather(pipe(client_reader, upstream_writer), pipe(upstream_reader, client_writer))
|
||||
|
||||
return await asyncio.start_server(handle, "127.0.0.1", port)
|
||||
|
||||
|
||||
async def main(host: str, ports: list[int]) -> None:
|
||||
servers = [await serve(host, port) for port in ports]
|
||||
print(f"forward-ports: 127.0.0.1 -> {host} for {ports}", flush=True)
|
||||
await asyncio.gather(*(server.serve_forever() for server in servers))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit(__doc__)
|
||||
asyncio.run(main(sys.argv[1], [int(port) for port in sys.argv[2:]]))
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/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.
|
||||
#
|
||||
# bash scripts/ci/redis-topology.sh <standalone|sentinel|cluster|tls> <redis version>
|
||||
#
|
||||
# The lanes are explicitOnly: they need the endpoint this script passes, so no stage runs them
|
||||
# (docs/redis/support-matrix.md records which lane produced which evidence). Each Gradle task fails
|
||||
# closed on its own account: an unknown mode, a missing endpoint, a lane with no tagged test class
|
||||
# and a run that executed zero tests are all errors.
|
||||
set -euo pipefail
|
||||
|
||||
topology=${1:?topology}
|
||||
version=${2:?redis version}
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
compose=(docker compose -f "src/adapter/outbound/redis-sdk/compose/${topology}/compose.yml")
|
||||
forwarder=''
|
||||
stop() {
|
||||
[ -z "${forwarder}" ] || kill "${forwarder}" 2>/dev/null || true
|
||||
"${compose[@]}" down -v
|
||||
}
|
||||
trap stop EXIT
|
||||
|
||||
runtime=:adapter:outbound:redis-runtime:redisTopologyTest
|
||||
sdk=:adapter:outbound:redis-sdk:redisTopologyTest
|
||||
semantic=:adapter:outbound:cache-redis:redisTopologyTest
|
||||
extra=()
|
||||
case "${topology}" in
|
||||
standalone) port=6379; ports=(6379); tasks=("${runtime}" "${sdk}" "${semantic}") ;;
|
||||
sentinel) port=27010; ports=(7010 7011 27010 27011 27012); tasks=("${runtime}" "${sdk}"); extra=(-Predis.topology.master=skeleton) ;;
|
||||
cluster) port=7100; ports=(7100 7101 7102 7103 7104 7105); tasks=("${runtime}" "${sdk}" "${semantic}") ;;
|
||||
tls) port=6390; ports=(6390); tasks=("${runtime}") ;;
|
||||
*) echo "redis-topology: unknown topology ${topology}" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
REDIS_VERSION=${version} "${compose[@]}" up -d --wait
|
||||
|
||||
# Inside a CI job container the Docker daemon's ports are on the daemon host, not on localhost, and
|
||||
# the lanes are built around localhost (cluster redirects announce 127.0.0.1, the TLS certificate
|
||||
# names localhost). Forward them, so the lane runs exactly as it does on a workstation.
|
||||
if [ -f /.dockerenv ]; then
|
||||
daemon_host=$(awk '$2 == "00000000" { printf "%d.%d.%d.%d\n", "0x" substr($3,7,2), "0x" substr($3,5,2), "0x" substr($3,3,2), "0x" substr($3,1,2); exit }' /proc/net/route)
|
||||
python3 scripts/ci/forward-ports.py "${daemon_host}" "${ports[@]}" &
|
||||
forwarder=$!
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# The tag says 7.4; the digest says which 7.4. Evidence that names only the tag cannot be reproduced
|
||||
# once the tag moves, so a run that cannot name its digest has nothing to certify.
|
||||
digest=$(docker image inspect --format '{{index .RepoDigests 0}}' "redis:${version}")
|
||||
[ -n "${digest}" ] || { echo "redis-topology: no repository digest for redis:${version}" >&2; exit 1; }
|
||||
if [ "${topology}" = tls ]; then
|
||||
trust=$(mktemp "${RUNNER_TEMP:-/tmp}/redis-lane-ca.XXXXXX")
|
||||
"${compose[@]}" cp redis:/tls/ca.crt "${trust}"
|
||||
extra=(-Predis.topology.trust-material="${trust}")
|
||||
fi
|
||||
|
||||
(cd src && ./gradlew "${tasks[@]}" --continue \
|
||||
-Predis.topology.host=localhost -Predis.topology.port="${port}" -Predis.topology.mode="${topology}" \
|
||||
"${extra[@]}")
|
||||
|
||||
printf 'evidence: commit=%s run=%s topology=%s redis_version=%s image_digest=%s\n' \
|
||||
"$(git rev-parse HEAD)" "${GITHUB_RUN_ID:-local}" "${topology}" "${version}" "${digest}"
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
# Vulnerability gate, shared by the stage workflows. Called by .gitea/workflows/pr.yml and main.yml
|
||||
# (`filesystem`) and release.yml (`image <reference>`); not by Gradle and not on the desktop, because
|
||||
# it downloads and installs its tools (docs/work/operate.md 4.1).
|
||||
#
|
||||
# bash scripts/ci/trivy-scan.sh filesystem dependency tree: block High/Critical, report
|
||||
# Medium/Low, fail on any CISA KEV match
|
||||
# bash scripts/ci/trivy-scan.sh image <reference> release image: write image-sbom.cdx.json,
|
||||
# block High/Critical, report Medium/Low
|
||||
#
|
||||
# Tools are pinned release binaries with an asserted SHA-256, installed under RUNNER_TEMP (or a
|
||||
# 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.
|
||||
set -euo pipefail
|
||||
|
||||
readonly TRIVY_VERSION='0.71.2'
|
||||
readonly TRIVY_SHA256_AMD64='0510e71e2fd39bf863856d499c8dc19feb4e7336546394c502a8f5cc7ab27460'
|
||||
readonly TRIVY_SHA256_ARM64='fe1c7106e15a5365d485b098a8c338f91e3b7ba71cb0e4963b98a3a098763cfc'
|
||||
readonly JQ_VERSION='1.8.1'
|
||||
readonly JQ_SHA256_AMD64='020468de7539ce70ef1bceaf7cde2e8c4f2ca6c3afb84642aabc5c97d9fc2a0d'
|
||||
readonly JQ_SHA256_ARM64='6bc62f25981328edd3cfcfe6fe51b073f2d7e7710d7ef7fcdac28d4e384fc3d4'
|
||||
readonly DEFAULT_KEV_FEED_URL='https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json'
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
tools="$(mktemp -d "${RUNNER_TEMP:-/tmp}/trivy-scan.XXXXXX")"
|
||||
trap 'rm -rf "${tools}"' EXIT
|
||||
|
||||
download() { # url, sha256, destination
|
||||
curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 "$1" --output "$3"
|
||||
printf '%s %s\n' "$2" "$3" | sha256sum -c -
|
||||
}
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64 | amd64) trivy_arch='64bit'; trivy_sha="${TRIVY_SHA256_AMD64}"; jq_asset='jq-linux-amd64'; jq_sha="${JQ_SHA256_AMD64}" ;;
|
||||
aarch64 | arm64) trivy_arch='ARM64'; trivy_sha="${TRIVY_SHA256_ARM64}"; jq_asset='jq-linux-arm64'; jq_sha="${JQ_SHA256_ARM64}" ;;
|
||||
*) echo "trivy-scan: unsupported architecture $(uname -m)" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
download "${TRIVY_DOWNLOAD_BASE_URL:-https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}}/trivy_${TRIVY_VERSION}_Linux-${trivy_arch}.tar.gz" \
|
||||
"${trivy_sha}" "${tools}/trivy.tar.gz"
|
||||
tar -xzf "${tools}/trivy.tar.gz" -C "${tools}" trivy
|
||||
download "${JQ_DOWNLOAD_BASE_URL:-https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}}/${jq_asset}" \
|
||||
"${jq_sha}" "${tools}/jq"
|
||||
chmod 0755 "${tools}/trivy" "${tools}/jq"
|
||||
export PATH="${tools}:${PATH}"
|
||||
[ "$(jq --version)" = "jq-${JQ_VERSION}" ] || { echo "trivy-scan: unexpected $(jq --version)" >&2; exit 1; }
|
||||
|
||||
scan_filesystem() {
|
||||
trivy fs --scanners vuln,license --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml .
|
||||
trivy fs --scanners vuln,license --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml .
|
||||
trivy fs --scanners vuln --severity CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN --exit-code 0 \
|
||||
--ignorefile .trivyignore.yaml --format json --output "${tools}/trivy-kev.json" .
|
||||
|
||||
# A KEV-listed vulnerability fails regardless of its CVSS score. The feed and the scan are both
|
||||
# checked for shape first: an empty or malformed input would otherwise intersect to nothing and
|
||||
# print "no catalog match" for a check that never ran.
|
||||
if ! curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
|
||||
"${KEV_FEED_URL:-${DEFAULT_KEV_FEED_URL}}" --output "${tools}/kev.json"; then
|
||||
echo "trivy-scan: KEV feed unavailable; set KEV_FEED_URL to an approved mirror" >&2
|
||||
exit 1
|
||||
fi
|
||||
jq -e '
|
||||
(.catalogVersion | type == "string" and test("\\S"))
|
||||
and (.dateReleased | type == "string" and test("\\S"))
|
||||
and (.count | type == "number")
|
||||
and (.count > 0)
|
||||
and (.count == (.count | floor))
|
||||
and (.vulnerabilities | type == "array")
|
||||
and ((.vulnerabilities | length) > 0)
|
||||
and (.count == (.vulnerabilities | length))
|
||||
and (all(.vulnerabilities[]; (.cveID | type == "string" and test("^CVE-[0-9]{4}-[0-9]{4,}$"))))
|
||||
and (([.vulnerabilities[].cveID] | unique | length) == .count)
|
||||
' "${tools}/kev.json" > /dev/null || { echo "trivy-scan: the KEV feed is malformed" >&2; exit 1; }
|
||||
jq -e '
|
||||
(type == "object")
|
||||
and (.Results | type == "array")
|
||||
and ((.Results | length) > 0)
|
||||
and (all(.Results[]; type == "object"))
|
||||
and (all(.Results[]; (.Vulnerabilities == null) or (.Vulnerabilities | type == "array")))
|
||||
and (all(.Results[]; all(.Vulnerabilities[]?;
|
||||
(type == "object") and (.VulnerabilityID | type == "string" and test("\\S")))))
|
||||
' "${tools}/trivy-kev.json" > /dev/null || { echo "trivy-scan: the Trivy KEV input is malformed" >&2; exit 1; }
|
||||
jq -r '[.Results[]?.Vulnerabilities[]?.VulnerabilityID] | unique[]' "${tools}/trivy-kev.json" | sort -u > "${tools}/found.txt"
|
||||
jq -r '.vulnerabilities[].cveID' "${tools}/kev.json" | sort -u > "${tools}/kev.txt"
|
||||
hits="$(comm -12 "${tools}/found.txt" "${tools}/kev.txt")"
|
||||
if [ -n "${hits}" ]; then
|
||||
printf 'trivy-scan: CISA KEV-listed vulnerability found regardless of CVSS:\n%s\n' "${hits}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "trivy-scan: no KEV catalog match."
|
||||
}
|
||||
|
||||
# The image scan sees the base image's OS packages, which the filesystem scan cannot. The SBOM is
|
||||
# written before the blocking scan, so the inventory survives the run that refuses to publish.
|
||||
scan_image() {
|
||||
trivy image --format cyclonedx --scanners license --output image-sbom.cdx.json "$1"
|
||||
test -s image-sbom.cdx.json
|
||||
trivy image --scanners vuln,license --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml "$1"
|
||||
trivy image --scanners vuln,license --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml "$1"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
filesystem) scan_filesystem ;;
|
||||
image) scan_image "${2:?image reference}" ;;
|
||||
*) sed -n '2,13p' "$0" >&2; exit 2 ;;
|
||||
esac
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Two questions about Gradle's configuration cache. Called by the `configuration-cache` job of
|
||||
# .gitea/workflows/main.yml and by scripts/verify.sh main.
|
||||
# 1. Can every repository-wide gate be stored? A property of the task graph, so --dry-run answers it
|
||||
# for all of them in seconds without running a lane.
|
||||
# 2. Is a stored entry reused while the build still executes its work? Checked on the two core
|
||||
# leaves, whose check runs in a minute.
|
||||
# prCheck and verifyStrictLaneStages are not in the list: the strict-lane check reads the task graph
|
||||
# itself and is declared incompatible, and prCheck is ci plus scripts.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../../src"
|
||||
|
||||
reused() { # gradle arguments...; fails unless the second identical run reuses the stored entry
|
||||
./gradlew "$@" --configuration-cache --configuration-cache-problems=fail
|
||||
output=$(./gradlew "$@" --configuration-cache --configuration-cache-problems=fail 2>&1)
|
||||
printf '%s\n' "${output}"
|
||||
grep -Fq 'Reusing configuration cache.' <<<"${output}" || {
|
||||
echo "configuration cache: not reused for: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
for gate in ci mainCheck integrationCheck releaseCheck; do
|
||||
reused "${gate}" --dry-run
|
||||
done
|
||||
reused :domain-core:check :application-core:check
|
||||
Executable
+190
@@ -0,0 +1,190 @@
|
||||
#!/usr/bin/env bash
|
||||
# 검증 진입점. 사람·세션·문서가 같은 명령을 쓰고, 단계 이름은 workflow(.gitea/workflows)와 같다.
|
||||
#
|
||||
# scripts/verify.sh <단계> [대상] [--on here|<호스트>] [--log <이름>] [--no-cache]
|
||||
#
|
||||
# 단계 무엇 workflow
|
||||
# docs 문서·지침 검사와 스크립트 시험(Gradle 없음) pr.yml의 prCheck 안
|
||||
# leaf <경로> registry gradle_path 하나의 check (작업 중)
|
||||
# pr :prCheck, :verifyStrictLaneStages --dry-run pr.yml `gradle`
|
||||
# main :mainCheck, :integrationCheck, build-logic 시험, 설정 캐시 main.yml(push)
|
||||
# nightly compose smoke 전부, :performanceCheck(마지막) main.yml(nightly)
|
||||
# release :releaseCheck(이 커밋을 provenance로) release.yml `release`
|
||||
# app 앱을 띄워 health와 기본 endpoint를 직접 본다 (없음)
|
||||
# round pr → main → nightly → release, 첫 실패에서 멈춘다 라운드 끝 묶음
|
||||
# docs 밖의 단계는 Gradle·Docker를 쓴다. 이 repo에서는 desktop에서만 돈다(docs/work/operate.md 4.1절).
|
||||
# trivy·lychee·nightly 행렬(Redis topology, PostgreSQL major, NFS)은 도구를 내려받거나 runner 환경이 필요해
|
||||
# workflow에서만 돈다.
|
||||
#
|
||||
# --on <호스트>: 지금 작업 트리(커밋 안 된 변경 포함)를 패치로 그 호스트에 옮긴다. 기준 커밋에서 새 worktree를
|
||||
# 만들어 패치를 적용하고, 트리 해시가 여기와 같은지 본 뒤 잠금 아래에서 같은 단계를 돌리고 worktree를 지운다.
|
||||
# push하지 않는다. 기준 커밋은 원격 checkout이 fetch로 받을 수 있어야 한다(기본: origin/main과 갈라진 곳).
|
||||
# docs 밖의 단계는 기본이 desktop이다. desktop에서 직접 돌릴 때는 --on here.
|
||||
# --no-cache: Gradle 명령마다 --no-build-cache를 붙인다(증거로 쓸 실행, docs/work/reference/gates.md 3절).
|
||||
# 환경 변수: VERIFY_HOST(무거운 단계의 --on 기본값, 없으면 desktop), VERIFY_REMOTE_REPO(원격 checkout, 기본
|
||||
# ~/workspace/<repo 이름>), VERIFY_BASE_REF(기본 origin/main), VERIFY_LOCK(기본 /tmp/claude-gates/heavy.lock),
|
||||
# VERIFY_SSH(기본 ssh).
|
||||
# 종료 코드: 단계의 종료 코드. 2 = 사용법, 4 = 원격 준비 실패.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "$ROOT"
|
||||
TMP_FILES=()
|
||||
trap '[ ${#TMP_FILES[@]} -eq 0 ] || rm -f "${TMP_FILES[@]}"' EXIT # 빈 배열 + set -u는 옛 bash에서 오류다
|
||||
# 빌드마다 쓰고 버리는 daemon. 여러 worktree의 빌드를 한 오래 사는 daemon이 받으면 서로 호환되지 않는 compiler
|
||||
# worker가 쌓여 desktop 메모리를 채운다(2026-11-08 측정: worker 41개, 14.2GB). GRADLE_OPTS는 단계 안에서 다시 부르는
|
||||
# Gradle(생성 명령 왕복, 설정 캐시·Redis 스크립트)에도 같은 규칙을 준다. repo 기본값(src/gradle.properties)은 그대로다.
|
||||
GRADLE_FLAGS=(--console=plain --no-daemon)
|
||||
export GRADLE_OPTS="${GRADLE_OPTS:+$GRADLE_OPTS }-Dorg.gradle.daemon=false"
|
||||
LOCK=${VERIFY_LOCK:-/tmp/claude-gates/heavy.lock}
|
||||
|
||||
usage() {
|
||||
awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$ROOT/scripts/verify.sh" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
gradle() { (cd src && ./gradlew "$@" "${GRADLE_FLAGS[@]}"); }
|
||||
|
||||
# ---------------------------------------------------------------- 단계 본문
|
||||
|
||||
run_docs() {
|
||||
python3 scripts/check-work-docs.py
|
||||
python3 scripts/check-docs.py
|
||||
python3 -m unittest discover -s scripts/tests
|
||||
python3 scripts/check-repo-layout.py
|
||||
}
|
||||
|
||||
# 대상은 registry의 gradle_path여야 한다. 폴더 이름이나 기억으로 짐작한 경로는 여기서 거절한다.
|
||||
run_leaf() {
|
||||
local path=${1:?leaf 뒤에 registry gradle_path(예: :adapter:outbound:persistence-jpa)}
|
||||
python3 - "$path" <<'PY' || { echo "verify: $path는 registry(src/config/architecture/modules.json)의 gradle_path가 아니다" >&2; exit 2; }
|
||||
import json, sys
|
||||
paths = {m["gradle_path"] for m in json.load(open("src/config/architecture/modules.json"))["modules"]}
|
||||
sys.exit(0 if sys.argv[1] in paths else 1)
|
||||
PY
|
||||
gradle "$path:check"
|
||||
}
|
||||
|
||||
run_pr() {
|
||||
gradle :prCheck
|
||||
gradle :verifyStrictLaneStages --dry-run
|
||||
}
|
||||
|
||||
run_main() {
|
||||
gradle :mainCheck --continue
|
||||
gradle :integrationCheck --continue
|
||||
gradle -p build-logic test
|
||||
bash scripts/ci/verify-configuration-cache.sh
|
||||
}
|
||||
|
||||
# performanceCheck는 마지막이다: 상한은 다른 빌드가 돌지 않는 머신에서만 뜻이 있다.
|
||||
run_nightly() {
|
||||
bash scripts/run-compose-runtime-smoke.sh --matrix src/app-bootstrap/compose-lanes/compose-profile-contracts.json
|
||||
gradle :performanceCheck --continue
|
||||
}
|
||||
|
||||
# CI는 GITHUB_SHA로 커밋을 받는다. 여기서는 HEAD를 준다(--on 원격 실행에서는 패치를 얹은 기준 커밋).
|
||||
run_release() { GIT_SHA=${GIT_SHA:-$(git rev-parse HEAD)} gradle :releaseCheck; }
|
||||
|
||||
run_app() { bash scripts/bootstrap-local.sh; }
|
||||
|
||||
# 함수를 && 목록 안에서 부르면 그 안의 set -e가 꺼진다. 그래서 차례로 부른다.
|
||||
run_round() {
|
||||
run_pr
|
||||
run_main
|
||||
run_nightly
|
||||
run_release
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 실행 위치
|
||||
|
||||
run_here() {
|
||||
local stage=$1
|
||||
shift
|
||||
case "$stage" in
|
||||
docs) run_docs ;;
|
||||
leaf | pr | main | nightly | release | app | round)
|
||||
# 같은 머신의 다른 세션·프론트 repo와 무거운 실행이 겹치지 않게 공유 잠금 아래에서 돈다.
|
||||
if [ -z "${VERIFY_LOCKED:-}" ] && [ -d "$(dirname "$LOCK")" ]; then
|
||||
export VERIFY_LOCKED=1
|
||||
exec flock "$LOCK" "$ROOT/scripts/verify.sh" "$stage" "$@" --on here "${NO_CACHE[@]}"
|
||||
fi
|
||||
"run_$stage" "$@"
|
||||
;;
|
||||
*) usage ;;
|
||||
esac
|
||||
}
|
||||
|
||||
run_remote() {
|
||||
local stage=$1 target=$2 host=$3 log=$4 ssh=${VERIFY_SSH:-ssh}
|
||||
local name base tree tmp_index patch id remote_repo
|
||||
name=$(basename "$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")")
|
||||
remote_repo=${VERIFY_REMOTE_REPO:-"~/workspace/$name"}
|
||||
base=$(git merge-base HEAD "${VERIFY_BASE_REF:-origin/main}")
|
||||
tmp_index=$(mktemp)
|
||||
patch=$(mktemp)
|
||||
TMP_FILES+=("$tmp_index" "$patch")
|
||||
cp "$(git rev-parse --git-path index)" "$tmp_index"
|
||||
GIT_INDEX_FILE=$tmp_index git add -A
|
||||
tree=$(GIT_INDEX_FILE=$tmp_index git write-tree)
|
||||
git diff --binary "$base" "$tree" > "$patch"
|
||||
id="verify-$(date +%s)-$$"
|
||||
echo "verify: $host에서 '$stage $target' (기준 ${base:0:12}, 트리 ${tree:0:12}, 로그 ~/$log-logs/$stage.log)" >&2
|
||||
$ssh "$host" "cat > /tmp/$id.patch" < "$patch"
|
||||
# compose lane이 만든 root 소유 파일이 있어도 지울 수 있게 정리는 worktree remove --force 하나로 한다.
|
||||
$ssh "$host" bash -s <<EOF
|
||||
set -u
|
||||
cd $remote_repo || exit 4
|
||||
git fetch -q origin || exit 4
|
||||
wt=\$(mktemp -d /tmp/$id.XXXXXX)
|
||||
git worktree add -q --detach "\$wt" $base || exit 4
|
||||
cleanup() { cd $remote_repo && git worktree remove --force "\$wt"; rm -f /tmp/$id.patch; }
|
||||
trap cleanup EXIT
|
||||
cd "\$wt"
|
||||
if [ -s /tmp/$id.patch ]; then git apply --binary --index /tmp/$id.patch || exit 4; fi
|
||||
got=\$(git write-tree)
|
||||
if [ "\$got" != "$tree" ]; then echo "트리 해시가 다르다: 원격 \$got, 여기 $tree" >&2; exit 4; fi
|
||||
mkdir -p "\$(dirname $LOCK)" ~/$log-logs
|
||||
echo "verify: \$(uptime)" >&2
|
||||
VERIFY_LOCKED=1 flock $LOCK ./scripts/verify.sh $stage $target --on here ${NO_CACHE[*]} 2>&1 | tee ~/$log-logs/$stage.log
|
||||
rc=\${PIPESTATUS[0]}
|
||||
# 새 worktree라 여기 있는 JUnit XML은 모두 이번 실행의 것이다. worktree를 지우기 전에 센다.
|
||||
find . -path '*/build/test-results/*' -name 'TEST-*.xml' -print0 | xargs -0 -r cat \\
|
||||
| grep -o '<testsuite [^>]*' \\
|
||||
| awk '{ for (i = 1; i <= NF; i++) if (split(\$i, kv, "=") == 2) { gsub(/"/, "", kv[2]); n[kv[1]] += kv[2] } }
|
||||
END { printf "verify: 테스트 tests=%d failures=%d errors=%d skipped=%d\\n", n["tests"], n["failures"], n["errors"], n["skipped"] }' \\
|
||||
| tee -a ~/$log-logs/$stage.log
|
||||
echo "verify: rc=\$rc" | tee -a ~/$log-logs/$stage.log
|
||||
exit \$rc
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
local stage=${1:-} target="" on="" log=""
|
||||
NO_CACHE=()
|
||||
[ -n "$stage" ] || usage
|
||||
shift
|
||||
if [ "$stage" = leaf ] && [ $# -gt 0 ] && [ "${1#--}" = "$1" ]; then
|
||||
target=$1
|
||||
shift
|
||||
fi
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--on) on=${2:?--on 뒤에 호스트}; shift 2 ;;
|
||||
--log) log=${2:?--log 뒤에 이름}; shift 2 ;;
|
||||
--no-cache) NO_CACHE=(--no-cache); GRADLE_FLAGS+=(--no-build-cache); shift ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$on" ]; then
|
||||
if [ "$stage" = docs ]; then on=here; else on=${VERIFY_HOST:-desktop}; fi
|
||||
fi
|
||||
if [ "$on" = here ]; then
|
||||
run_here "$stage" ${target:+"$target"}
|
||||
else
|
||||
log=${log:-$(git branch --show-current | tr '/' '-')}
|
||||
run_remote "$stage" "$target" "$on" "${log:-detached}"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user