From 0b35acca90e125eff3983ca670f4812f88bfd180 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sun, 22 Nov 2026 11:16:35 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20PR=20=EC=9D=BC=EA=B4=84=20=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=C2=B7=EB=B3=91=ED=95=A9=20=EC=9A=94=EC=B2=AD=EC=97=90?= =?UTF-8?q?=EC=84=9C=20repo=5Fowner=EB=A5=BC=20=ED=95=84=EC=88=98=EB=A1=9C?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 6 +++--- test-migration.sh | 18 ++++-------------- utils/prActions.js | 9 ++++++++- utils/prActions.test.js | 23 ++++++++++++++++++++++- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9bb0897..9b4b6d1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,14 +29,14 @@ wrangler.jsonc Worker 설정과 공개 값(vars) ## 엔드포인트 -`repo_owner` 를 받는 엔드포인트는 `DaleStudy` 가 아니면 403 이다 (생략하면 `DaleStudy`). `/check-weeks` 는 저장소도 leetcode-study 만 받는다. +`repo_owner` 를 받는 엔드포인트는 `DaleStudy` 가 아니면 403 이다. 일괄 승인·병합 요청에는 `repo_owner`가 필수다. `/check-weeks` 는 생략하면 `DaleStudy`를 사용하며 저장소도 leetcode-study 만 받는다. | 경로 | 하는 일 | | ------------------------- | --------------------------------------------------------------------------------------------------------------- | | `POST /webhooks` | GitHub App 웹훅 수신 (아래 "웹훅") | | `POST /check-weeks` | 열린 PR 전체의 Week 설정을 검사해 경고 댓글을 달거나 지운다. `{ "repo_name" }` | -| `POST /approve-prs` | 해당 주차 풀이 PR 을 일괄 승인한다. `{ "repo_name", "week": "Week 8", "excludes"? }` | -| `POST /merge-prs` | 해당 주차의 승인된 PR 을 일괄 병합한다. `{ "repo_name", "week", "excludes"?, "merge_method"? }` (기본 `squash`) | +| `POST /approve-prs` | 해당 주차 풀이 PR 을 일괄 승인한다. `{ "repo_owner", "repo_name", "week": "Week 8", "excludes"? }` | +| `POST /merge-prs` | 해당 주차의 승인된 PR 을 일괄 병합한다. `{ "repo_owner", "repo_name", "week", "excludes"?, "merge_method"? }` (기본 `squash`) | | `POST /resolve-iteration` | 날짜가 몇 기 몇 주차인지 프로젝트 보드에서 읽는다. `{ "date": "2026-08-08" }` | | `POST /internal/*` | 웹훅 핸들러가 AI 작업을 별도 invocation 으로 넘길 때 쓴다 (`X-Internal-Secret` 인증) | diff --git a/test-migration.sh b/test-migration.sh index 4cae1c7..99cc8f2 100755 --- a/test-migration.sh +++ b/test-migration.sh @@ -110,7 +110,7 @@ fi # 1.6 approve-prs week 누락 (400) BODY=$(curl -s -w '\n%{http_code}' -X POST "$BASE_URL/approve-prs" \ -H "Content-Type: application/json" \ - -d '{"repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) + -d '{"repo_owner":"DaleStudy","repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) STATUS=$(echo "$BODY" | tail -1) BODY_CONTENT=$(echo "$BODY" | sed '$d') if [ "$STATUS" = "400" ] && echo "$BODY_CONTENT" | grep -q "week"; then @@ -122,7 +122,7 @@ fi # 1.7 merge-prs week 누락 (400) BODY=$(curl -s -w '\n%{http_code}' -X POST "$BASE_URL/merge-prs" \ -H "Content-Type: application/json" \ - -d '{"repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) + -d '{"repo_owner":"DaleStudy","repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) STATUS=$(echo "$BODY" | tail -1) BODY_CONTENT=$(echo "$BODY" | sed '$d') if [ "$STATUS" = "400" ] && echo "$BODY_CONTENT" | grep -q "week"; then @@ -134,7 +134,7 @@ fi # 1.8 경로 별칭 (underscore) BODY=$(curl -s -w '\n%{http_code}' -X POST "$BASE_URL/approve_prs" \ -H "Content-Type: application/json" \ - -d '{"repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) + -d '{"repo_owner":"DaleStudy","repo_name":"leetcode-study"}' --max-time 30 2>/dev/null) STATUS=$(echo "$BODY" | tail -1) if [ "$STATUS" = "400" ]; then pass "1.8 /approve_prs 경로 별칭 라우팅" @@ -286,17 +286,7 @@ fi section "Tier 4: 수동 검증 (아래 명령을 직접 실행하세요)" echo "" -echo -e " ${YELLOW}[approve-prs]${NC} PR 일괄 승인 (Week 번호를 실제 값으로 변경)" -echo " curl -X POST $BASE_URL/approve-prs \\" -echo " -H 'Content-Type: application/json' \\" -echo " -d '{\"repo_name\":\"leetcode-study\",\"week\":\"Week 14\"}'" - -echo "" -echo -e " ${YELLOW}[merge-prs]${NC} PR 일괄 병합" -echo " curl -X POST $BASE_URL/merge-prs \\" -echo " -H 'Content-Type: application/json' \\" -echo " -d '{\"repo_name\":\"leetcode-study\",\"week\":\"Week 14\",\"merge_method\":\"squash\"}'" - +echo " 일괄 승인·병합은 DaleStudy/leetcode-study의 Actions → Management에서 실행합니다." echo "" echo -e " ${YELLOW}[Webhook]${NC} 실제 이벤트로 검증" echo " 1. wrangler tail (로그 모니터링 시작)" diff --git a/utils/prActions.js b/utils/prActions.js index 50f1df5..076d049 100644 --- a/utils/prActions.js +++ b/utils/prActions.js @@ -16,10 +16,17 @@ const PASSING_CHECK_STATE = "SUCCESS"; export async function parsePrActionPayload(request) { try { const data = await request.json(); - const repoOwner = data.repo_owner || "DaleStudy"; + const repoOwner = data.repo_owner; const repoName = data.repo_name; const week = data.week; + if (!repoOwner) { + return { + valid: false, + response: errorResponse("Missing required field: repo_owner", 400), + }; + } + if (!repoName) { return { valid: false, diff --git a/utils/prActions.test.js b/utils/prActions.test.js index df84379..0634c21 100644 --- a/utils/prActions.test.js +++ b/utils/prActions.test.js @@ -1,6 +1,6 @@ import { describe, it, expect } from "vitest"; -import { getCheckSkipReason } from "./prActions.js"; +import { getCheckSkipReason, parsePrActionPayload } from "./prActions.js"; describe("getCheckSkipReason", () => { it("모든 체크가 통과하면 승인을 막지 않는다", () => { @@ -18,3 +18,24 @@ describe("getCheckSkipReason", () => { expect(getCheckSkipReason({})).toBe("checks missing"); }); }); + +describe("parsePrActionPayload", () => { + it.each([ + [undefined, 400], + ["fork-owner", 403], + ["DaleStudy", null], + ])("repo_owner=%s", async (owner, expectedError) => { + const request = new Request("https://example.com", { + method: "POST", + body: JSON.stringify({ repo_owner: owner, repo_name: "leetcode-study", week: "Week 2" }), + }); + const result = await parsePrActionPayload(request); + if (expectedError) { + expect(result.valid).toBe(false); + expect(result.response.status).toBe(expectedError); + } else { + expect(result.valid).toBe(true); + expect(result.data.repoOwner).toBe(owner); + } + }); +}); From 4ec2abe9a5ba79db443abac2ec9a5a82803a97d0 Mon Sep 17 00:00:00 2001 From: Hojeong Park Date: Sun, 22 Nov 2026 11:25:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=EC=88=98=EB=8F=99=20=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=C2=B7=EB=B3=91=ED=95=A9=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=98=88=EC=8B=9C=EC=97=90=20=EC=A0=80=EC=9E=A5=EC=86=8C=20?= =?UTF-8?q?=EC=86=8C=EC=9C=A0=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test-migration.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test-migration.sh b/test-migration.sh index 99cc8f2..89b3a82 100755 --- a/test-migration.sh +++ b/test-migration.sh @@ -286,7 +286,17 @@ fi section "Tier 4: 수동 검증 (아래 명령을 직접 실행하세요)" echo "" -echo " 일괄 승인·병합은 DaleStudy/leetcode-study의 Actions → Management에서 실행합니다." +echo -e " ${YELLOW}[approve-prs]${NC} PR 일괄 승인 (Week 번호를 실제 값으로 변경)" +echo " curl -X POST $BASE_URL/approve-prs \\" +echo " -H 'Content-Type: application/json' \\" +echo " -d '{\"repo_owner\":\"<저장소 소유자>\",\"repo_name\":\"leetcode-study\",\"week\":\"Week 14\"}'" + +echo "" +echo -e " ${YELLOW}[merge-prs]${NC} PR 일괄 병합" +echo " curl -X POST $BASE_URL/merge-prs \\" +echo " -H 'Content-Type: application/json' \\" +echo " -d '{\"repo_owner\":\"<저장소 소유자>\",\"repo_name\":\"leetcode-study\",\"week\":\"Week 14\",\"merge_method\":\"squash\"}'" + echo "" echo -e " ${YELLOW}[Webhook]${NC} 실제 이벤트로 검증" echo " 1. wrangler tail (로그 모니터링 시작)"