A cache entry cannot be overwritten, so the fixed key restored the same old snapshot on every later run and no progress made after it survived. Save each run under its own key and restore the newest one, and cache the OCR session records only: the checkout is rebuilt from scratch every run, which is what keeps files the new head deleted out of the review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.7 KiB
YAML
112 lines
4.7 KiB
YAML
name: PR Review
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches: [main]
|
|
types: [opened, reopened, ready_for_review, synchronize]
|
|
workflow_dispatch:
|
|
inputs:
|
|
pull_number:
|
|
description: PR number
|
|
required: true
|
|
type: number
|
|
|
|
permissions: {}
|
|
|
|
env:
|
|
OCR_VERSION: v1.14.8
|
|
OCR_SHA256: fd82b5ddc1599fbad0680231a74e5292d4d7158522642e06c9229ed6ef32365f
|
|
|
|
concurrency:
|
|
group: pr-review-${{ github.event.pull_request.number || inputs.pull_number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
review:
|
|
name: Reims Go Reviewer
|
|
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'workflow_dispatch' || !github.event.pull_request.draft)
|
|
runs-on: ubuntu-latest
|
|
# Up to three review rounds, each bounded by the OCR timeout.
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: Create reviewer App token
|
|
id: app-token
|
|
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2
|
|
with:
|
|
app-id: ${{ secrets.OCR_APP_ID }}
|
|
private-key: ${{ secrets.OCR_APP_PRIVATE_KEY }}
|
|
repositories: Reims-Go
|
|
|
|
# Load only trusted scripts, rules, and documentation from the workflow commit.
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
ref: ${{ github.workflow_sha }}
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
sparse-checkout-cone-mode: false
|
|
sparse-checkout: |
|
|
/.github/scripts/pr-review.mjs
|
|
/.github/scripts/pr-review-language.mjs
|
|
/.opencodereview/rule.json
|
|
/docs/pr-review-guidelines.md
|
|
/docs/design-guidelines.md
|
|
/go.mod
|
|
|
|
- name: Cache OpenCodeReview binary
|
|
id: ocr-cache
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: ${{ runner.temp }}/ocr-bin
|
|
key: opencodereview-${{ env.OCR_VERSION }}-${{ env.OCR_SHA256 }}
|
|
|
|
# Only the OCR session records are kept: the checkout is rebuilt each run,
|
|
# and the session records are what let a review continue where it stopped.
|
|
# A cache entry cannot be overwritten, so each run saves under its own key
|
|
# and the next run restores the newest entry with the prefix below; GitHub
|
|
# evicts entries that stay unused for seven days, and least recently used
|
|
# ones when the repository reaches its cache quota.
|
|
- name: Cache PR review sessions
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
|
|
with:
|
|
path: ${{ runner.temp }}/pr-review-state/sessions
|
|
key: pr-review-sessions-${{ github.repository }}-${{ github.event.pull_request.number || inputs.pull_number }}-${{ github.run_id }}
|
|
restore-keys: |
|
|
pr-review-sessions-${{ github.repository }}-${{ github.event.pull_request.number || inputs.pull_number }}-
|
|
|
|
- name: Ensure PR review state directories
|
|
shell: bash
|
|
run: mkdir -p "$RUNNER_TEMP/pr-review-state/sessions"
|
|
|
|
- name: Download OpenCodeReview
|
|
if: steps.ocr-cache.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p "$RUNNER_TEMP/ocr-bin"
|
|
curl --fail --location --retry 3 --output "$RUNNER_TEMP/ocr-bin/ocr" "https://github.com/alibaba/open-code-review/releases/download/$OCR_VERSION/opencodereview-linux-amd64"
|
|
|
|
- name: Verify OpenCodeReview
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
echo "$OCR_SHA256 $RUNNER_TEMP/ocr-bin/ocr" | sha256sum --check --strict
|
|
chmod 700 "$RUNNER_TEMP/ocr-bin/ocr"
|
|
|
|
- name: Review PR
|
|
env:
|
|
PR_REVIEW_OCR_BIN: ${{ runner.temp }}/ocr-bin/ocr
|
|
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
PR_REVIEW_BOT_LOGIN: ${{ vars.PR_REVIEW_BOT_LOGIN }}
|
|
PR_REVIEW_APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
|
|
PR_REVIEW_LLM_KEY: ${{ secrets.PR_REVIEW_LLM_KEY }}
|
|
PR_REVIEW_LLM_BASE_URL: ${{ vars.PR_REVIEW_LLM_BASE_URL || 'https://open.bigmodel.cn/api/anthropic' }}
|
|
PR_REVIEW_LLM_MODEL: ${{ vars.PR_REVIEW_LLM_MODEL || 'glm-5.4' }}
|
|
PR_REVIEW_LLM_PROTOCOL: ${{ vars.PR_REVIEW_LLM_PROTOCOL || 'anthropic' }}
|
|
PR_REVIEW_LLM_EXTRA_BODY: ${{ vars.PR_REVIEW_LLM_EXTRA_BODY }}
|
|
PR_REVIEW_CODE_SUGGESTIONS: ${{ vars.PR_REVIEW_CODE_SUGGESTIONS }}
|
|
PR_REVIEW_STATE_DIR: ${{ runner.temp }}/pr-review-state/sessions
|
|
PR_REVIEW_SESSION_HOME: ${{ runner.temp }}/pr-review-state/sessions
|
|
PR_REVIEW_REUSE_INCOMPLETE: "true"
|
|
run: node .github/scripts/pr-review.mjs
|