From 55c6bca1f8d2cbbd33ba5a343a48e2c0fe5fb09c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 4 Jun 2026 23:57:05 +0800 Subject: [PATCH] chore: update ci pipeline examples (#45) * chore: remove --audience agent flag and simplify JSON parsing in CI examples - Remove --audience agent flag from ocr review commands in CI examples - Simplify JSON output parsing by reading directly without skipping first line - Update README docs to reflect the simplified CLI usage * fix: correct typo in .gitlab-ci.yml comment Change 'confuring' to 'setting' in CI variable configuration comment. --- README.md | 5 ++--- README.zh-CN.md | 5 ++--- examples/github_actions/ocr-review.yml | 6 ++---- examples/gitlab_ci/.gitlab-ci.yml | 6 ++---- examples/gitlab_ci/README.md | 3 +-- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2dccfa7..724932a 100644 --- a/README.md +++ b/README.md @@ -208,11 +208,10 @@ The core command for CI integration: ocr review \ --from "origin/main" \ --to "origin/feature-branch" \ - --format json \ - --audience agent + --format json ``` -The `--format json` and `--audience agent` flags output machine-readable results suitable for parsing in CI scripts. +The `--format json` flag outputs machine-readable results suitable for parsing in CI scripts. See the [`examples/`](./examples/) directory for integration examples: diff --git a/README.zh-CN.md b/README.zh-CN.md index 04b2b3a..baabd06 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -208,11 +208,10 @@ CI 集成的核心命令: ocr review \ --from "origin/main" \ --to "origin/feature-branch" \ - --format json \ - --audience agent + --format json ``` -`--format json` 和 `--audience agent` 参数输出适合 CI 脚本解析的机器可读结果。 +`--format json` 参数输出适合 CI 脚本解析的机器可读结果。 集成示例请参见 [`examples/`](./examples/) 目录: diff --git a/examples/github_actions/ocr-review.yml b/examples/github_actions/ocr-review.yml index 34e0b9d..ffeefb5 100644 --- a/examples/github_actions/ocr-review.yml +++ b/examples/github_actions/ocr-review.yml @@ -95,7 +95,6 @@ jobs: --from "origin/${BASE_REF}" \ --to "origin/${HEAD_REF}" \ --format json \ - --audience agent \ > /tmp/ocr-result.json 2>/tmp/ocr-stderr.log || true echo "OCR review completed. Output:" @@ -111,12 +110,11 @@ jobs: const fs = require('fs'); const path = '/tmp/ocr-result.json'; - // Read OCR output (skip first line which is not valid JSON) + // Read OCR output let result; try { const raw = fs.readFileSync(path, 'utf8'); - const jsonContent = raw.substring(raw.indexOf('\n') + 1); - result = JSON.parse(jsonContent); + result = JSON.parse(raw); } catch (e) { console.log('Failed to parse OCR output:', e.message); // Post a simple comment if parsing fails diff --git a/examples/gitlab_ci/.gitlab-ci.yml b/examples/gitlab_ci/.gitlab-ci.yml index 7d915bd..9bcd372 100644 --- a/examples/gitlab_ci/.gitlab-ci.yml +++ b/examples/gitlab_ci/.gitlab-ci.yml @@ -27,7 +27,7 @@ code-review: # Configure OCR - mkdir -p ~/.open-code-review - # Gitlab CI/CD does not support confuring variables with value length less than 8, so you can't set use_anthropic as a CI variable + # Gitlab CI/CD does not support setting variables with value length less than 8, so you can't set use_anthropic as a CI variable - | ocr config set llm.url $OCR_LLM_URL ocr config set llm.auth_token $OCR_LLM_AUTH_TOKEN @@ -42,7 +42,6 @@ code-review: --from "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" \ --to "origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" \ --format json \ - --audience agent \ > /tmp/ocr-result.json 2>/tmp/ocr-stderr.log || true echo "OCR review completed." cat /tmp/ocr-result.json @@ -139,10 +138,9 @@ code-review: # --- Main --- - # Read OCR result (skip first line which is summary, not JSON) + # Read OCR result try: with open("/tmp/ocr-result.json", "r") as f: - next(f) # Skip first line result = json.load(f) except (FileNotFoundError, json.JSONDecodeError) as e: print(f"Failed to parse OCR output: {e}", file=sys.stderr) diff --git a/examples/gitlab_ci/README.md b/examples/gitlab_ci/README.md index ae1615f..68874e4 100644 --- a/examples/gitlab_ci/README.md +++ b/examples/gitlab_ci/README.md @@ -172,8 +172,7 @@ script: "ocr", "review", "--from", f"origin/{TARGET_BRANCH}", "--to", f"origin/{SOURCE_BRANCH}", - "--format", "json", - "--audience", "agent" + "--format", "json" ], capture_output=True, text=True) # Save output for the posting script