feat: update Claude workflow to run after CI completion - #269
Conversation
|
Warning Rate limit exceeded@keito4 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 24 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 Walkthrough📝 WalkthroughPre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| steps: | ||
| - name: Get PR number | ||
| id: pr | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:2:53: Double quote to prevent globbing and word splitting [shellcheck]
| steps: | ||
| - name: Get PR number | ||
| id: pr | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:4:60: Double quote to prevent globbing and word splitting [shellcheck]
| steps: | ||
| - name: Get PR number | ||
| id: pr | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:6:60: Double quote to prevent globbing and word splitting [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
shellcheck reported issue in this script: SC2034:warning:11:1: CHECKS appears unused. Verify use (or export if used externally) [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:11:37: Double quote to prevent globbing and word splitting [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:14:40: Double quote to prevent globbing and word splitting [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:20:28: Double quote to prevent globbing and word splitting [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:23:29: Double quote to prevent globbing and word splitting [shellcheck]
Pull Request ReviewこのPRを詳細にレビューしました。全体的に良い実装ですが、いくつかの改善点とセキュリティ上の懸念があります。 ✅ 良い点
|
1bc113a to
de552d6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
script/update-claude-workflow-multi-repo.sh (3)
96-98: Consider handling existing remote branches.If a previous run created the branch but failed before completing, subsequent runs will fail when pushing. Consider checking for existing remote branches or using force push with lease.
🔎 Proposed enhancement
# 新しいブランチを作成 log_info "Creating branch: $BRANCH_NAME" + # Check if branch exists remotely and delete if so + if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then + log_warning "Branch $BRANCH_NAME already exists on remote, deleting..." + git push origin --delete "$BRANCH_NAME" 2>/dev/null || true + fi git checkout -b "$BRANCH_NAME"
153-209: Handle existing PRs gracefully.If a PR already exists for the branch (from a previous partial run),
gh pr createwill fail. Consider checking for existing PRs or usinggh pr createwith error handling.🔎 Proposed enhancement
# PR作成 log_info "Creating pull request..." + # Check if PR already exists + EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url' 2>/dev/null || echo "") + if [ -n "$EXISTING_PR" ]; then + log_warning "PR already exists: $EXISTING_PR" + PR_URL="$EXISTING_PR" + else PR_URL=$(gh pr create \ --title "feat: update Claude workflow to run after CI completion" \ --body "$(cat <<'EOF' ... EOF )" \ --base "$default_branch" 2>&1) + fi log_success "PR created: $PR_URL"
214-218: Consider tracking success/skip/failure counts.The summary only shows total repositories. Tracking and displaying how many succeeded, were skipped (no claude.yml or no changes), or failed would improve visibility.
🔎 Proposed enhancement
Add counters at the start of the script:
SUCCESS_COUNT=0 SKIP_COUNT=0 FAIL_COUNT=0Increment appropriately throughout the loop, then update the summary:
log_success "All repositories processed!" echo "" echo "Summary:" echo "- Total repositories: ${#REPOS[@]}" +echo "- Successful: $SUCCESS_COUNT" +echo "- Skipped: $SKIP_COUNT" +echo "- Failed: $FAIL_COUNT" echo "- Work directory: $WORK_DIR (will be cleaned up)".github/workflows/claude.yml (1)
58-59: Unused variableCHECKS.The
CHECKSvariable is set but never used in the subsequent logic. Either remove it or use it for more granular check status verification.🔎 Proposed fix - remove unused variable
- # Check runsを取得 - CHECKS=$(gh api repos/$REPO/commits/$HEAD_SHA/check-runs --jq '.check_runs[] | select(.name == "CI" or .name == "build" or .name == "test" or .name == "lint")') - # CIワークフローのステータスを取得 CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/claude.ymlscript/update-claude-workflow-multi-repo.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/workflows/claude.yml
📄 CodeRabbit inference engine (CLAUDE.md)
Trigger automatic AI assistance on @claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Files:
.github/workflows/claude.yml
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
Applied to files:
script/update-claude-workflow-multi-repo.sh.github/workflows/claude.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Applied to files:
script/update-claude-workflow-multi-repo.sh.github/workflows/claude.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/ci.yml : Validate code quality in CI pipeline (.github/workflows/ci.yml) with linting, formatting, testing, and building
Applied to files:
.github/workflows/claude.yml
📚 Learning: 2025-12-09T08:39:14.049Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance
Applied to files:
.github/workflows/claude.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
🔇 Additional comments (6)
script/update-claude-workflow-multi-repo.sh (3)
1-10: Good use of strict mode and variable setup.The script uses
set -euo pipefailwhich is excellent for catching errors early. The use of$$inWORK_DIRensures unique temporary directories for concurrent executions.
60-65: Good cleanup handling with trap.The cleanup trap ensures the temporary work directory is removed even if the script fails, which prevents disk space leaks.
149-151: Push may fail silently on branch protection.If target repositories have branch protection rules preventing direct pushes to feature branches, this will fail. The
set -ewill cause the script to stop. Consider adding explicit error handling with a helpful message..github/workflows/claude.yml (3)
13-15: Improved concurrency grouping.The updated concurrency key now includes repository and issue/PR number, which provides better isolation between different PRs/Issues in the same repository.
76-85: Correct conditional logic for job execution.The conditions properly handle all scenarios:
- Issues trigger Claude directly (skipped CI check)
- PR comments require successful CI
- The
always()combined with explicit result checks ensures correct flow control.
88-110: Permissions correctly configured at both levels.The
checks: readpermission is appropriately added both at the job level (for the job to access checks) and inadditional_permissions(for the Claude action to inherit). This follows the principle of least privilege.
| # CIワークフローのステータスを取得 | ||
| CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') | ||
|
|
||
| echo "CI Status: $CI_STATUS" | ||
|
|
||
| # CIが成功している、またはチェックが存在しない場合は許可 | ||
| if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then | ||
| echo "ci_passed=true" >> $GITHUB_OUTPUT | ||
| echo "✅ CI checks passed or not required" | ||
| else | ||
| echo "ci_passed=false" >> $GITHUB_OUTPUT | ||
| echo "❌ CI checks have not passed yet. Current status: $CI_STATUS" | ||
| echo "Please wait for CI to complete before running Claude Code." | ||
| fi |
There was a problem hiding this comment.
API failure could incorrectly allow execution.
If the gh api call to get CI status fails (network issue, rate limit, etc.), CI_STATUS may be empty, causing ci_passed=true. Consider validating the API response.
🔎 Proposed fix with error handling
# CIワークフローのステータスを取得
- CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
+ CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') || {
+ echo "ci_passed=false" >> $GITHUB_OUTPUT
+ echo "❌ Failed to fetch CI status"
+ exit 0
+ }
echo "CI Status: $CI_STATUS"
# CIが成功している、またはチェックが存在しない場合は許可
- if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
+ if [ "$CI_STATUS" = "success" ] || [ -z "$CI_STATUS" ]; then
echo "ci_passed=true" >> $GITHUB_OUTPUT
echo "✅ CI checks passed or not required"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # CIワークフローのステータスを取得 | |
| CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') | |
| echo "CI Status: $CI_STATUS" | |
| # CIが成功している、またはチェックが存在しない場合は許可 | |
| if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then | |
| echo "ci_passed=true" >> $GITHUB_OUTPUT | |
| echo "✅ CI checks passed or not required" | |
| else | |
| echo "ci_passed=false" >> $GITHUB_OUTPUT | |
| echo "❌ CI checks have not passed yet. Current status: $CI_STATUS" | |
| echo "Please wait for CI to complete before running Claude Code." | |
| fi | |
| # CIワークフローのステータスを取得 | |
| CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') || { | |
| echo "ci_passed=false" >> $GITHUB_OUTPUT | |
| echo "❌ Failed to fetch CI status" | |
| exit 0 | |
| } | |
| echo "CI Status: $CI_STATUS" | |
| # CIが成功している、またはチェックが存在しない場合は許可 | |
| if [ "$CI_STATUS" = "success" ] || [ -z "$CI_STATUS" ]; then | |
| echo "ci_passed=true" >> $GITHUB_OUTPUT | |
| echo "✅ CI checks passed or not required" | |
| else | |
| echo "ci_passed=false" >> $GITHUB_OUTPUT | |
| echo "❌ CI checks have not passed yet. Current status: $CI_STATUS" | |
| echo "Please wait for CI to complete before running Claude Code." | |
| fi |
🤖 Prompt for AI Agents
.github/workflows/claude.yml around lines 61 to 74: the script treats an empty
CI_STATUS as success which lets execution proceed when the gh api call actually
failed; change the logic to detect API failure by checking the gh api command
exit code (or HTTP response) before trusting CI_STATUS, and only set
ci_passed=true when the API succeeded and returned "success" or an explicit "no
status" indicator; on gh api failure, set ci_passed=false and log the error/exit
code and response so execution is blocked and the failure is visible.
de552d6 to
89d4f0b
Compare
|
(aside) |
|
Claude finished @keito4's task in 2m 44s —— View job CI修正完了(手動適用が必要)実施内容CI失敗の原因であるshellcheck警告をすべて修正しました。ただし、GitHub Appの権限制限により 修正内容1. script/update-claude-workflow-multi-repo.sh
2. .github/workflows/claude.yml
📋 完全なdiffdiff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml
index c20d7c7..85a846f 100644
--- a/.github/workflows/claude.yml
+++ b/.github/workflows/claude.yml
@@ -34,11 +34,11 @@ jobs:
id: pr
run: |
if [ "${{ github.event_name }}" = "issue_comment" ]; then
- echo "number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
+ echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
- echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
+ echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "pull_request_review" ]; then
- echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
+ echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
fi
- name: Check CI status
@@ -50,25 +50,22 @@ jobs:
REPO="${{ github.repository }}"
# PRのHEAD SHAを取得
- PR_DATA=$(gh api repos/$REPO/pulls/$PR_NUMBER)
+ PR_DATA=$(gh api "repos/$REPO/pulls/$PR_NUMBER")
HEAD_SHA=$(echo "$PR_DATA" | jq -r '.head.sha')
echo "Checking CI status for PR #$PR_NUMBER (SHA: $HEAD_SHA)"
- # Check runsを取得
- CHECKS=$(gh api repos/$REPO/commits/$HEAD_SHA/check-runs --jq '.check_runs[] | select(.name == "CI" or .name == "build" or .name == "test" or .name == "lint")')
-
# CIワークフローのステータスを取得
- CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
+ CI_STATUS=$(gh api "repos/$REPO/commits/$HEAD_SHA/status" --jq '.state')
echo "CI Status: $CI_STATUS"
# CIが成功している、またはチェックが存在しない場合は許可
if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
- echo "ci_passed=true" >> $GITHUB_OUTPUT
+ echo "ci_passed=true" >> "$GITHUB_OUTPUT"
echo "✅ CI checks passed or not required"
else
- echo "ci_passed=false" >> $GITHUB_OUTPUT
+ echo "ci_passed=false" >> "$GITHUB_OUTPUT"
echo "❌ CI checks have not passed yet. Current status: $CI_STATUS"
echo "Please wait for CI to complete before running Claude Code."
fi
diff --git a/script/update-claude-workflow-multi-repo.sh b/script/update-claude-workflow-multi-repo.sh
index 2bf0e6e..768fe8a 100755
--- a/script/update-claude-workflow-multi-repo.sh
+++ b/script/update-claude-workflow-multi-repo.sh
@@ -81,7 +81,7 @@ for repo in "${REPOS[@]}"; do
continue
fi
- cd "$repo_dir"
+ cd "$repo_dir" || exit
# デフォルトブランチを取得
default_branch=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')適用方法以下のいずれかの方法で修正を適用してください: 方法1: ローカルで手動編集
方法2: パッチファイルを使用ローカルリポジトリで以下を実行: # ブランチをチェックアウト
git checkout feat/update-claude-workflow-ci-dependency
# 上記のdiffをpatch.diffとして保存し、適用
git apply patch.diff
git add -A
git commit -m "fix: resolve shellcheck warnings"
git push origin feat/update-claude-workflow-ci-dependency期待される結果修正適用後、shellcheckの警告がすべて解消され、CI(Lint & Format ジョブ)が通過します。 | Branch |
Claude Code reviewを他のCIが全て通った後にのみ実行するように 変更しました。 ## 変更内容 ### 新規追加 - `check-ci-status` ジョブ: PRの場合、CIステータスを チェック - PRのHEAD SHAを取得 - GitHub Status APIでCIステータスを確認 - CIが成功している場合のみ次のジョブを実行 ### 更新 - `claude` ジョブ: - `check-ci-status` ジョブに依存 - Issueへのコメント(PRではない)の場合は直接実行 - PRへのコメントの場合はCIが完了している場合のみ実行 ### concurrency設定 - より詳細なグループ化によりPR/Issue単位で並行実行を 制御 ## 動作 1. **Issueへの@claudeコメント**: CIチェック不要、即座に実行 2. **PRへの@claudeコメント**: CIステータスをチェックし、成功している場合のみ実行 3. **CI未完了の場合**: Claude実行をスキップし、待機メッセージを表示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
89d4f0b to
4e36bae
Compare
Claude Code によるPRレビューこのPRは、Claude Code ワークフローを他のCIが完了した後にのみ実行するように改善するものです。全体的に良い設計ですが、いくつか改善点と懸念事項があります。 ✅ 良い点
|
claude-code-review.yml が他のCIが全て通った後にのみ 実行されるように変更しました。 ## 変更内容 ### 新規追加 - `check-ci-status` ジョブ: CIステータスをチェック - PRのHEAD SHAを取得 - GitHub Status APIでCIステータスを確認 - CIが成功している場合のみ次のジョブを実行 ### 更新 - `claude-review` ジョブ: - `check-ci-status` ジョブに依存 - CIが成功した場合のみ実行 ## 動作 1. **PRが作成/更新されたとき**: check-ci-statusジョブが実行される 2. **CIが成功している場合**: claude-reviewジョブが実行される 3. **CIが未完了/失敗の場合**: claude-reviewジョブはスキップされる 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:14:28: Double quote to prevent globbing and word splitting [shellcheck]
| id: check | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:17:29: Double quote to prevent globbing and word splitting [shellcheck]
Summary
Claude Code reviewを他のCIが全て通った後にのみ実行するように変更しました。
変更内容
新規追加
check-ci-statusジョブ: PRの場合、CIステータスをチェックscript/update-claude-workflow-multi-repo.sh: 全リポジトリにclaude.ymlの変更を適用するスクリプト更新
claudeジョブ:check-ci-statusジョブに依存concurrency設定:
動作
Test plan
次のステップ
このPRがマージされた後、
script/update-claude-workflow-multi-repo.shを実行して以下のリポジトリに同じ変更を適用します:
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.