Files
cli-autoreview/.github/workflows/ai-review.yml
Roberto Guagliardo 4c29732a8e
Some checks failed
AI Reviewer / review (pull_request) Failing after 7s
New python
2026-02-02 20:13:55 +00:00

83 lines
2.5 KiB
YAML

name: AI Reviewer
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
review:
runs-on: ubuntu-latest
container:
image: python:3.11-bookworm
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Show Python
run: python --version
- name: Install system deps (git + curl)
run: |
apt-get update
apt-get install -y --no-install-recommends git curl ca-certificates
git --version
curl --version
- name: Create venv and install project
run: |
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -e ".[dev]"
- name: Wait for Ollama
run: |
for i in $(seq 1 60); do
if curl -sSf http://192.168.1.92:11434/api/tags >/dev/null 2>&1; then
echo "ollama ready" && exit 0
fi
sleep 1
done
echo "ollama not reachable" >&2
exit 1
- 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');
let body = '{}';
try { body = fs.readFileSync('review.json', 'utf8'); } catch (e) {
body = JSON.stringify({ error: 'missing-review', message: String(e) });
}
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` +
'```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,
});