Skip to content

fix(check-ci-coderabbit): PR の CI 状態を statusCheckRollup から取得する - #343

Merged
aloekun merged 1 commit into
masterfrom
fix/monitor-ci-rollup
Aug 2, 2026
Merged

fix(check-ci-coderabbit): PR の CI 状態を statusCheckRollup から取得する#343
aloekun merged 1 commit into
masterfrom
fix/monitor-ci-rollup

Conversation

@aloekun

@aloekun aloekun commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • fetch_cigh run list --branch から gh pr view <pr> --repo <repo> --json statusCheckRollup へ変更し、ブランチ名解決を経路から除去
  • git branch --show-current に依存していた get_current_branch を削除
  • rollup の union ノード (CheckRun / StatusContext) を正規化する parse_ci_rollup を追加。大文字の GraphQL 語彙を小文字化し、実行中 (conclusion: null) は status へフォールバック
  • CodeRabbit 自身の commit status は ci.overall から除外。CR は decide() の専用 gate (rate-limit / evidence backstop) で扱う契約を壊さないため
  • 空 rollup / パース失敗は success ではなく pending (ADR-064 の陽性証拠原則)

Context

Why: 本リポジトリは jj colocated で git HEAD が detached のため git branch --show-current が常に空を返し、fetch_ci("") が早期 return して CI が恒久的に pending / runs: [] になっていた。

なぜ今まで表面化しなかったか: PR に status check を出す workflow が存在せず (release-binaries.yml は master push 限定、pr-monitor.yml は意図的に pull_request を使わない)、「CI 未設定」と「CI を観測できない」が同じ出力だった。ADR-065 の CI matrix (PR #342) が PR 単位の check を初めて生み、実際には failure だった Windows leg を pending と報告し続けることで露見した。

併せて閉じた 2 つ目の穴: gh run list --branch X --limit 5 はブランチ上の全 SHA の run を返すため、push 後に前 commit の結論を現在の結論として報告しうる (ADR-064 が排除した silent success と同型)。rollup は PR head SHA スコープなのでこの経路が構造的に閉じる。

Scope decision: PR #342 (WP-16) とは別 PR にした。あちらは CI 基盤の新設、本 PR は監視コンポーネントの修正で変更単位が異なる。

Validation

  • 実 PR ci: Windows/Linux の 2 OS matrix を新設し hooks smoke test を追加 (ADR-065) #342 に対する E2E 実測 (修正前後で比較):
    • 修正前: overall: pending, runs: []
    • 修正後: overall: failure, runs: [rust (ubuntu-latest)=success, rust (windows-latest)=failure]
    • review_state: success は専用経路で保持され、CR status が CI 判定に混ざらないことも確認
  • cargo test -p check-ci-coderabbit: 112 pass
  • cargo clippy --all-targets --all-features -- -D warnings: clean
  • pnpm push pre-push review: simplicity=needs_fix → fix 適用 → post_takt_regate で quality_gate 再実行 → 全グループ成功、security=approved
  • fix step が入れた 2 件 (CR status 除外 / --repo 明示) は採用者側で独立に再検証した (上記 E2E + テスト + clippy)

References

Summary by CodeRabbit

  • バグ修正

    • PRに紐づく最新のCIチェック結果を正しく取得・判定できるようになりました。
    • CI結果が取得できない場合や未確定の場合は、適切に「保留」として表示されます。
    • 実際のCI失敗が見落とされ、保留として扱われる問題を修正しました。
    • 不要なチェック結果を除外し、成功・失敗・実行中の状態をより正確に判定します。
  • ドキュメント

    • CI状態の判定ルールと、過去の問題に関する記録を追加しました。

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

CI 取得をブランチ単位の gh run list から PR の statusCheckRollup に変更しました。CheckRunStatusContext を正規化し、状態判定と関連テストを更新しました。

Changes

CI ロールアップ検出

Layer / File(s) Summary
ロールアップモデルと状態判定
src/check-ci-coderabbit/src/models.rs, src/check-ci-coderabbit/src/parsers.rs
GhRollupItem を追加しました。CheckRunStatusContext を共通形式へ正規化し、CodeRabbit の status context を除外します。空、未確定、失敗、スキップ状態の判定を更新し、テストを追加しました。
PR 単位の CI 取得
src/check-ci-coderabbit/src/main.rs
fetch_cigh pr view <PR> --repo <repo> --json statusCheckRollup を使用するように変更しました。ブランチ取得処理と gh run list の利用を削除しました。
CI 観測方針の記録
docs/adr/adr-064-monitor-success-positive-evidence.md
CI 欠測の原因、statusCheckRollup への切り替え、空 rollup を pending とする方針を ADR に追記しました。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant run_check
  participant GitHubCLI
  participant parse_ci_rollup
  run_check->>GitHubCLI: PR の statusCheckRollup を取得
  GitHubCLI-->>parse_ci_rollup: rollup JSON を渡す
  parse_ci_rollup-->>run_check: CI 状態を返す
Loading

Possibly related PRs

🚥 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 タイトルは、PRのCI状態をstatusCheckRollupから取得する主要な変更を具体的かつ簡潔に示しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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/monitor-ci-rollup

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.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Monitor 分析 (GitHub Actions バックストップ)

  • トリガー: issue_comment (created) / 実行 run
  • CI: statusCheckRollup に Actions 系 check は未出現。唯一のエントリは CodeRabbit 自身の commit status (state: PENDING)。CI (rust ビルド等) はまだ走っていないか、rollup に反映されていない。
  • レビュー状況: CodeRabbit — レビュー未着 (処理中プレースホルダーのみ、指摘なし)。人間レビュー: なし (reviewDecision 空、reviews: [])。インライン指摘: なし。
  • Verdict: user_decision (CI/CodeRabbit ともに結果未確定のため、承認・修正要否いずれも判定材料が無い)

Applicable Findings (Critical / High / Major)

(該当なし — レビュー未着のため指摘自体が存在しない)

Applicable Findings (Medium 以下)

(該当なし)

Filtered (not applicable)

(該当なし)

次のアクション

  • CodeRabbit のレビュー完了、および Actions CI (rust ビルド/テスト) の check 出現を待って再監視する。
  • 本 PR は ADR-064 の amendment として fetch_cigit branch --show-current (jj colocated で detached HEAD のため常に空) から gh pr view --json statusCheckRollup ベースに置き換えており、CI 判定ロジック自体が変更対象になっている点に留意 (この PR 自身の CI 結果が最初の実地検証になる)。

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/check-ci-coderabbit/src/parsers.rs (1)

53-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

判定ロジックの重複を統合する余地がある。

is_coderabbit_status_context の判定式は、同じファイル内の parse_coderabbit_status が使う filter closure と同一のロジックです。共通ヘルパーへ抽出すると、マッチ条件を変更する際に更新箇所を1つに集約できます。

♻️ 提案する統合案
+fn contains_coderabbit(context: Option<&str>) -> bool {
+    context.map(|c| c.contains("CodeRabbit")).unwrap_or(false)
+}
+
 fn is_coderabbit_status_context(item: &GhRollupItem) -> bool {
-    item.context
-        .as_deref()
-        .map(|c| c.contains("CodeRabbit"))
-        .unwrap_or(false)
+    contains_coderabbit(item.context.as_deref())
 }

parse_coderabbit_status 側の filter も同じヘルパーを使うように置き換えられます。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/check-ci-coderabbit/src/parsers.rs` around lines 53 - 67,
is_coderabbit_status_context と parse_coderabbit_status に重複している CodeRabbit
context 判定を統合する。parse_coderabbit_status の filter closure を
is_coderabbit_status_context の共通ヘルパー呼び出しに置き換え、既存の判定条件と結果を維持する。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/check-ci-coderabbit/src/parsers.rs`:
- Around line 53-67: is_coderabbit_status_context と parse_coderabbit_status
に重複している CodeRabbit context 判定を統合する。parse_coderabbit_status の filter closure を
is_coderabbit_status_context の共通ヘルパー呼び出しに置き換え、既存の判定条件と結果を維持する。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 754bfba0-5b1e-457d-bb6d-6d029c88b9c9

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2b37c and 1985926.

📒 Files selected for processing (4)
  • docs/adr/adr-064-monitor-success-positive-evidence.md
  • src/check-ci-coderabbit/src/main.rs
  • src/check-ci-coderabbit/src/models.rs
  • src/check-ci-coderabbit/src/parsers.rs

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Monitor 分析 (GitHub Actions バックストップ)

  • トリガー: pull_request_review (submitted) / 実行 run
  • CI: statusCheckRollup に Rust ビルド/テスト系の CheckRun はまだ出現していない。エントリは本 workflow 自身の analyze check (実行中) と CodeRabbit の commit status (SUCCESS) のみ。CI の合否は現時点で未確定。
  • レビュー状況: CodeRabbit — レビュー完了 (state: COMMENTED, nitpick 1 件、CodeRabbit 自身が「🔵 Trivial」「💤 Low value」とタグ付け)。人間レビュー: なし (reviewDecision 空)。インライン (pulls/.../comments) 指摘: 0 件 (nitpick は review body 内)。
  • Verdict: approved (適用可能な指摘は Trivial/Low value の 1 件のみで、severity は Info/Low 相当)

Applicable Findings (Critical / High / Major)

(該当なし)

Applicable Findings (Medium 以下)

# File (Line) Reviewer Issue Recommended Action
1 src/check-ci-coderabbit/src/parsers.rs (53-67) CodeRabbit is_coderabbit_status_context (GhRollupItem 向け) と parse_coderabbit_status の filter closure (GhStatusItem 向け) が「context に "CodeRabbit" を含むか」という同一ロジックを別々に実装している 共通ヘルパー (fn contains_coderabbit(context: Option<&str>) -> bool) への統合を検討。CodeRabbit 自身が Trivial/Low value と評価しており必須対応ではない

Filtered (not applicable)

(該当なし)

次のアクション

  • Rust ビルド/テスト系の CheckRun が statusCheckRollup に出現するまで待ち、次回イベント (push / review 等) で CI 結果を再評価する (本 workflow はポーリングしないため能動的な待機はしない)。
  • 上記 nitpick はブロッカーではないため、対応するかは任意 (低優先度のリファクタリングとして次回まとめて処理する選択肢もある)。

@aloekun
aloekun merged commit facd19d into master Aug 2, 2026
2 checks passed
@aloekun
aloekun deleted the fix/monitor-ci-rollup branch August 2, 2026 04:03
aloekun added a commit that referenced this pull request Aug 2, 2026
…3) (#346)

PR #342/#343/#344 の post-merge feedback 採用候補 14 件のうち、2026-08-02 の
方針決定 (文書系 10 件 = 1 docs バッチ PR、実装系 4 件 = A/B 系統別 PR) に従い
5 エントリとして登録:

- 順位 359: 文書系 10 件の docs バッチ (dev-conventions 集中、Severity High 2 件含む)
- 順位 360: cargo test コマンド等価性検証テスト (#342/#343 で連続指摘 = Frequency High)
- 順位 361: JJ_VERSION の 2 ファイル一致検証テスト (順位 360 と同一 PR 可)
- 順位 362: git subprocess ブランチ名依存引数の custom lint rule (#343 incident 由来)
- 順位 363: check-ci-coderabbit の detached HEAD 回帰統合テスト (順位 362 と同一 PR 可)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant