github-actions[bot] commented on code in PR #61334:
URL: https://github.com/apache/doris/pull/61334#discussion_r2935409968
##########
.github/workflows/opencode-review.yml:
##########
@@ -108,8 +108,51 @@ jobs:
BASE_SHA: ${{ steps.pr.outputs.base_sha }}
- name: Run automated code review
+ id: review
+ continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+ set -o pipefail
PROMPT=$(cat /tmp/review_prompt.txt)
- opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6"
+ opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 |
tee /tmp/opencode-review.log
Review Comment:
**Bug**: GitHub Actions default shell is `bash --noprofile --norc -eo
pipefail {0}`, so `set -e` is already active. When `opencode` fails, this
pipeline will trigger an immediate script exit due to `set -e` + `pipefail` —
the subsequent `status=${PIPESTATUS[0]}` and `failure_reason` extraction logic
on lines below will **never execute**.
This means when `opencode` actually fails (the primary scenario this PR aims
to handle), `failure_reason` is never written to `GITHUB_OUTPUT`, and the PR
comment in the next step will show an empty error message.
Also note that `set -o pipefail` on the line above is redundant since it's
already in the default shell flags.
**Suggested fix**: Disable `set -e` around the pipeline so `PIPESTATUS` can
be captured:
```bash
set +e
opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 | tee
/tmp/opencode-review.log
status=${PIPESTATUS[0]}
set -e
```
Or alternatively, append `|| true` to prevent the pipeline from triggering
`set -e`:
```bash
opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 | tee
/tmp/opencode-review.log || true
status=${PIPESTATUS[0]}
```
Note: with `|| true`, `PIPESTATUS[0]` will be `0` (from `true`), so you'd
need to capture it differently — the `set +e`/`set -e` approach is cleaner.
##########
.github/workflows/opencode-review.yml:
##########
@@ -108,8 +108,51 @@ jobs:
BASE_SHA: ${{ steps.pr.outputs.base_sha }}
- name: Run automated code review
+ id: review
+ continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+ set -o pipefail
PROMPT=$(cat /tmp/review_prompt.txt)
- opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6"
+ opencode run "$PROMPT" -m "github-copilot/claude-opus-4.6" 2>&1 |
tee /tmp/opencode-review.log
+ status=${PIPESTATUS[0]}
+
+ failure_reason=$(rg -m1 -i '^Error:|SSE read timed out'
/tmp/opencode-review.log || true)
+ if [ "$status" -ne 0 ] && [ -z "$failure_reason" ]; then
+ failure_reason="OpenCode exited with status $status"
+ fi
+
+ if [ -n "$failure_reason" ]; then
+ {
+ echo "failure_reason<<EOF"
+ printf '%s\n' "$failure_reason"
+ echo "EOF"
+ } >> "$GITHUB_OUTPUT"
+ exit 1
+ fi
+
+ - name: Comment PR on review failure
+ if: ${{ steps.review.outcome == 'failure' }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ FAILURE_REASON: ${{ steps.review.outputs.failure_reason }}
+ RUN_URL: ${{ github.server_url }}/${{ github.repository
}}/actions/runs/${{ github.run_id }}
+ run: |
+ gh pr comment "${{ github.event.issue.number }}" --body "$(cat <<EOF
+ OpenCode automated review failed and did not complete.
+
+ Error: ${FAILURE_REASON}
+ Workflow run: ${RUN_URL}
+
Review Comment:
**Minor (Cosmetic)**: This heredoc uses `<<EOF` (not `<<-EOF`), so the
leading whitespace on lines 143-148 will be included verbatim in the PR comment
body. This will make the comment appear oddly indented with leading spaces.
Consider either:
1. Using `<<-EOF` with tab indentation (heredoc strips leading tabs), or
2. Removing the leading spaces from the heredoc content:
```yaml
run: |
gh pr comment "${{ github.event.issue.number }}" --body "$(cat
<<EOF
OpenCode automated review failed and did not complete.
Error: ${FAILURE_REASON}
Workflow run: ${RUN_URL}
Please inspect the workflow logs and rerun the review after the underlying
issue is resolved.
EOF
)"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]