From c8b8c010f1bcdbc5690f60b784489db40bd8918c Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:12:41 +0900 Subject: [PATCH 01/14] =?UTF-8?q?=20feat(OK-123):=20GPT4=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A6=AC=EB=B7=B0=20yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/prompt/review.txt | 22 ++++++++++ .github/workflows/ai-pr-review.yml | 68 ++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/prompt/review.txt create mode 100644 .github/workflows/ai-pr-review.yml diff --git a/.github/prompt/review.txt b/.github/prompt/review.txt new file mode 100644 index 0000000..8d6372e --- /dev/null +++ b/.github/prompt/review.txt @@ -0,0 +1,22 @@ +You are a senior React Native developer reviewing a pull request in a production-level project. + +๐Ÿ› ๏ธ Project Stack: +- React Native with Expo +- TypeScript +- OpenAPI-based API handling +- App router-based navigation (like Expo Router or similar) + +Your goal is to: +1. Focus on **performance issues**, especially those that may cause unnecessary re-renders, inefficient rendering in lists, or redundant API calls. +2. Identify areas that are **likely to throw runtime errors**, especially "Cannot read property of undefined", null dereferencing, or optional chaining misuses. +3. Suggest better **modularization**, such as breaking down components or extracting hooks/utilities if any logic is too large or repeated. +4. Point out places where **better patterns or abstraction** could improve readability and maintainability (e.g., custom hooks, reusable UI components). +5. Suggest **alternative approaches** where applicable (e.g., using FlatList instead of ScrollView, memoizing with `useMemo`, `useCallback`, etc.) +6. Mention if any **types are too generic or unsafe** (e.g., use of `any`, improper inference). + +Output your response in **clear sections**: `Performance`, `Error Safety`, `Modularization`, `Suggestions`. + +If everything looks good, say `LGTM โœ…` under each section. +Always write in Korean. + +Here is the code diff: \ No newline at end of file diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml new file mode 100644 index 0000000..ea227c4 --- /dev/null +++ b/.github/workflows/ai-pr-review.yml @@ -0,0 +1,68 @@ +name: AI PR Review + +on: + pull_request: + types: [opened, synchronize] + +jobs: + ai_review: + runs-on: ubuntu-latest + steps: + - name: Checkout PR code + uses: actions/checkout@v3 + + - name: Get PR diff + id: diff + run: | + git fetch origin ${{ github.base_ref }} + git diff origin/${{ github.base_ref }} > pr.diff + echo "::set-output name=diff::$(cat pr.diff)" + + - name: Check PR size + id: check_size + run: | + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} | wc -l) + CHANGED_LINES=$(git diff --shortstat origin/${{ github.base_ref }} | grep -o '[0-9]\+' | paste -sd+ - | bc || echo 0) + echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT + echo "changed_lines=$CHANGED_LINES" >> $GITHUB_OUTPUT + + - name: Review with OpenAI + id: review + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + run: | + PROMPT=$(cat .github/prompt/review.txt) + DIFF=$(cat pr.diff | head -c 4000) + FINAL_PROMPT="$PROMPT\n$DIFF" + + RESPONSE=$(curl https://api.openai.com/v1/chat/completions \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4", + "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] + }' | jq -r '.choices[0].message.content') + + echo "::set-output name=review::$RESPONSE" + + - name: Comment on PR + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + ๐Ÿค– **AI ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์š”์•ฝ (GPT-4 ๊ธฐ๋ฐ˜)** + ``` + ${{ steps.review.outputs.review }} + ``` + + - name: Warn if PR is too large + if: ${{ steps.check_size.outputs.changed_files > 10 || steps.check_size.outputs.changed_lines > 500 }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment ${{ github.event.pull_request.number }} \ + --body "โš ๏ธ **์ด PR์€ ๋Œ€ํ˜• ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค.** + - ๋ณ€๊ฒฝ๋œ ํŒŒ์ผ ์ˆ˜: \`${{ steps.check_size.outputs.changed_files }}\` + - ๋ณ€๊ฒฝ๋œ ๋ผ์ธ ์ˆ˜: \`${{ steps.check_size.outputs.changed_lines }}\` + + ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ + --repo ${{ github.repository }} From 3da73881e907dc2616b9749665969252895b184c Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:19:14 +0900 Subject: [PATCH 02/14] =?UTF-8?q?fix(OK-123):=20=EA=B9=83=ED=97=88?= =?UTF-8?q?=EB=B8=8C=20=ED=86=A0=ED=81=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index ea227c4..f9737a2 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -57,7 +57,7 @@ jobs: - name: Warn if PR is too large if: ${{ steps.check_size.outputs.changed_files > 10 || steps.check_size.outputs.changed_lines > 500 }} env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} run: | gh pr comment ${{ github.event.pull_request.number }} \ --body "โš ๏ธ **์ด PR์€ ๋Œ€ํ˜• ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค.** From 9442470f19527e262e39bc5b14317f246ca863d8 Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:21:04 +0900 Subject: [PATCH 03/14] =?UTF-8?q?fix(OK-123):set-output=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20+=20review=20=EC=B6=9C=EB=A0=A5=20=EC=95=88?= =?UTF-8?q?=EC=A0=95=EC=84=B1=20=EB=B3=B4=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index f9737a2..0391b49 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -16,7 +16,7 @@ jobs: run: | git fetch origin ${{ github.base_ref }} git diff origin/${{ github.base_ref }} > pr.diff - echo "::set-output name=diff::$(cat pr.diff)" + echo "diff=$(cat pr.diff)" >> $GITHUB_OUTPUT - name: Check PR size id: check_size @@ -43,9 +43,10 @@ jobs: "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] }' | jq -r '.choices[0].message.content') - echo "::set-output name=review::$RESPONSE" + echo "review=$RESPONSE" >> $GITHUB_OUTPUT - name: Comment on PR + if: steps.review.outputs.review != '' uses: marocchino/sticky-pull-request-comment@v2 with: message: | @@ -65,4 +66,4 @@ jobs: - ๋ณ€๊ฒฝ๋œ ๋ผ์ธ ์ˆ˜: \`${{ steps.check_size.outputs.changed_lines }}\` ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ - --repo ${{ github.repository }} + --repo ${{ github.repository }} From 1eeff8e558d24e149b86cfa3a60c6e6d25f31c8e Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:23:29 +0900 Subject: [PATCH 04/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 0391b49..6682e07 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -8,16 +8,18 @@ jobs: ai_review: runs-on: ubuntu-latest steps: + # 1. PR ์ฝ”๋“œ ์ฒดํฌ์•„์›ƒ - name: Checkout PR code uses: actions/checkout@v3 + # 2. PR diff ์ƒ์„ฑ ๋ฐ ์ €์žฅ - name: Get PR diff id: diff run: | git fetch origin ${{ github.base_ref }} git diff origin/${{ github.base_ref }} > pr.diff - echo "diff=$(cat pr.diff)" >> $GITHUB_OUTPUT + # 3. ๋ณ€๊ฒฝ ํŒŒ์ผ ์ˆ˜ / ๋ผ์ธ ์ˆ˜ ๊ณ„์‚ฐ - name: Check PR size id: check_size run: | @@ -26,6 +28,7 @@ jobs: echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT echo "changed_lines=$CHANGED_LINES" >> $GITHUB_OUTPUT + # 4. OpenAI๋กœ ๋ฆฌ๋ทฐ ์š”์ฒญ - name: Review with OpenAI id: review env: @@ -43,10 +46,16 @@ jobs: "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] }' | jq -r '.choices[0].message.content') + # null ๋ฐฉ์ง€์šฉ fallback ์ฒ˜๋ฆฌ + if [ -z "$RESPONSE" ]; then + RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.)" + fi + echo "review=$RESPONSE" >> $GITHUB_OUTPUT + # 5. PR์— ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ (๋นˆ ์‘๋‹ต์ด๋ฉด ์Šคํ‚ต) - name: Comment on PR - if: steps.review.outputs.review != '' + if: ${{ steps.review.outputs.review != '' }} uses: marocchino/sticky-pull-request-comment@v2 with: message: | @@ -55,6 +64,7 @@ jobs: ${{ steps.review.outputs.review }} ``` + # 6. PR ํฌ๊ธฐ ์ดˆ๊ณผ ์‹œ ๊ฒฝ๊ณ  ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ - name: Warn if PR is too large if: ${{ steps.check_size.outputs.changed_files > 10 || steps.check_size.outputs.changed_lines > 500 }} env: @@ -66,4 +76,4 @@ jobs: - ๋ณ€๊ฒฝ๋œ ๋ผ์ธ ์ˆ˜: \`${{ steps.check_size.outputs.changed_lines }}\` ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ - --repo ${{ github.repository }} + --repo ${{ github.repository }} From 16e21b8b73cdabdb171a641c76eeb16338297f45 Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:25:36 +0900 Subject: [PATCH 05/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 6682e07..d7ae75b 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -55,7 +55,7 @@ jobs: # 5. PR์— ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ (๋นˆ ์‘๋‹ต์ด๋ฉด ์Šคํ‚ต) - name: Comment on PR - if: ${{ steps.review.outputs.review != '' }} + if: ${{ steps.review.outputs.review && steps.review.outputs.review != 'null' }} uses: marocchino/sticky-pull-request-comment@v2 with: message: | @@ -63,6 +63,8 @@ jobs: ``` ${{ steps.review.outputs.review }} ``` + env: + GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} # 6. PR ํฌ๊ธฐ ์ดˆ๊ณผ ์‹œ ๊ฒฝ๊ณ  ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ - name: Warn if PR is too large From 9da457351bbcdbad091a2b6262a186d6c9a147cd Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:27:44 +0900 Subject: [PATCH 06/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index d7ae75b..21b4db8 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -79,3 +79,8 @@ jobs: ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ --repo ${{ github.repository }} + + - name: Debug response + if: always() + run: | + echo "RESPONSE: ${{ steps.review.outputs.review }}" From 4bb3bc995d471c849bd9e491c91711a60f38a792 Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:30:21 +0900 Subject: [PATCH 07/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 21b4db8..2bfbbcd 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -38,17 +38,21 @@ jobs: DIFF=$(cat pr.diff | head -c 4000) FINAL_PROMPT="$PROMPT\n$DIFF" - RESPONSE=$(curl https://api.openai.com/v1/chat/completions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-4", + RAW_RESPONSE=$(curl --fail -s https://api.openai.com/v1/chat/completions \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] - }' | jq -r '.choices[0].message.content') + }') - # null ๋ฐฉ์ง€์šฉ fallback ์ฒ˜๋ฆฌ - if [ -z "$RESPONSE" ]; then - RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.)" + echo "==== GPT RAW RESPONSE ====" + echo "$RAW_RESPONSE" + + RESPONSE=$(echo "$RAW_RESPONSE" | jq -r '.choices[0].message.content' || echo "") + + if [ -z "$RESPONSE" ] || [ "$RESPONSE" = "null" ]; then + RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" fi echo "review=$RESPONSE" >> $GITHUB_OUTPUT From fb18206728e67667b3b4054636b7a153a887b15c Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:32:18 +0900 Subject: [PATCH 08/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 2bfbbcd..873d313 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -38,13 +38,13 @@ jobs: DIFF=$(cat pr.diff | head -c 4000) FINAL_PROMPT="$PROMPT\n$DIFF" - RAW_RESPONSE=$(curl --fail -s https://api.openai.com/v1/chat/completions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ + RAW_RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] - }') + }') echo "==== GPT RAW RESPONSE ====" echo "$RAW_RESPONSE" @@ -52,25 +52,32 @@ jobs: RESPONSE=$(echo "$RAW_RESPONSE" | jq -r '.choices[0].message.content' || echo "") if [ -z "$RESPONSE" ] || [ "$RESPONSE" = "null" ]; then - RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" + RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" fi echo "review=$RESPONSE" >> $GITHUB_OUTPUT - # 5. PR์— ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ (๋นˆ ์‘๋‹ต์ด๋ฉด ์Šคํ‚ต) + # โœ… 5. Debug (ํ•ญ์ƒ ์‹คํ–‰) + - name: Debug response + if: always() + run: | + echo "==== DEBUGGING GPT RESPONSE ====" + echo "REVIEW OUTPUT: ${{ steps.review.outputs.review }}" + + # 6. PR์— ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ (๋นˆ ์‘๋‹ต์ด๋ฉด ์Šคํ‚ต) - name: Comment on PR if: ${{ steps.review.outputs.review && steps.review.outputs.review != 'null' }} uses: marocchino/sticky-pull-request-comment@v2 with: message: | - ๐Ÿค– **AI ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์š”์•ฝ (GPT-4 ๊ธฐ๋ฐ˜)** + ๐Ÿค– **AI ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์š”์•ฝ (GPT-3.5 ๊ธฐ๋ฐ˜)** ``` ${{ steps.review.outputs.review }} ``` env: GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} - # 6. PR ํฌ๊ธฐ ์ดˆ๊ณผ ์‹œ ๊ฒฝ๊ณ  ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ + # 7. PR ํฌ๊ธฐ ์ดˆ๊ณผ ์‹œ ๊ฒฝ๊ณ  ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ - name: Warn if PR is too large if: ${{ steps.check_size.outputs.changed_files > 10 || steps.check_size.outputs.changed_lines > 500 }} env: @@ -82,9 +89,4 @@ jobs: - ๋ณ€๊ฒฝ๋œ ๋ผ์ธ ์ˆ˜: \`${{ steps.check_size.outputs.changed_lines }}\` ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ - --repo ${{ github.repository }} - - - name: Debug response - if: always() - run: | - echo "RESPONSE: ${{ steps.review.outputs.review }}" + --repo ${{ github.repository }} From 5a00b9753b7816b6e6ea962f62ae4019c78f30fa Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:35:10 +0900 Subject: [PATCH 09/14] =?UTF-8?q?fix(OK-123):=20ai-pr-review.yml=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ai-pr-review.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml index 873d313..bedd280 100644 --- a/.github/workflows/ai-pr-review.yml +++ b/.github/workflows/ai-pr-review.yml @@ -38,13 +38,16 @@ jobs: DIFF=$(cat pr.diff | head -c 4000) FINAL_PROMPT="$PROMPT\n$DIFF" + echo "$FINAL_PROMPT" > prompt.txt + ESCAPED_PROMPT=$(jq -Rs . < prompt.txt) + RAW_RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": "'"${FINAL_PROMPT//$'\n'/\\n}"'"}] - }') + "messages": [{"role": "user", "content": '"$ESCAPED_PROMPT"'}] + }') echo "==== GPT RAW RESPONSE ====" echo "$RAW_RESPONSE" @@ -52,7 +55,7 @@ jobs: RESPONSE=$(echo "$RAW_RESPONSE" | jq -r '.choices[0].message.content' || echo "") if [ -z "$RESPONSE" ] || [ "$RESPONSE" = "null" ]; then - RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" + RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" fi echo "review=$RESPONSE" >> $GITHUB_OUTPUT From 3ce657c01f31dcb770cad5f5b173b2676e22f726 Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:46:37 +0900 Subject: [PATCH 10/14] =?UTF-8?q?test(OK-123):=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=9E=98=EB=B9=97=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=9A=A9:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PatientListPage/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/PatientListPage/index.tsx b/src/pages/PatientListPage/index.tsx index 85e9d72..27998c8 100644 --- a/src/pages/PatientListPage/index.tsx +++ b/src/pages/PatientListPage/index.tsx @@ -14,7 +14,7 @@ const PatientListPage = () => { const result = useGetPatientList(); const data = result?.data ?? []; const isLoading = result?.isLoading ?? false; - + console.log(data); return (
From b461bde42ca34f4cc2cad2c01f4ca88b4f1c5cf1 Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 11:54:15 +0900 Subject: [PATCH 11/14] =?UTF-8?q?feat(OK-123):=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=9E=98=EB=B9=97=20config=20=ED=8C=8C=EC=9D=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .coderabbit/config.yml | 30 ++++++++++ .github/prompt/review.txt | 22 ------- .github/workflows/ai-pr-review.yml | 95 ------------------------------ 3 files changed, 30 insertions(+), 117 deletions(-) create mode 100644 .coderabbit/config.yml delete mode 100644 .github/prompt/review.txt delete mode 100644 .github/workflows/ai-pr-review.yml diff --git a/.coderabbit/config.yml b/.coderabbit/config.yml new file mode 100644 index 0000000..7723693 --- /dev/null +++ b/.coderabbit/config.yml @@ -0,0 +1,30 @@ +review: + model: gpt-3.5 # ๋˜๋Š” 'gpt-4' (์œ ๋ฃŒ ์š”๊ธˆ์ œ ์‚ฌ์šฉ ์‹œ) + language: ko + files: + - include: '**/*.ts' + - include: '**/*.tsx' + - exclude: '**/*.test.ts' + - exclude: '**/*.spec.ts' + + prompt: | + You are a senior React Native developer reviewing a pull request in a production-level project. + + ๐Ÿ› ๏ธ Project Stack: + - React Native with Expo + - TypeScript + - OpenAPI-based API handling + - App router-based navigation (like Expo Router or similar) + + Your goal is to: + 1. Focus on **performance issues**, especially those that may cause unnecessary re-renders, inefficient rendering in lists, or redundant API calls. + 2. Identify areas that are **likely to throw runtime errors**, especially "Cannot read property of undefined", null dereferencing, or optional chaining misuses. + 3. Suggest better **modularization**, such as breaking down components or extracting hooks/utilities if any logic is too large or repeated. + 4. Point out places where **better patterns or abstraction** could improve readability and maintainability (e.g., custom hooks, reusable UI components). + 5. Suggest **alternative approaches** where applicable (e.g., using FlatList instead of ScrollView, memoizing with `useMemo`, `useCallback`, etc.) + 6. Mention if any **types are too generic or unsafe** (e.g., use of `any`, improper inference). + + Output your response in **clear sections**: `Performance`, `Error Safety`, `Modularization`, `Suggestions`. + + If everything looks good, say `LGTM โœ…` under each section. + Always write in Korean. diff --git a/.github/prompt/review.txt b/.github/prompt/review.txt deleted file mode 100644 index 8d6372e..0000000 --- a/.github/prompt/review.txt +++ /dev/null @@ -1,22 +0,0 @@ -You are a senior React Native developer reviewing a pull request in a production-level project. - -๐Ÿ› ๏ธ Project Stack: -- React Native with Expo -- TypeScript -- OpenAPI-based API handling -- App router-based navigation (like Expo Router or similar) - -Your goal is to: -1. Focus on **performance issues**, especially those that may cause unnecessary re-renders, inefficient rendering in lists, or redundant API calls. -2. Identify areas that are **likely to throw runtime errors**, especially "Cannot read property of undefined", null dereferencing, or optional chaining misuses. -3. Suggest better **modularization**, such as breaking down components or extracting hooks/utilities if any logic is too large or repeated. -4. Point out places where **better patterns or abstraction** could improve readability and maintainability (e.g., custom hooks, reusable UI components). -5. Suggest **alternative approaches** where applicable (e.g., using FlatList instead of ScrollView, memoizing with `useMemo`, `useCallback`, etc.) -6. Mention if any **types are too generic or unsafe** (e.g., use of `any`, improper inference). - -Output your response in **clear sections**: `Performance`, `Error Safety`, `Modularization`, `Suggestions`. - -If everything looks good, say `LGTM โœ…` under each section. -Always write in Korean. - -Here is the code diff: \ No newline at end of file diff --git a/.github/workflows/ai-pr-review.yml b/.github/workflows/ai-pr-review.yml deleted file mode 100644 index bedd280..0000000 --- a/.github/workflows/ai-pr-review.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: AI PR Review - -on: - pull_request: - types: [opened, synchronize] - -jobs: - ai_review: - runs-on: ubuntu-latest - steps: - # 1. PR ์ฝ”๋“œ ์ฒดํฌ์•„์›ƒ - - name: Checkout PR code - uses: actions/checkout@v3 - - # 2. PR diff ์ƒ์„ฑ ๋ฐ ์ €์žฅ - - name: Get PR diff - id: diff - run: | - git fetch origin ${{ github.base_ref }} - git diff origin/${{ github.base_ref }} > pr.diff - - # 3. ๋ณ€๊ฒฝ ํŒŒ์ผ ์ˆ˜ / ๋ผ์ธ ์ˆ˜ ๊ณ„์‚ฐ - - name: Check PR size - id: check_size - run: | - CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} | wc -l) - CHANGED_LINES=$(git diff --shortstat origin/${{ github.base_ref }} | grep -o '[0-9]\+' | paste -sd+ - | bc || echo 0) - echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT - echo "changed_lines=$CHANGED_LINES" >> $GITHUB_OUTPUT - - # 4. OpenAI๋กœ ๋ฆฌ๋ทฐ ์š”์ฒญ - - name: Review with OpenAI - id: review - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - run: | - PROMPT=$(cat .github/prompt/review.txt) - DIFF=$(cat pr.diff | head -c 4000) - FINAL_PROMPT="$PROMPT\n$DIFF" - - echo "$FINAL_PROMPT" > prompt.txt - ESCAPED_PROMPT=$(jq -Rs . < prompt.txt) - - RAW_RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gpt-3.5-turbo", - "messages": [{"role": "user", "content": '"$ESCAPED_PROMPT"'}] - }') - - echo "==== GPT RAW RESPONSE ====" - echo "$RAW_RESPONSE" - - RESPONSE=$(echo "$RAW_RESPONSE" | jq -r '.choices[0].message.content' || echo "") - - if [ -z "$RESPONSE" ] || [ "$RESPONSE" = "null" ]; then - RESPONSE="(AI ์‘๋‹ต์ด ๋น„์–ด ์žˆ๊ฑฐ๋‚˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.)" - fi - - echo "review=$RESPONSE" >> $GITHUB_OUTPUT - - # โœ… 5. Debug (ํ•ญ์ƒ ์‹คํ–‰) - - name: Debug response - if: always() - run: | - echo "==== DEBUGGING GPT RESPONSE ====" - echo "REVIEW OUTPUT: ${{ steps.review.outputs.review }}" - - # 6. PR์— ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ (๋นˆ ์‘๋‹ต์ด๋ฉด ์Šคํ‚ต) - - name: Comment on PR - if: ${{ steps.review.outputs.review && steps.review.outputs.review != 'null' }} - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: | - ๐Ÿค– **AI ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์š”์•ฝ (GPT-3.5 ๊ธฐ๋ฐ˜)** - ``` - ${{ steps.review.outputs.review }} - ``` - env: - GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} - - # 7. PR ํฌ๊ธฐ ์ดˆ๊ณผ ์‹œ ๊ฒฝ๊ณ  ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ - - name: Warn if PR is too large - if: ${{ steps.check_size.outputs.changed_files > 10 || steps.check_size.outputs.changed_lines > 500 }} - env: - GH_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} - run: | - gh pr comment ${{ github.event.pull_request.number }} \ - --body "โš ๏ธ **์ด PR์€ ๋Œ€ํ˜• ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค.** - - ๋ณ€๊ฒฝ๋œ ํŒŒ์ผ ์ˆ˜: \`${{ steps.check_size.outputs.changed_files }}\` - - ๋ณ€๊ฒฝ๋œ ๋ผ์ธ ์ˆ˜: \`${{ steps.check_size.outputs.changed_lines }}\` - - ๋ฆฌ๋ทฐ ํšจ์œจ์„ ์œ„ํ•ด ๊ฐ€๋Šฅํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋” ์ž‘์€ PR๋กœ ๋‚˜๋ˆ ์ฃผ์„ธ์š” ๐Ÿ™" \ - --repo ${{ github.repository }} From 1a6e6f61f6217848263c1a6e38fe3f8731850dbf Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 13:39:27 +0900 Subject: [PATCH 12/14] =?UTF-8?q?chore/OK-123:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=9E=98=EB=B9=97=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PatientListPage/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/PatientListPage/index.tsx b/src/pages/PatientListPage/index.tsx index 27998c8..446900b 100644 --- a/src/pages/PatientListPage/index.tsx +++ b/src/pages/PatientListPage/index.tsx @@ -14,7 +14,19 @@ const PatientListPage = () => { const result = useGetPatientList(); const data = result?.data ?? []; const isLoading = result?.isLoading ?? false; - console.log(data); + + // ์ถ”ํ›„ ์‚ญ์ œ + console.log(data); // ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ + console.log(isLoading); + + const handlePressAdใ…‡Patient = (test: string) => { + console.log(test); + }; + + useEffect(() => { + handlePressAdPatient(1); + }, []); + return (
From 6521d8faf1db1ec79df9478db609e7cc551928ec Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 13:49:18 +0900 Subject: [PATCH 13/14] =?UTF-8?q?chore/OK-123:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=9E=98=EB=B9=97=EB=B9=97=20yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .coderabbit/config.yml => .condrabbit.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename .coderabbit/config.yml => .condrabbit.yml (81%) diff --git a/.coderabbit/config.yml b/.condrabbit.yml similarity index 81% rename from .coderabbit/config.yml rename to .condrabbit.yml index 7723693..0996ca0 100644 --- a/.coderabbit/config.yml +++ b/.condrabbit.yml @@ -21,10 +21,10 @@ review: 2. Identify areas that are **likely to throw runtime errors**, especially "Cannot read property of undefined", null dereferencing, or optional chaining misuses. 3. Suggest better **modularization**, such as breaking down components or extracting hooks/utilities if any logic is too large or repeated. 4. Point out places where **better patterns or abstraction** could improve readability and maintainability (e.g., custom hooks, reusable UI components). - 5. Suggest **alternative approaches** where applicable (e.g., using FlatList instead of ScrollView, memoizing with `useMemo`, `useCallback`, etc.) - 6. Mention if any **types are too generic or unsafe** (e.g., use of `any`, improper inference). + 5. Suggest **alternative approaches** where applicable (e.g., using FlatList instead of ScrollView, memoizing with useMemo, useCallback, etc.) + 6. Mention if any **types are too generic or unsafe** (e.g., use of any, improper inference). - Output your response in **clear sections**: `Performance`, `Error Safety`, `Modularization`, `Suggestions`. + Output your response in **clear sections**: Performance, Error Safety, Modularization, Suggestions. - If everything looks good, say `LGTM โœ…` under each section. + If everything looks good, say LGTM โœ… under each section. Always write in Korean. From 3547c33d5de3e880f313b430b9733c4ea16b379c Mon Sep 17 00:00:00 2001 From: hyorish03 Date: Wed, 14 May 2025 14:43:54 +0900 Subject: [PATCH 14/14] =?UTF-8?q?chore/OK-123:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=9E=98=EB=B9=97=EB=B9=97=20yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PatientListPage/index.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/pages/PatientListPage/index.tsx b/src/pages/PatientListPage/index.tsx index 446900b..c15c1a7 100644 --- a/src/pages/PatientListPage/index.tsx +++ b/src/pages/PatientListPage/index.tsx @@ -12,26 +12,14 @@ import { patientCardStyles, styles } from './styles'; const PatientListPage = () => { const result = useGetPatientList(); - const data = result?.data ?? []; + const data = result?.data; const isLoading = result?.isLoading ?? false; - // ์ถ”ํ›„ ์‚ญ์ œ - console.log(data); // ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ - console.log(isLoading); - - const handlePressAdใ…‡Patient = (test: string) => { - console.log(test); - }; - - useEffect(() => { - handlePressAdPatient(1); - }, []); - return (
- {data?.length === 0 ? ( + {data.length === 0 ? ( ) : (