Skip to content

Commit 0f397ee

Browse files
authored
Merge pull request #21 from Siquan-lab/master
test
2 parents 572e890 + 2ba2ee9 commit 0f397ee

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/scripts/ai_code_review.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ def call_gpt(diff_text):
3030
if not api_key:
3131
raise ValueError("❌ OPENAI_API_KEY is not set.")
3232

33+
api_endpoint = os.environ.get("OPENAI_API_ENDPOINT")
34+
3335
client = openai.OpenAI(
3436
api_key=api_key,
35-
base_url="https://llm-proxy.us-east-2.int.infra.intelligence.webex.com/azure/v1?api-version=2024-10-21",
37+
base_url=api_endpoint,
3638
default_headers={"api-key": api_key},
3739
)
3840

.github/workflows/ai_code_review.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,31 @@ jobs:
2727
- name: 📦 Install dependencies
2828
run: pip install openai requests
2929

30+
- name: ✅ Checkout the default branch
31+
uses: actions/checkout@v4
32+
with:
33+
# 在 pull_request_target 事件中,我们必须手动检出 PR 提交的代码
34+
# 否则它会检出主分支的代码,导致审查的是主分支而非PR分支
35+
ref: ${{ github.event.pull_request.h ead.sha }}
36+
3037
- name: 🧾 Download PR diff via GitHub API
38+
id: pr_diff
3139
env:
3240
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3341
GITHUB_REPOSITORY: ${{ github.repository }}
3442
PR_NUMBER: ${{ github.event.pull_request.number }}
3543
run: |
36-
curl -s -H "Authorization: token $GITHUB_TOKEN" \
37-
-H "Accept: application/vnd.github.v3.diff" \
38-
https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER \
39-
-o pr.diff
44+
# 确保 GITHUB_TOKEN 有权限读取 PR
45+
PR_DIFF=$(gh pr view ${{ github.event.number }} --json files --jq '.files | map(.patch) | join("\n")')
46+
# 将 diff 输出设置为一个环境变量
47+
echo "PR_DIFF<<EOF" >> $GITHUB_ENV
48+
echo "$PR_DIFF" >> $GITHUB_ENV
49+
echo "EOF" >> $GITHUB_ENV
4050
4151
- name: 🤖 Run AI code review
4252
env:
4353
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
54+
OPENAI_API_ENDPOINT: ${{ secrets.OPENAI_API_ENDPOINT }}
4455
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4556
GITHUB_REPOSITORY: ${{ github.repository }}
4657
PR_NUMBER: ${{ github.event.pull_request.number }}

src/test/java/net/lvsq/jgossip/BuggyCalculator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.logging.Logger;
1010

1111
public class BuggyCalculator {
12-
1312
private static final Logger logger = Logger.getLogger(BuggyCalculator.class.getName());
1413

1514
public double divide(int numerator, int denominator) {

0 commit comments

Comments
 (0)