* Add CodeUp CI integration (issue #517) Adds examples/codeup_ci with: - post_review.py: runs ocr review --format json and posts a GLOBAL_COMMENT summary via CodeUp's CreateChangeRequestComment API - post_review_test.py: unit tests (27 passing) - codeup-flow.yml: example Yunxiao Flow pipeline - README.md: setup docs and known limitations (v1 = summary comment only, inline comments as a follow-up) * chore: ignore Python cache files * Add actual file contents for CodeUp CI integration * Use generic placeholder for OCR_LLM_MODEL example * Address review: remove local .gitignore, add trailing newlines, simplify testing docs |
||
|---|---|---|
| .. | ||
| codeup-flow.yml | ||
| post_review.py | ||
| post_review_test.py | ||
| README.md | ||
CodeUp CI Integration
Run open-code-review (ocr) automatically on every merge request in
Alibaba Cloud Yunxiao CodeUp, posting results
as a merge request comment via Flow.
How it works
- A Yunxiao Flow pipeline is triggered on merge request open/update.
- The pipeline installs Node.js and the
ocrCLI. post_review.pyrunsocr review --format jsonagainst the diff between the merge request's target and source branches.- Findings are formatted into a single Markdown summary and posted to the merge request via the CreateChangeRequestComment API.
This posts one summary comment per review run rather than true inline per-line comments. Inline comments require resolving the merge request's current patchset ID first — a reasonable follow-up, tracked as a known limitation below.
Setup
-
Copy
codeup-flow.ymlinto your repository (or paste its contents into a new pipeline in the Flow console) and adjustendpoint,serviceConnection, andrunsOnfor your organization. -
Copy
post_review.pyalongside it (or reference it directly if you keep it in a shared location). -
Configure the following pipeline variables in Flow, marking secrets as protected:
Variable Required Description CODEUP_TOKENYes (secret) Personal access token used for the x-yunxiao-tokenheader.CODEUP_ORG_IDYes Your Yunxiao organization ID. CODEUP_REPO_IDYes Numeric ID of the CodeUp repository. OCR_LLM_URLYes Your LLM endpoint, e.g. https://api.anthropic.com/v1/messages.OCR_LLM_TOKENYes (secret) API key for the LLM endpoint. OCR_LLM_MODELYes Model name, e.g. <provider-model-name>.OCR_USE_ANTHROPICIf using Anthropic Set to truewhenOCR_LLM_URLis an Anthropic-compatible endpoint.CODEUP_MR_LOCAL_ID,CODEUP_TARGET_BRANCH, andCODEUP_SOURCE_BRANCHare populated automatically from the merge request trigger context — seecodeup-flow.ymlfor how they're wired into the step's environment. -
Enable the merge-request trigger on the pipeline's code source (Edit pipeline → Edit code source → Enable code source trigger, with trigger event set to "Merge request created/updated").
Optional flags
Set OCR_REVIEW_EXTRA_ARGS as a pipeline variable to pass extra flags to
ocr review, e.g. --concurrency 4.
Known limitations
- Summary comment only. Findings are posted as one combined Markdown
comment rather than individual inline comments anchored to specific
lines. True inline comments would require calling
CreateChangeRequestComment once per finding with
file_pathandline_numberset against the merge request's current patchset — planned as a follow-up. - Requires a full (non-shallow) clone, or at minimum a fetch of the target
branch, since
post_review.pydiffsorigin/<target>againstorigin/<source>.
Local testing
python3 -m unittest post_review_test -v