Skip to content
Merged

test #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/scripts/ai_code_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ def call_gpt(diff_text):
if not api_key:
raise ValueError("❌ OPENAI_API_KEY is not set.")

api_endpoint = os.environ.get("OPENAI_API_ENDPOINT")

client = openai.OpenAI(
api_key=api_key,
base_url="https://llm-proxy.us-east-2.int.infra.intelligence.webex.com/azure/v1?api-version=2024-10-21",
base_url=api_endpoint,
default_headers={"api-key": api_key},
)

Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/ai_code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,31 @@ jobs:
- name: 📦 Install dependencies
run: pip install openai requests

- name: ✅ Checkout the default branch
uses: actions/checkout@v4
with:
# 在 pull_request_target 事件中,我们必须手动检出 PR 提交的代码
# 否则它会检出主分支的代码,导致审查的是主分支而非PR分支
ref: ${{ github.event.pull_request.h ead.sha }}

- name: 🧾 Download PR diff via GitHub API
id: pr_diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
curl -s -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3.diff" \
https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER \
-o pr.diff
# 确保 GITHUB_TOKEN 有权限读取 PR
PR_DIFF=$(gh pr view ${{ github.event.number }} --json files --jq '.files | map(.patch) | join("\n")')
# 将 diff 输出设置为一个环境变量
echo "PR_DIFF<<EOF" >> $GITHUB_ENV
echo "$PR_DIFF" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 🤖 Run AI code review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_ENDPOINT: ${{ secrets.OPENAI_API_ENDPOINT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
Expand Down
1 change: 0 additions & 1 deletion src/test/java/net/lvsq/jgossip/BuggyCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.logging.Logger;

public class BuggyCalculator {

private static final Logger logger = Logger.getLogger(BuggyCalculator.class.getName());

public double divide(int numerator, int denominator) {
Expand Down
Loading