fix(ci): hand review diff to agent as file, not argv
PR Check / Dockerfile lint (droast) (pull_request) Skipped
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 35s
PR Check / Typecheck (pull_request) Successful in 38s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 5s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / AI code review (opencode) (pull_request) Failing after 11s
PR Check / Dockerfile lint (droast) (pull_request) Skipped
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / ESLint (pull_request) Successful in 35s
PR Check / Typecheck (pull_request) Successful in 38s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 5s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / AI code review (opencode) (pull_request) Failing after 11s
Passing the PR diff as a command-line argument exceeded
MAX_ARG_STRLEN (128KiB per single argument; the diff was 190KB,
mostly pnpm-lock.yaml). The shell failed with E2BIG ('Argument list
too long') and the tee pipeline masked the failure, so the raw error
log got posted as a 'review' comment.
- exclude pnpm-lock.yaml from the review diff (pnpm audit covers deps)
- write the diff to .pr-review-diff.patch in the workspace; the agent
reads it with file tools
- redirect output instead of piping through tee and fail the job when
opencode fails, so errors are never posted as review comments
This commit is contained in:
1 parent
99f6e28ad0
commit
16b9291a51
1 file changed
+23
-6
@@ -190,9 +190,15 @@ jobs:
|
|||||||
|
|
||||||
- name: Get PR diff
|
- name: Get PR diff
|
||||||
run: |
|
run: |
|
||||||
git diff --merge-base \
|
# lockfile changes bloat the diff (175KB here) and are pointless to
|
||||||
"origin/${{ github.base_ref }}" > /tmp/pr.diff
|
# review - pnpm audit already covers dependencies. Excluding the
|
||||||
wc -l /tmp/pr.diff
|
# lockfile also keeps the diff small enough to hand to the model.
|
||||||
|
# The diff goes to a file IN the workspace so the agent can read it
|
||||||
|
# with its file tools (passing 190KB as a CLI argument fails with
|
||||||
|
# "Argument list too long", MAX_ARG_STRLEN is 128KiB).
|
||||||
|
git diff --merge-base "origin/${{ github.base_ref }}" \
|
||||||
|
-- . ':(exclude)pnpm-lock.yaml' > .pr-review-diff.patch
|
||||||
|
wc -c .pr-review-diff.patch
|
||||||
|
|
||||||
- name: Run opencode review
|
- name: Run opencode review
|
||||||
env:
|
env:
|
||||||
@@ -201,12 +207,18 @@ jobs:
|
|||||||
# deepseek-v4-pro#max: flagship reasoning model at maximum thinking
|
# deepseek-v4-pro#max: flagship reasoning model at maximum thinking
|
||||||
# budget. Requires funds on the opencode account.
|
# budget. Requires funds on the opencode account.
|
||||||
# Cheaper fallbacks: opencode/deepseek-v4.1-flash, or remove "#max".
|
# Cheaper fallbacks: opencode/deepseek-v4.1-flash, or remove "#max".
|
||||||
|
# Output is redirected (not piped through tee): if opencode fails,
|
||||||
|
# the job must fail here so the error log is never posted as a
|
||||||
|
# "review" comment.
|
||||||
opencode run \
|
opencode run \
|
||||||
--model opencode/deepseek-v4-pro#max \
|
--model opencode/deepseek-v4-pro#max \
|
||||||
"You are a principal engineer performing a rigorous code review on a
|
"You are a principal engineer performing a rigorous code review on a
|
||||||
pull request. You have tool access: read repo files for context when
|
pull request. You have tool access: read repo files for context when
|
||||||
the diff alone is ambiguous, but review ONLY code changed in this PR.
|
the diff alone is ambiguous, but review ONLY code changed in this PR.
|
||||||
|
|
||||||
|
The full PR diff is in the file .pr-review-diff.patch in the repo
|
||||||
|
root. Read it first with your file tools.
|
||||||
|
|
||||||
## Project context
|
## Project context
|
||||||
- Stack: Nuxt 4 (Vue 3, TypeScript) SSR web app in the repo root.
|
- Stack: Nuxt 4 (Vue 3, TypeScript) SSR web app in the repo root.
|
||||||
Backend/API services are being added in Golang.
|
Backend/API services are being added in Golang.
|
||||||
@@ -251,7 +263,7 @@ jobs:
|
|||||||
unoptimized images, blocking Nitro middleware).
|
unoptimized images, blocking Nitro middleware).
|
||||||
|
|
||||||
## Output format (strict)
|
## Output format (strict)
|
||||||
Review the diff at the end of this message. For every finding:
|
Review the diff in .pr-review-diff.patch. For every finding:
|
||||||
[BLOCKER] file:line - what and why + concrete fix suggestion
|
[BLOCKER] file:line - what and why + concrete fix suggestion
|
||||||
[WARN] file:line - what and why + concrete fix suggestion
|
[WARN] file:line - what and why + concrete fix suggestion
|
||||||
[NIT] file:line - optional improvement
|
[NIT] file:line - optional improvement
|
||||||
@@ -266,8 +278,13 @@ jobs:
|
|||||||
End your response with a final verdict line, exactly one of:
|
End your response with a final verdict line, exactly one of:
|
||||||
VERDICT: APPROVE (no BLOCKER findings)
|
VERDICT: APPROVE (no BLOCKER findings)
|
||||||
VERDICT: REQUEST_CHANGES (at least one BLOCKER)" \
|
VERDICT: REQUEST_CHANGES (at least one BLOCKER)" \
|
||||||
"$(cat /tmp/pr.diff)" \
|
> /tmp/review.md 2>&1
|
||||||
2>&1 | tee /tmp/review.md
|
EXIT_CODE=$?
|
||||||
|
cat /tmp/review.md
|
||||||
|
if [ $EXIT_CODE -ne 0 ]; then
|
||||||
|
echo "::error::opencode review failed (exit ${EXIT_CODE}) - NOT posting this output as a review comment"
|
||||||
|
exit $EXIT_CODE
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Post review as PR comment
|
- name: Post review as PR comment
|
||||||
continue-on-error: true # token missing/expired must not fail the build
|
continue-on-error: true # token missing/expired must not fail the build
|
||||||
|
|||||||
Reference in new issue
Block a user