Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Update ai-code-reviewer.yml

LearningCircuit58396860291a
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index 0613a3f432..3b341a2ef7 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -34,21 +34,86 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
- AI_MODEL: z-ai/glm-4.6
- AI_TEMPERATURE: 0.1
- AI_MAX_TOKENS: 2000
- MAX_DIFF_SIZE: 800000
+ AI_MODEL: ${{ vars.AI_MODEL || 'z-ai/glm-4.6' }}
+ AI_TEMPERATURE: ${{ vars.AI_TEMPERATURE || '0.1' }}
+ AI_MAX_TOKENS: ${{ vars.AI_MAX_TOKENS || '2000' }}
+ MAX_DIFF_SIZE: ${{ vars.MAX_DIFF_SIZE || '800000' }}
+ EXCLUDE_FILE_PATTERNS: ${{ vars.EXCLUDE_FILE_PATTERNS || '*.lock,*.min.js,*.min.css,package-lock.json,yarn.lock' }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO_FULL_NAME: ${{ github.repository }}
+ FAIL_ON_REQUESTED_CHANGES: ${{ vars.FAIL_ON_REQUESTED_CHANGES || 'false' }}
+ DEBUG_MODE: ${{ vars.DEBUG_MODE || 'false' }}
run: |
- # Run the AI reviewer and post the comment directly via stdin
- # If the script fails, the error message will be posted as a comment
- cat diff.txt | bash github/scripts/ai-reviewer.sh | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F - || {
- echo "⚠️ AI Code Review failed. Check the workflow logs for details."
+ # Run the AI reviewer and save response to file
+ echo "Running AI code review..."
+ AI_RESPONSE=$(cat diff.txt | bash ai-reviewer.sh)
+
+ # Save response for debugging (only in debug mode)
+ if [ "$DEBUG_MODE" = "true" ]; then
+ echo "Debug: AI response saved to ai_response.txt"
+ echo "$AI_RESPONSE" > ai_response.txt
+ fi
+
+ # Check if AI_RESPONSE is empty
+ if [ -z "$AI_RESPONSE" ]; then
+ echo "❌ AI response is empty"
+ exit 1
+ fi
+
+ # Parse JSON response
+ if ! echo "$AI_RESPONSE" | jq . >/dev/null 2>&1; then
+ echo "⚠️ AI response is not valid JSON. Cannot process review."
+ # Don't post raw response as it may contain sensitive data
+ echo "AI response could not be processed. Please check the workflow logs." | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F -
exit 1
- }
+ fi
+
+ # Extract fields from JSON
+ REVIEW=$(echo "$AI_RESPONSE" | jq -r '.review // "No review provided"')
+ DECISION=$(echo "$AI_RESPONSE" | jq -r '.fail_pass_workflow // "uncertain"')
+ LABELS=$(echo "$AI_RESPONSE" | jq -r '.labels_added[]? // empty')
+
+ # Post the review as PR comment
+ echo "$REVIEW" | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F -
+
+ # Add labels to PR
+ echo "Labels to add: $LABELS"
+ for label in $LABELS; do
+ echo "Adding label: $label"
+ if gh label create "$label" --color "0366d6" --description "Auto-created by AI reviewer" 2>/dev/null; then
+ echo "Created new label: $label"
+ else
+ echo "Label already exists: $label"
+ fi
+ if gh issue edit ${{ github.event.pull_request.number }} --add-label "$label" 2>/dev/null; then
+ echo "Successfully added label: $label"
+ else
+ echo "Failed to add label: $label"
+ fi
+ done
+
+ # Handle workflow decision
+ echo "AI decision: $DECISION"
+ if [ "$FAIL_ON_REQUESTED_CHANGES" = "true" ] && [ "$DECISION" = "fail" ]; then
+ echo "❌ AI requested changes and FAIL_ON_REQUESTED_CHANGES is enabled. Failing workflow."
+ exit 1
+ fi
+
+ echo "✅ AI review completed successfully"
+
+ # Remove the ai_code_review label to make re-triggering easier
+ echo "Removing ai_code_review label to allow easy re-triggering"
+ if gh issue edit ${{ github.event.pull_request.number }} --remove-label "ai_code_review" 2>/dev/null; then
+ echo "Successfully removed ai_code_review label"
+ else
+ echo "Failed to remove ai_code_review label (may have been already removed)"
+ fi
- name: Cleanup
if: always()
run: |
rm -f diff.txt
+ # Only remove ai_response.txt if it exists (only created in debug mode)
+ if [ -f "ai_response.txt" ]; then
+ rm -f ai_response.txt
+ fi