Skip to content

fix: Claude CI 自己キャンセル防止・enforce_admins 修正・ヘルスチェック追加 - #619

Merged
keito4 merged 1 commit into
mainfrom
fix/616-617-618-ci-fixes
Mar 22, 2026
Merged

fix: Claude CI 自己キャンセル防止・enforce_admins 修正・ヘルスチェック追加#619
keito4 merged 1 commit into
mainfrom
fix/616-617-618-ci-fixes

Conversation

@keito4

@keito4 keito4 commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #616, Closes #617, Closes #618

3件の CI 関連 Issue をまとめて修正。

変更内容

#617: claude.yml の concurrency 自己キャンセル問題

  • claude[bot] を actor フィルターに追加
  • claude[bot] の応答コメントがワークフローをトリガーし、実行中のジョブを自己キャンセルしていた問題を修正

#616: enforce_admins デフォルトを false に変更

  • setup-team-protection の main ブランチ保護で enforce_admins=false をデフォルトに
  • 管理者が自身の PR をマージできなくなる問題を解消
  • 影響ファイル: .claude/commands/setup-team-protection.md, script/setup-team-protection.sh

#618: Claude Code OAuth ヘルスチェックワークフロー追加

  • templates/workflows/claude-health-check.yml を新規追加
  • 毎週月曜にトークン有効性を確認、失敗時に Issue を自動作成
  • 重複 Issue 防止(claude-health ラベルで既存チェック)

Test plan

  • 全テスト通過 (95 tests)
  • Prettier フォーマット通過
  • claude.yml: claude[bot] コメントでワークフローがトリガーされないこと

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated health check workflow that runs weekly to validate service connectivity and create notifications if issues are detected.
  • Changes

    • Branch protection admin enforcement now defaults to disabled for default branches.
    • Updated workflow execution to exclude bot-triggered events, reducing unnecessary job runs.

Closes #616, Closes #617, Closes #618

#617: claude.yml の concurrency 自己キャンセル問題
- claude[bot] を actor フィルターに追加し、応答コメントによる
  ワークフロー自己キャンセルを防止

#616: enforce_admins デフォルトを false に変更
- setup-team-protection の main ブランチ保護で enforce_admins=false に
- 管理者が自身の PR をマージできない問題を解消

#618: Claude Code OAuth ヘルスチェックワークフローテンプレート追加
- 毎週月曜にトークン有効性を確認
- 失敗時に Issue を自動作成(重複防止付き)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 22, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR implements three fixes addressing token validation, admin enforcement defaults, and workflow actor filtering: updates enforce_admins default from true to false in branch protection configuration and documentation; excludes claude[bot] from triggering the Claude workflow job; and introduces a new weekly health-check workflow to validate Claude Code OAuth token validity and auto-create issues upon failure.

Changes

Cohort / File(s) Summary
Branch Protection Configuration
.claude/commands/setup-team-protection.md, script/setup-team-protection.sh
Updated enforce_admins default from true to false for main/master branches and aligned documentation and logging messages to reflect this change.
Claude Workflow Actor Filter
.github/workflows/claude.yml
Added claude[bot] to the job conditional's actor exclusion list alongside existing github-actions[bot] and dependabot[bot] to prevent workflow re-triggering on bot responses.
Claude Code Health Check Workflow
templates/workflows/claude-health-check.yml
New GitHub Actions workflow that runs weekly and on manual dispatch to validate Claude Code OAuth token by attempting a direct prompt; creates an issue with Japanese labels and remediation steps if token validation fails and no existing issue exists.

Sequence Diagram(s)

sequenceDiagram
    participant GA as GitHub Actions<br/>(Scheduled/Manual)
    participant CCA as Claude Code Action
    participant OAuth as Claude OAuth API
    participant GH as GitHub API
    
    GA->>CCA: Trigger health-check with OAUTH_TOKEN
    CCA->>OAuth: Validate token (direct_prompt: "OK")
    alt Token Valid
        OAuth-->>CCA: Success (Reply: "OK")
        CCA-->>GA: Step succeeds
        GA->>GA: Skip issue creation
    else Token Invalid/Expired
        OAuth-->>CCA: Error
        CCA-->>GA: Step fails (continue-on-error)
        GA->>GH: Check for existing open issues<br/>(label: claude-health)
        alt Issue Exists
            GH-->>GA: Found open issue
            GA->>GA: Exit (no duplicate)
        else No Issue Exists
            GH-->>GA: No open issue
            GA->>GH: Create new issue<br/>(Japanese title & labels)
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • keito4/config#583: Modifies the enforce_admins default in script/setup-team-protection.sh for the main branch, directly overlapping with this PR's branch protection changes.
  • keito4/config#16: Modifies .github/workflows/claude.yml to add the base Claude Code workflow, which this PR extends by adding actor-based exclusion logic.
  • keito4/config#566: Updates branch-protection files (script/setup-team-protection.sh and .claude/commands/setup-team-protection.md) with enforce_admins and default behavior changes, sharing identical files and logic.

Suggested labels

released, size/S

Poem

🐰 Admin guards were far too stern,
Now admins may merge in turn!
Bots won't loop with self-replies,
Health checks watch with watchful eyes,
Tokens fail? An issue cries—
All in order, wise and spry!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title combines three distinct changes (self-cancel prevention, enforce_admins fix, health check addition) in a concise format that accurately reflects the main objectives of the changeset.
Linked Issues check ✅ Passed Code changes implement all primary objectives from #616, #617, and #618: enforce_admins changed to false, claude[bot] added to actor filters with workflow exclusion, and health-check workflow added.
Out of Scope Changes check ✅ Passed All file changes directly address the three linked issues with no extraneous modifications beyond the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/616-617-618-ci-fixes

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4 keito4 self-assigned this Mar 22, 2026
@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

コードレビュー

全体的に的確な修正です。各変更について詳細をコメントします。


.github/workflows/claude.yml — self-cancel 防止

github.actor != 'claude[bot]' &&

シンプルで正確な修正。claude[bot] が自分のコメントでワークフローをトリガーする問題を最小限の変更で解消しています。問題なし。


enforce_admins: false への変更

setup-team-protection.sh とドキュメント(.claude/commands/setup-team-protection.md)が整合して更新されており、コメントも正確に反映されています。小規模チームのデフォルトとして適切な判断です。


⚠️ templates/workflows/claude-health-check.yml — 要確認点

1. ラベルが存在しない場合のエラーハンドリング

gh issue create \
  --label "claude-health,bug" \

このワークフローはテンプレートとして配布されますが、claude-health ラベルが存在しないリポジトリでは gh issue create が失敗します(gh CLI はラベルが存在しない場合エラーになります)。

対策案:

# ラベルを事前に作成(既存の場合は無視)
gh label create "claude-health" --color "0075ca" --description "Claude Code health check" 2>/dev/null || true

gh issue create \
  --label "claude-health" \
  --label "bug" \
  ...

2. continue-on-error: true の意図

現在の構成では、アクション自体が失敗しても次ステップに進みますが、「トークンが有効で OK と返答した場合」と「アクション自体が内部エラーで失敗した場合」を区別できません。後者でも Issue が作成されてしまいます。

誤検知のリスクが許容範囲であればこのままで構いませんが、認識しておくことを推奨します。

3. 軽微: --label の複数指定形式

"claude-health,bug" の代わりに --label "claude-health" --label "bug" と分けるほうが gh CLI の慣用的な書き方で可読性が上がります(動作上は同じです)。


総評

CI の自己キャンセル問題と enforce_admins の修正は即マージ可能なレベルです。ヘルスチェックワークフローはラベル不存在時のエラー処理を追加すると、テンプレートとしての堅牢性が上がります。

🤖 Generated with Claude Code

@keito4
keito4 merged commit f7268f7 into main Mar 22, 2026
17 of 18 checks passed
@keito4
keito4 deleted the fix/616-617-618-ci-fixes branch March 22, 2026 15:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5b09248e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Default branch: admin enforcement, no mandatory reviews
enforce_admins=true
# Default branch: no admin enforcement, no mandatory reviews
enforce_admins=false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Respect --enforce-admins for default branch

The main|master branch defaults now unconditionally set enforce_admins=false, which overrides an explicit --enforce-admins invocation (ENFORCE_ADMINS=true). In the default non---uniform path, an operator can request admin enforcement and still end up with admins exempt from protection on the default branch, which weakens branch protection contrary to the CLI option contract.

Useful? React with 👍 / 👎.


gh issue create \
--title "fix: Claude Code OAuth トークンが無効です" \
--label "claude-health,bug" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove undeclared label from health-check issue creation

The failure handler always passes --label "claude-health,bug", but this repository’s label definitions (.github/labels.yml and templates/github/labels.yml) do not include claude-health. GitHub’s labeling guidance requires labels to exist before being added via gh, so in repos generated from these templates the alert-creation step can fail exactly when the health check detects an invalid token, preventing the intended notification.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.105.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

1 participant