From 7b4ade82af5e31b3074ffd810de02646e2f5a949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:53:45 -0300 Subject: [PATCH] ci: use lambdaclass/actions reusable workflows for AI review --- .../prompts/{pr_review.md => ai-review.md} | 0 .github/workflows/ai-review.yml | 36 ++++++ .github/workflows/pr_review_chatgpt.yaml | 48 -------- .github/workflows/pr_review_claude.yaml | 49 -------- .github/workflows/pr_review_kimi.yaml | 113 ------------------ 5 files changed, 36 insertions(+), 210 deletions(-) rename .github/prompts/{pr_review.md => ai-review.md} (100%) create mode 100644 .github/workflows/ai-review.yml delete mode 100644 .github/workflows/pr_review_chatgpt.yaml delete mode 100644 .github/workflows/pr_review_claude.yaml delete mode 100644 .github/workflows/pr_review_kimi.yaml diff --git a/.github/prompts/pr_review.md b/.github/prompts/ai-review.md similarity index 100% rename from .github/prompts/pr_review.md rename to .github/prompts/ai-review.md diff --git a/.github/workflows/ai-review.yml b/.github/workflows/ai-review.yml new file mode 100644 index 0000000..d8b302b --- /dev/null +++ b/.github/workflows/ai-review.yml @@ -0,0 +1,36 @@ +# AI Code Review using lambdaclass/actions reusable workflows +# +# Triggers: +# - Automatically on PR open/ready_for_review +# - On-demand via PR comments: /kimi, /codex, /claude (requires write access) +# +# Custom prompt: .github/prompts/ai-review.md +# +# Required secrets: +# - KIMI_API_KEY: For Kimi reviews (https://platform.moonshot.ai/) +# - OPENAI_API_KEY: For Codex reviews (https://platform.openai.com/) +# - ANTHROPIC_API_KEY: For Claude reviews (https://console.anthropic.com/) + +name: AI Code Review + +on: + pull_request: + types: [opened, ready_for_review] + issue_comment: + types: [created] + +jobs: + kimi-review: + uses: lambdaclass/actions/.github/workflows/ai-review-kimi.yml@v1 + secrets: + KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }} + + codex-review: + uses: lambdaclass/actions/.github/workflows/ai-review-codex.yml@v1 + secrets: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + + claude-review: + uses: lambdaclass/actions/.github/workflows/ai-review-claude.yml@v1 + secrets: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} diff --git a/.github/workflows/pr_review_chatgpt.yaml b/.github/workflows/pr_review_chatgpt.yaml deleted file mode 100644 index 70affed..0000000 --- a/.github/workflows/pr_review_chatgpt.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: PR Review - ChatGPT - -on: - pull_request: - types: [opened, synchronize, reopened] - pull_request_review_comment: - types: [created] - issue_comment: - types: [created] - -permissions: - contents: read - pull-requests: write - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - chatgpt-review: - name: ChatGPT Code Review - if: | - github.event_name == 'pull_request' || - (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@chatgpt')) || - (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@chatgpt')) - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Read review prompt - id: prompt - run: | - PROMPT=$(cat .github/prompts/pr_review.md) - echo "content<> $GITHUB_OUTPUT - echo "$PROMPT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: ChatGPT Code Review - uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - MODEL: gpt-4o - LANGUAGE: English - MAX_PATCH_LENGTH: 100000 - max_tokens: 4096 - PROMPT: ${{ steps.prompt.outputs.content }} diff --git a/.github/workflows/pr_review_claude.yaml b/.github/workflows/pr_review_claude.yaml deleted file mode 100644 index 83379e1..0000000 --- a/.github/workflows/pr_review_claude.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: PR Review - Claude - -on: - pull_request: - types: [opened, synchronize, reopened] - pull_request_review_comment: - types: [created] - issue_comment: - types: [created] - -permissions: - contents: read - pull-requests: write - issues: write - id-token: write - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - claude-review: - name: Claude Code Review - if: | - github.event_name == 'pull_request' || - (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) || - (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Read review prompt - id: prompt - run: | - PROMPT=$(cat .github/prompts/pr_review.md) - echo "content<> $GITHUB_OUTPUT - echo "$PROMPT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Claude Code Review - uses: anthropics/claude-code-action@v1 - with: - anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - claude_args: | - --max-turns 5 - --model claude-sonnet-4-20250514 - trigger_phrase: "@claude" - prompt: ${{ steps.prompt.outputs.content }} diff --git a/.github/workflows/pr_review_kimi.yaml b/.github/workflows/pr_review_kimi.yaml deleted file mode 100644 index 5599be2..0000000 --- a/.github/workflows/pr_review_kimi.yaml +++ /dev/null @@ -1,113 +0,0 @@ -name: PR Review - Kimi - -on: - pull_request: - types: [opened, synchronize, reopened] - pull_request_review_comment: - types: [created] - issue_comment: - types: [created] - -permissions: - contents: read - pull-requests: write - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - kimi-review: - name: Kimi Code Review - if: | - github.event_name == 'pull_request' || - (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@kimi')) || - (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@kimi')) - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Read review prompt - id: prompt - run: | - PROMPT=$(cat .github/prompts/pr_review.md) - echo "content<> $GITHUB_OUTPUT - echo "$PROMPT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Get PR diff - id: diff - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr diff ${{ github.event.pull_request.number }} > pr_diff.txt - # Truncate if too large (Kimi has context limits) - head -c 100000 pr_diff.txt > pr_diff_truncated.txt - - - name: Kimi Code Review - id: kimi_review - env: - KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }} - PR_TITLE: ${{ github.event.pull_request.title }} - REVIEW_PROMPT: ${{ steps.prompt.outputs.content }} - run: | - if [ -z "$KIMI_API_KEY" ]; then - echo "Error: KIMI_API_KEY secret is not set" > kimi_review.txt - exit 0 - fi - - DIFF_CONTENT=$(cat pr_diff_truncated.txt) - - # Build the request body - REQUEST_BODY=$(jq -n \ - --arg diff "$DIFF_CONTENT" \ - --arg title "$PR_TITLE" \ - --arg prompt "$REVIEW_PROMPT" \ - '{ - "model": "moonshot-v1-128k", - "messages": [ - { - "role": "system", - "content": $prompt - }, - { - "role": "user", - "content": ("PR Title: " + $title + "\n\nDiff:\n" + $diff) - } - ], - "temperature": 0.3, - "max_tokens": 4096 - }') - - # Try the API call - HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" https://api.moonshot.ai/v1/chat/completions \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $KIMI_API_KEY" \ - -d "$REQUEST_BODY") - - HTTP_CODE=$(echo "$HTTP_RESPONSE" | tail -n1) - RESPONSE=$(echo "$HTTP_RESPONSE" | sed '$d') - - if [ "$HTTP_CODE" != "200" ]; then - echo "API Error (HTTP $HTTP_CODE): $RESPONSE" > kimi_review.txt - else - # Check for API errors in response - ERROR=$(echo "$RESPONSE" | jq -r '.error.message // empty') - if [ -n "$ERROR" ]; then - echo "API Error: $ERROR" > kimi_review.txt - else - REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "Error: Unexpected API response"') - echo "$REVIEW" > kimi_review.txt - fi - fi - - - name: Post review comment - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "

Kimi AI Code Review

" > body.md - cat kimi_review.txt >> body.md - echo -e "\n---\n*Automated review by Kimi (Moonshot AI)*\n
" >> body.md - - gh pr comment ${{ github.event.pull_request.number }} --body-file body.md