mirror of
https://github.com/Sea-Haven-Industries/pr-reviewer.git
synced 2026-09-30 08:03:17 +00:00
A single-user local dashboard that pulls open PRs from the Sea-Haven-Industries org, reviews each with a Fireworks model in the BLOCK/FIX/NIT/QUESTION format, and posts the review to GitHub as the token owner. Runs only on localhost; secrets stay in a gitignored .env and never reach the browser. Structured as an app/ package plus a static/ frontend so the module imports and static mount resolve. HTTP uses httpx2 (the runtime lib starlette's TestClient now prefers), pinned in requirements.txt. Includes a stdlib-only pytest suite (network mocked, no extra test deps so CI needs only pytest) with a skip-by-default live Fireworks test, and CI wired to the org ci-python-app reusable workflow to lint app and tests and run the mocked suite fully offline. Dependabot covers pip and github-actions.
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
"""Live Fireworks integration test (opt-in, needs a real key).
|
|
|
|
Validates that the configured FIREWORKS_MODEL slug (default
|
|
accounts/fireworks/models/deepseek-v4-pro) actually works end to end and returns
|
|
JSON the reviewer can parse. Skipped automatically when FIREWORKS_API_KEY is
|
|
unset, so the mocked suite and CI stay offline.
|
|
|
|
Run just this: ``pytest -m live``
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
from dotenv import load_dotenv
|
|
|
|
# Ensure .env is loaded so the skip guard and Config both see the real key.
|
|
load_dotenv()
|
|
|
|
from app.config import Config # noqa: E402
|
|
from app.reviewer import Reviewer # noqa: E402
|
|
|
|
pytestmark = pytest.mark.live
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not os.getenv("FIREWORKS_API_KEY"),
|
|
reason="FIREWORKS_API_KEY not set; live Fireworks test skipped",
|
|
)
|
|
def test_live_fireworks_review_roundtrip() -> None:
|
|
cfg = Config()
|
|
assert cfg.FIREWORKS_API_KEY, "expected a real Fireworks key from .env"
|
|
|
|
reviewer = Reviewer(cfg)
|
|
pr = {
|
|
"number": 1,
|
|
"title": "Add divide helper",
|
|
"author": "octocat",
|
|
"owner": "Sea-Haven-Industries",
|
|
"repo": "sandbox",
|
|
"body": "Adds a small division helper.",
|
|
}
|
|
diff = (
|
|
"diff --git a/calc.py b/calc.py\n"
|
|
"new file mode 100644\n"
|
|
"--- /dev/null\n"
|
|
"+++ b/calc.py\n"
|
|
"@@ -0,0 +1,2 @@\n"
|
|
"+def divide(a, b):\n"
|
|
"+ return a / b\n"
|
|
)
|
|
|
|
result = reviewer.review(pr, diff)
|
|
|
|
# The response must be parseable JSON shaped like a review.
|
|
assert isinstance(result, dict)
|
|
assert "summary" in result
|
|
assert "_body_markdown" in result
|
|
assert result["_body_markdown"].startswith("**Summary:**")
|
|
# recommended_event, when present, must be one of the allowed values.
|
|
if result.get("recommended_event"):
|
|
assert result["recommended_event"] in {
|
|
"COMMENT",
|
|
"APPROVE",
|
|
"REQUEST_CHANGES",
|
|
}
|