Skip to content

Commit 066d956

Browse files
authored
Update review.yml
1 parent 516ae8e commit 066d956

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

.github/workflows/review.yml

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: PR Summary and Inline Issues Check
1+
name: Code Review Pipeline
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
55

66
jobs:
7-
summarize_and_check:
7+
code_review:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout Code
@@ -20,7 +20,7 @@ jobs:
2020
python -m pip install --upgrade pip
2121
pip install requests
2222
23-
- name: Run AI Analysis
23+
- name: Run Code Review
2424
env:
2525
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
2626
GITHUB_TOKEN: ${{ secrets.G_TOKEN }}
@@ -57,16 +57,15 @@ jobs:
5757
pr_files = requests.get(diff_url, headers=headers).json()
5858
5959
inline_comments = [] # Collect inline comments to post
60-
diff_text = ""
6160
6261
# Loop through the files in the PR
6362
for fdata in pr_files:
6463
filename = fdata['filename']
6564
patch = fdata.get('patch', '')
66-
diff_text += f"File: {filename}\\nPatch:\\n{patch}\\n\\n"
6765
6866
# Call OpenAI for inline code analysis
69-
issues_prompt = f"Review the following code changes for critical issues (e.g., syntax errors, undefined variables, broken imports). Provide specific inline comments for each issue with the corresponding line number from this diff:\n\n{patch}"
67+
issues_prompt = f"""Analyze the following code changes for syntax errors, typos, and critical issues. Provide comments for specific errors with the line number where they occur:
68+
\n\n{patch}"""
7069
ai_headers = {"Content-Type": "application/json", "Authorization": f"Bearer {openai_key}"}
7170
data_issues = {
7271
"model": "gpt-4o-mini",
@@ -94,7 +93,7 @@ jobs:
9493
"path": filename,
9594
"line": line_number,
9695
"side": "RIGHT", # Changes are always on the "RIGHT" side in the diff
97-
"body": f"**AI Code Issue Check:**\n{description}"
96+
"body": f"**AI Code Review:**\n{description}"
9897
})
9998
10099
# Post inline comments as a single review
@@ -110,26 +109,5 @@ jobs:
110109
review_response.raise_for_status()
111110
print("Inline review comments posted successfully.")
112111
else:
113-
print("No critical issues found in the code.")
114-
115-
# Always post PR summary
116-
summary_prompt = f"Summarize the following pull request changes in a concise, technical manner. Include details on which files were changed and a high-level overview of the changes:\n\n{diff_text}"
117-
data_summary = {
118-
"model": "gpt-4o-mini",
119-
"messages": [{"role": "user", "content": summary_prompt}],
120-
"temperature": 0.7
121-
}
122-
summary_response = requests.post("https://api.openai.com/v1/chat/completions", headers=ai_headers, json=data_summary)
123-
summary_response.raise_for_status()
124-
summary = summary_response.json()['choices'][0]['message']['content'].strip()
125-
126-
# Post AI Pull Request Summary
127-
comment_url = f"https://api.github.com/repos/{repo_full_name}/issues/{pr_number}/comments"
128-
summary_comment = {
129-
"body": f"**AI Pull Request Summary:**\\n{summary}"
130-
}
131-
summary_comment_response = requests.post(comment_url, headers={'Authorization': f'token {token}', 'Accept': 'application/vnd.github.v3+json'}, json=summary_comment)
132-
summary_comment_response.raise_for_status()
133-
134-
print("PR Summary posted successfully.")
112+
print("No issues found in the code.")
135113
EOF

0 commit comments

Comments
 (0)