ci: refactor Claude review to reusable org-wide workflow#43
Conversation
65704c4 to
a565e72
Compare
This comment has been minimized.
This comment has been minimized.
a565e72 to
46f8405
Compare
This comment has been minimized.
This comment has been minimized.
46f8405 to
999d988
Compare
This comment has been minimized.
This comment has been minimized.
|
@copilot please review this pull request. |
|
@danielewood I've opened a new pull request, #44, to work on those changes. Once the pull request is ready, I'll request review from you. |
2ad90b3 to
974ffe8
Compare
This comment has been minimized.
This comment has been minimized.
974ffe8 to
1d031d8
Compare
This comment has been minimized.
This comment has been minimized.
1d031d8 to
3148fc6
Compare
This comment has been minimized.
This comment has been minimized.
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
3148fc6 to
9065a6a
Compare
There was a problem hiding this comment.
Pull request overview
Updates CI automation to avoid failing Claude’s OAuth validation when the Claude review workflow itself is part of the PR diff, and adds a new CodeQL workflow.
Changes:
- Add a pre-check in
claude-code-review.ymlto detect edits to the workflow and skip the Claude review run. - Post a PR comment explaining the skip when the workflow is modified.
- Add a new
codeql.ymlworkflow to run CodeQL analysis for Go on pushes/PRs and a weekly schedule.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| .github/workflows/claude-code-review.yml | Adds early “workflow modified” detection, skip notice/comment, and gates the Claude action run. |
| .github/workflows/codeql.yml | Introduces a CodeQL GitHub Actions workflow for Go analysis. |
| - name: Minimize previous review comments | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | |
There was a problem hiding this comment.
The PR description says the workflow should "skip all review steps" to save runner time when claude-code-review.yml is modified, but the "Minimize previous review comments" step still runs even when skip=true. Gate this step with the same if: steps.check.outputs.skip != 'true' (or move it after the skip check) to avoid extra API calls/time on skipped runs.
| gh -R ${{ github.repository }} pr view ${{ github.event.pull_request.number }} \ | ||
| --json comments \ | ||
| --jq '.comments[] | select(.author.login == "claude") | .id' \ | ||
| --jq '.comments[] | select(.author.login == "claude" or .author.login == "github-actions") | .id' \ |
There was a problem hiding this comment.
This minimization query targets any PR comments authored by github-actions. That can unintentionally minimize comments posted by other workflows/bots (release notes, CI summaries, etc.) since they often also appear as github-actions. Narrow the filter to only comments created by this workflow (e.g., match a unique body prefix/header like ## Code review), or store the node_id of the comment you posted and only minimize those.
| --jq '.comments[] | select(.author.login == "claude" or .author.login == "github-actions") | .id' \ | |
| --jq '.comments[] | select(.author.login == "claude" or (.author.login == "github-actions" and (.body | startswith("## Code review")))) | .id' \ |
.github/workflows/codeql.yml
Outdated
| name: CodeQL | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| schedule: | ||
| - cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC |
There was a problem hiding this comment.
This PR introduces a new codeql.yml workflow, but the PR title/description only discuss skipping Claude review when its workflow is modified. Either update the PR description to include the CodeQL addition (and rationale) or split this into a separate PR to keep changes scoped and reviewable.
| --body "## Code review | ||
|
|
||
| Skipped — this PR modifies \`claude-code-review.yml\`. The OAuth token exchange requires the workflow file to match the default branch, so the review cannot run until this change is merged." | ||
|
|
There was a problem hiding this comment.
The --body string includes leading spaces before Skipped — ... (because of YAML indentation), which will render as a Markdown code block in the PR comment. Consider removing the leading indentation (or use a heredoc/cat <<'EOF' style) so the message renders as normal text.
| --body "## Code review | |
| Skipped — this PR modifies \`claude-code-review.yml\`. The OAuth token exchange requires the workflow file to match the default branch, so the review cannot run until this change is merged." | |
| --body $'## Code review\n\nSkipped — this PR modifies `claude-code-review.yml`. The OAuth token exchange requires the workflow file to match the default branch, so the review cannot run until this change is merged.' |
This comment has been minimized.
This comment has been minimized.
9065a6a to
bac26fd
Compare
| uses: sensiblebit/.github/.github/workflows/claude-code-review.yml@main | ||
| secrets: | ||
| CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
There was a problem hiding this comment.
The PR description states "Add an early check that detects when claude-code-review.yml is in the PR diff" and "Skip all review steps gracefully (exit green with a notice)". However, the actual implementation replaces the entire inline workflow with a call to a reusable workflow in a separate repository (sensiblebit/.github).
This is not adding an early check to the current workflow - it's delegating the entire workflow to an external repository. If the skip logic exists, it would be in the reusable workflow at sensiblebit/.github/.github/workflows/claude-code-review.yml, not in this file. The PR description should accurately describe this as "refactor to use shared reusable workflow" rather than implying that skip logic is being added to this file.
| Do NOT skip the review for any reason — never treat a PR as "trivial" or | ||
| "obviously correct." Always run the full review pipeline and post a comment | ||
| with the results. If no issues are found, post the "No issues found" summary. | ||
| uses: sensiblebit/.github/.github/workflows/claude-code-review.yml@main |
There was a problem hiding this comment.
The original workflow defined explicit permissions (contents: read, pull-requests: write, issues: read, id-token: write). When calling a reusable workflow, these permissions need to be explicitly passed using the permissions: key at the job level, or the reusable workflow must define them itself using permissions: at the workflow level.
Without explicit permissions, the reusable workflow will either fail or use default permissions which may be too broad. You should either:
- Add a
permissions:block to this job that matches the original permissions, OR - Verify that the reusable workflow at
sensiblebit/.githubhas appropriate workflow-level permissions defined
According to GitHub documentation, when calling a reusable workflow, the caller must explicitly grant permissions if the reusable workflow needs them.
| uses: sensiblebit/.github/.github/workflows/claude-code-review.yml@main | |
| uses: sensiblebit/.github/.github/workflows/claude-code-review.yml@main | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: read | |
| id-token: write |
| uses: sensiblebit/.github/.github/workflows/claude-code-review.yml@main | ||
| secrets: | ||
| CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
There was a problem hiding this comment.
According to rule CL-1 in CLAUDE.md, every commit changing behavior must update CHANGELOG.md under the Unreleased section. This PR changes CI behavior by replacing an inline workflow with a reusable workflow call (and according to the description, adds skip logic for self-modifications). However, there's no corresponding entry in CHANGELOG.md.
An entry should be added to the "Changed" section describing this CI workflow modification, something like: "Replace inline Claude Code Review workflow with reusable workflow from sensiblebit/.github"
The OAuth token exchange validates that the workflow file matches main exactly, so PRs that modify claude-code-review.yml always fail. Add an early check that detects this and skips the review gracefully instead of burning runner time on an inevitable 401. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bac26fd to
a698943
Compare
Code reviewSkipped — this PR modifies the review workflow. The OAuth token exchange requires the workflow file to match the default branch, so the review cannot run until this change is merged. |
Summary
sensiblebit/.githubCLAUDE_CODE_OAUTH_TOKENsecretTest plan
startup_failure)🤖 Generated with Claude Code