fix(scripts): verify.sh parts가 게이트 명령의 args를 넘긴다
문제: `scripts/verify.sh parts <ID>`는 게이트의 명령을 하나씩 돌리면서 config/ci/gates.json 명령의 `script`만 읽고 `args`를 버린다. 그래서 FE-GATE-009의 `review:a11y-manual -- --format-only`가 인자 없이 돌아 release 증거를 찾다가 rc=1이 되고, production 게이트의 `drill:runbook -- FE-RB-00N --release-root …` 여섯 개도 다른 명령이 된다. ci:gate(run-ci-gate.ts)는 `pnpm <script> ...args`로 돌려 영향이 없다. desktop 측정에서 parts만 009를 실패로 냈다. 고른 방법: 계약을 읽는 python이 필드를 \x1f로, args를 \x1e로 나눠 내보내고 bash가 배열로 받아 `corepack pnpm -s <script> ...args`로 돌린다. 탭 구분은 빈 expectedExitCode 칸이 이어지는 탭과 합쳐져 다음 칸이 밀리므로 쓰지 않았다. 위험·한계: args 안에 \x1e·\x1f가 들어가면 잘못 나뉜다. 지금 계약에는 없다. 검증(노트북): python3 -m unittest discover -s scripts/tests 통과. 새 시험은 args가 있는 게이트 7개 모두에서 수정 전 실패, 수정 뒤 통과.
This commit is contained in:
@@ -51,6 +51,24 @@ class StagePlanTest(unittest.TestCase):
|
||||
self.assertEqual([line.split(": ", 1)[1] for line in result.stdout.splitlines()],
|
||||
[f"corepack pnpm -s {scripts[c]}" for c in gate["commandIds"]])
|
||||
|
||||
def test_parts_passes_each_command_its_arguments_as_ci_gate_does(self) -> None:
|
||||
# run-ci-gate.ts runs `pnpm <script> ...args`. Without the args FE-GATE-009's
|
||||
# `review:a11y-manual -- --format-only` checked the release evidence instead and failed.
|
||||
contract = gates()
|
||||
commands = {c["id"]: c for c in contract["commands"]}
|
||||
with_args = [g for g in contract["gates"]
|
||||
if any(commands[c].get("args") for c in g["commandIds"])]
|
||||
self.assertTrue(with_args, "the contract has no command with arguments to check")
|
||||
for gate in with_args:
|
||||
with self.subTest(gate=gate["id"]):
|
||||
result = sh([str(VERIFY), "parts", gate["id"], "--dry-run"], cwd=REPO)
|
||||
expected = []
|
||||
for command_id in gate["commandIds"]:
|
||||
command = commands[command_id]
|
||||
words = ["corepack", "pnpm", "-s", command["script"], *command.get("args", [])]
|
||||
expected.append(" ".join(words))
|
||||
self.assertEqual([line.split(": ", 1)[1] for line in result.stdout.splitlines()], expected)
|
||||
|
||||
def test_arguments_after_the_separator_go_to_the_one_script_or_command_as_given(self) -> None:
|
||||
result = sh([str(VERIFY), "script", "test:sample-removal", "--dry-run", "--", "--feature=invoice-feature"],
|
||||
cwd=REPO)
|
||||
|
||||
+9
-4
@@ -62,7 +62,9 @@ elif kind == "scripts":
|
||||
commands = {command["id"]: command for command in contract["commands"]}
|
||||
for command_id in gate["commandIds"]:
|
||||
command = commands[command_id]
|
||||
print(f'{command["script"]}\t{command.get("expect", "pass")}\t{command.get("expectedExitCode", "")}')
|
||||
# \x1f between fields keeps an empty exit code a field; \x1e between the command's args.
|
||||
args = "\x1e".join(command.get("args", []))
|
||||
print(f'{command["script"]}\x1f{command.get("expect", "pass")}\x1f{command.get("expectedExitCode", "")}\x1f{args}')
|
||||
PY
|
||||
}
|
||||
|
||||
@@ -129,12 +131,15 @@ run_gates() {
|
||||
}
|
||||
|
||||
run_parts() {
|
||||
local gate=$1 failed=0 script expect code rc
|
||||
local gate=$1 failed=0 script expect code argtext rc args
|
||||
[ "$DRY_RUN" = 1 ] || ci_env
|
||||
gates_json scripts "$gate" > /dev/null || { echo "verify: config/ci/gates.json에 없는 게이트: $gate" >&2; return 2; }
|
||||
while IFS=$'\t' read -r script expect code; do
|
||||
while IFS=$'\x1f' read -r script expect code argtext; do
|
||||
rc=0
|
||||
step "$gate $script" corepack pnpm -s "$script" || rc=$?
|
||||
args=()
|
||||
# The command's args, as run-ci-gate.ts passes them (`pnpm <script> ...args`).
|
||||
[ -z "$argtext" ] || IFS=$'\x1e' read -r -a args <<< "$argtext"
|
||||
step "$gate $script" corepack pnpm -s "$script" ${args[@]+"${args[@]}"} || rc=$?
|
||||
# expect=fail인 명령(음성 fixture)은 정해진 종료 코드로 실패해야 통과다.
|
||||
if [ "$expect" = fail ]; then
|
||||
[ "$DRY_RUN" = 1 ] || [ "$rc" = "${code:-1}" ] || failed=1
|
||||
|
||||
Reference in New Issue
Block a user