Init
This commit is contained in:
79
.github/workflows/ai-review.yml
vendored
Normal file
79
.github/workflows/ai-review.yml
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
name: AI Reviewer
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
review:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- 11434:11434
|
||||
options: >-
|
||||
--health-cmd='curl -sSf http://192.168.1.92/:11434/ || exit 1' --health-interval=10s --health-timeout=5s --health-retries=12
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Create venv and install
|
||||
run: |
|
||||
python -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -e ".[dev]"
|
||||
|
||||
- name: Wait for Ollama
|
||||
run: |
|
||||
# Wait for Ollama service to be ready
|
||||
for i in $(seq 1 30); do
|
||||
if curl -sSf http://192.168.1.92:11434/ >/dev/null 2>&1; then
|
||||
echo "ollama ready" && break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: (Optional) Pull model into Ollama
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
# ignore errors if ollama CLI not available in container; it's optional
|
||||
ollama pull qwen2.5-coder:7b || true
|
||||
|
||||
- name: Run ai-reviewer
|
||||
env:
|
||||
OLLAMA_HOST: http://192.168.1.92:11434
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
ai-reviewer review --repo . --base "${{ github.event.pull_request.base.ref }}" --head "${{ github.head_ref }}" --format json > review.json
|
||||
|
||||
- name: Post PR comment with findings
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const body = fs.readFileSync('review.json','utf8');
|
||||
let parsed = {};
|
||||
try { parsed = JSON.parse(body); } catch (e) { parsed = { error: 'invalid-json', raw: body }; }
|
||||
const findings = parsed.findings || [];
|
||||
const summary = findings.length === 0 ? 'AI Reviewer: no findings.' : `AI Reviewer found ${findings.length} findings.`;
|
||||
const commentBody = `${summary}\n\n<details><summary>Full JSON</summary>\n\n\n\n\
|
||||
\
|
||||
\n\n\n\\n\\n\n\
|
||||
\n\
|
||||
\n\n\n\n\n\n\n\n\n\
|
||||
\n\`
|
||||
\n\n` + '```json\n' + JSON.stringify(parsed, null, 2) + '\n```\n</details>';
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: commentBody,
|
||||
});
|
||||
Reference in New Issue
Block a user