Compare commits
No commits in common. "main" and "v1.7" have entirely different histories.
1 changed files with 92 additions and 3 deletions
95
.github/workflows/repo-pipeline.yml
vendored
95
.github/workflows/repo-pipeline.yml
vendored
|
|
@ -173,7 +173,6 @@ jobs:
|
||||||
|
|
||||||
- name: Dependency Review
|
- name: Dependency Review
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
continue-on-error: true
|
|
||||||
uses: actions/dependency-review-action@v4
|
uses: actions/dependency-review-action@v4
|
||||||
|
|
||||||
ai-review:
|
ai-review:
|
||||||
|
|
@ -185,8 +184,98 @@ jobs:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
# Claude review is performed locally by Claude Code before the PR is merged.
|
- name: Generate Claude review
|
||||||
# See CLAUDE.md in the repository for the process.
|
env:
|
||||||
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${ANTHROPIC_API_KEY:-}" ]; then
|
||||||
|
echo "::notice::ANTHROPIC_API_KEY not set – Claude review skipped"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
python3 << 'PYEOF'
|
||||||
|
import os, json, urllib.request
|
||||||
|
|
||||||
|
token = os.environ["GITHUB_TOKEN"]
|
||||||
|
repo = os.environ["REPO"]
|
||||||
|
pr_num = os.environ["PR_NUMBER"]
|
||||||
|
headers_gh = {"Authorization": f"Bearer {token}", "User-Agent": "vanity-dev-engine",
|
||||||
|
"Accept": "application/vnd.github.v3+json"}
|
||||||
|
|
||||||
|
# Skip if Claude review already exists
|
||||||
|
req = urllib.request.Request(
|
||||||
|
f"https://api.github.com/repos/{repo}/issues/{pr_num}/comments?per_page=100",
|
||||||
|
headers=headers_gh)
|
||||||
|
with urllib.request.urlopen(req) as r:
|
||||||
|
comments = json.loads(r.read())
|
||||||
|
if any("### Claude" in (c.get("body") or "") for c in comments):
|
||||||
|
print("Claude review already present – skipping generation.")
|
||||||
|
raise SystemExit(0)
|
||||||
|
|
||||||
|
# Fetch PR diff (truncated to 12 000 chars to stay within token limit)
|
||||||
|
req_diff = urllib.request.Request(
|
||||||
|
f"https://api.github.com/repos/{repo}/pulls/{pr_num}",
|
||||||
|
headers={**headers_gh, "Accept": "application/vnd.github.v3.diff"})
|
||||||
|
with urllib.request.urlopen(req_diff) as r:
|
||||||
|
diff = r.read().decode("utf-8", errors="replace")[:12000]
|
||||||
|
|
||||||
|
# Fetch PR body
|
||||||
|
req_pr = urllib.request.Request(
|
||||||
|
f"https://api.github.com/repos/{repo}/pulls/{pr_num}", headers=headers_gh)
|
||||||
|
with urllib.request.urlopen(req_pr) as r:
|
||||||
|
pr_data = json.loads(r.read())
|
||||||
|
pr_body = (pr_data.get("body") or "")[:800]
|
||||||
|
|
||||||
|
prompt = f"""You are a senior iOS Swift developer reviewing a pull request.
|
||||||
|
Analyse the changes carefully and write a concise code review.
|
||||||
|
|
||||||
|
PR title: {os.environ["PR_TITLE"]}
|
||||||
|
PR description: {pr_body}
|
||||||
|
|
||||||
|
Git diff (may be truncated):
|
||||||
|
{diff}
|
||||||
|
|
||||||
|
Reply with EXACTLY this structure – no deviations:
|
||||||
|
|
||||||
|
### Claude
|
||||||
|
|
||||||
|
DoD status: PASS
|
||||||
|
Blocker: 0
|
||||||
|
Major: 0
|
||||||
|
|
||||||
|
<your review here – cover code quality, correctness, Swift best practices,
|
||||||
|
potential bugs, and suggestions. Be specific and constructive.>
|
||||||
|
|
||||||
|
Only set DoD status to FAIL or raise Blocker/Major above 0 when you find
|
||||||
|
real defects that must be fixed before merging."""
|
||||||
|
|
||||||
|
payload = json.dumps({
|
||||||
|
"model": "claude-opus-4-6",
|
||||||
|
"max_tokens": 1500,
|
||||||
|
"messages": [{"role": "user", "content": prompt}]
|
||||||
|
}).encode()
|
||||||
|
req_ai = urllib.request.Request(
|
||||||
|
"https://api.anthropic.com/v1/messages", data=payload,
|
||||||
|
headers={"x-api-key": os.environ["ANTHROPIC_API_KEY"],
|
||||||
|
"anthropic-version": "2023-06-01",
|
||||||
|
"content-type": "application/json"})
|
||||||
|
with urllib.request.urlopen(req_ai) as r:
|
||||||
|
review = json.loads(r.read())["content"][0]["text"]
|
||||||
|
|
||||||
|
# Post comment
|
||||||
|
body_payload = json.dumps({"body": review}).encode()
|
||||||
|
req_post = urllib.request.Request(
|
||||||
|
f"https://api.github.com/repos/{repo}/issues/{pr_num}/comments",
|
||||||
|
data=body_payload,
|
||||||
|
headers={**headers_gh, "Content-Type": "application/json"})
|
||||||
|
with urllib.request.urlopen(req_post) as r:
|
||||||
|
result = json.loads(r.read())
|
||||||
|
print(f"Claude review posted: {result['html_url']}")
|
||||||
|
PYEOF
|
||||||
|
|
||||||
- name: Generate ChatGPT review
|
- name: Generate ChatGPT review
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue