Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
description: >
How the review output should be posted:
- check: post as a check run (requires checks: write permission)
- check_neutral: like check, but uses GitHub's non-blocking `neutral`
conclusion when issues are found, so the check does not shadow
real CI checks in the PR status rollup
- comment: post as a PR comment
- auto: check if allowed, otherwise post as a comment
default: auto
Expand Down Expand Up @@ -171,3 +174,30 @@ jobs:
ANTHROPIC_VERTEX_PROJECT_ID: ${{ secrets.ANTHROPIC_VERTEX_PROJECT_ID }}
CLOUD_ML_REGION: ${{ secrets.CLOUD_ML_REGION }}
PUBLISH_MODE: ${{ inputs.summary-mode }}

# Finalize the "Claude Code Review" check when the review job did not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI (and probably not the point of this PR) : ideally, I would have called the script from here, instead of letting claude do it. This however required finding how to generate an "outcome" from Claude, and process it in next step, which I did not have to investigate....

(start of review could be posted here instead of in the skill)

# complete normally (action failure, runner timeout, cancellation).
# Without this the check sits at status=in_progress forever and blocks
# any branch protection that waits on it. PATCHes via gh api directly
# so the step has no coupling to the skill's helper script and is a
# natural no-op when no in-progress check exists (e.g. legacy skill).
- name: Finalize stuck Claude Code Review check
if: always() && steps.claude-review.outcome != 'success'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be called when using legacy skill (from the repo) which does not rely on the script...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added steps.claude-review.outcome != 'success' so it only applies when required

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we not simplify this:

  • remove continue-on-error for "Run Claude Code Review" : see clearly if it fails
  • run finalization if faileld() || cancelled(), as usual?

This would catch all kind of failures (even checkout...) and be more idiomatic?

env:
OWNER_REPO: ${{ github.repository }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using GitHub api is self-contained indeed ; but

  • it duplicates the logic in the script
  • it will create a check even if comment mode is used: in which case it should actually update the comment...
  • it will only UPDATE a check, and not create it (in case claude failed before posting the check)

→ I think it is better to try to use the script if it is present (in checkout) and there is no "local" review-pr skill (.claude/skills/review-pr)... (as you did in first review, I think :/ )
→ maybe a better way would be to change the skill so it does not call the script, but just generates the information (via env variables, output, or generating a file); then move the script here and call it systematically... This would avoid duplication and reduce dependency (still a bit though, as the "protocol" to communicate with Claude would still not be supported by local skill...). Probably a much larger endeavor though, and still some coupling: so not sure it's worth it: best keep it simple IMHO

check_id=$(gh api "repos/${OWNER_REPO}/commits/${HEAD_SHA}/check-runs" \
-f check_name="Claude Code Review" \
--jq '.check_runs[] | select(.status != "completed") | .id' | head -1)
if [[ -z "${check_id}" ]]; then
echo "No in-progress 'Claude Code Review' check on this SHA — nothing to finalize"
exit 0
fi
summary="Claude review job did not complete (action failure, timeout, or cancellation). See [workflow logs](${RUN_URL})."
jq -n --arg summary "${summary}" '{
status: "completed",
conclusion: "cancelled",
output: { title: "Claude Code Review: cancelled", summary: $summary }
}' | gh api "repos/${OWNER_REPO}/check-runs/${check_id}" --method PATCH --input -
Loading