Skip to content

Conversation

@mafreud
Copy link
Contributor

@mafreud mafreud commented Oct 12, 2025

Summary by CodeRabbit

  • 新機能
    • issues.opened に対し「Hello, World!」を自動コメントするよう対応
  • リファクタ
    • JIT設定の取り扱いと外部API呼び出しを整理、サーバー作成/削除処理のペイロード順序を整備
    • 関数のリソース設定配置を見直し
  • テスト
    • Probot テストを簡素化、ペイロード/認証モックを明確化しネット接続制御を追加
  • スタイル
    • ビルド/リンター/エディタ設定の構成を整理(キー順序・コンパイル設定含む)
  • チョア
    • package.json スクリプトやワークスペース拡張推奨、保存時アクションを更新

@linear
Copy link

linear bot commented Oct 12, 2025

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 12, 2025

Walkthrough

Probot関連の再編成で getJitConfiggithub.ts に新規追加し参照元を切替、hetzner.ts から削除。Webhook を issues.reopened から issues.opened に変更。Firebase のリソース設定や各種設定ファイル・テストを更新。

Changes

Cohort / File(s) Change Summary
Probot — GitHub JIT の追加と参照切替
openci-runner/firebase/functions/probot/github.ts, openci-runner/firebase/functions/probot/index.ts
github.tsgetJitConfig(octokit, owner, repo, serverId) を追加(Octokit POST /repos/.../generate-jitconfig を呼ぶ)。index.ts は hetzner から github に呼び先を切替、Webhook ハンドラを issues.opened に変更、インポート整理と引数順微調整。
Hetzner モジュールの整理
openci-runner/firebase/functions/probot/hetzner.ts
getJitConfig を削除。deleteServer に明示的な HTTP メソッド "DELETE" を追加。createServer のリクエストボディのフィールド順を整理・重複削除し、戻り値に serverId を明示。
Firebase Functions エントリ変更
openci-runner/firebase/functions/src/index.ts
onRequest のリソース設定(cpu/memory)をトップレベルへ移動し、createProbot 内に overrides を再導入。
テストとフィクスチャ更新
openci-runner/firebase/functions/test/index.test.ts, openci-runner/firebase/functions/test/fixtures/issues.opened.json
テストを Probot 単体前提で更新(ProbotOctokit 削除、appId 定義、nock モック簡素化、厳密比較へ変更)。フィクスチャはフィールド順のみ変更。
パッケージと TypeScript 設定
openci-runner/firebase/functions/package.json, openci-runner/firebase/functions/tsconfig.json
package.json に scripts/engines/main/name/private/type を整備(Node 22、ESM、scripts 再導入)。tsconfig.jsoncompileOnSave を追加し、module/sourceMap/targetcompilerOptions に移動・再追加。
ツール/ワークスペースとビルド設定
biome.jsonc, openci.code-workspace
biome.jsoncassist ブロック追加、linter.recommended をトップレベルへ移動・ルール整理、files.includes を追加。openci.code-workspace に拡張推奨、Dockerfile 用フォーマッタ、codeActionsOnSave 等を追加・再配置。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor GitHub
  participant FF as Firebase onRequest
  participant PB as Probot
  participant HZ as Hetzner API
  participant GHAPI as GitHub API

  GitHub->>FF: webhook (issues.opened)
  FF->>PB: dispatch event
  PB->>HZ: createServer(apiKey)
  HZ-->>PB: { serverId, ipv4 }
  PB->>GHAPI: POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig
  GHAPI-->>PB: { encoded_jit_config }
  PB->>HZ: initRunner(encoded_jit_config)
  PB->>GitHub: post comment / other actions
  FF-->>GitHub: 200 OK
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

ぴょん、と跳んでコードの畑へ
issues.opened に挨拶を送るよ
JIT は GitHub の手で紡がれ
サーバは立ち上がり IPv4 が光る
うさぎのしっぽでビルド合図 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed タイトルはProbotのIssue作成時の単体テスト追加とファイル全体の整形を言及しており、実際にテスト追加とフォーマットが含まれていますが、その他の主要な機能追加や設定リファクタリングを反映していません。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch op-317

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between aaeb791 and a867853.

📒 Files selected for processing (2)
  • biome.jsonc (1 hunks)
  • openci.code-workspace (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-12T04:41:44.291Z
Learnt from: mafreud
PR: open-ci-io/openci#505
File: biome.jsonc:12-17
Timestamp: 2025-10-12T04:41:44.291Z
Learning: In Biome configuration (biome.json or biome.jsonc), `recommended: true` can be placed under `linter.rules` to enable recommended rules for all groups. This is a valid configuration according to the official Biome documentation at https://biomejs.dev/ja/reference/configuration/#linterrulesrecommended

Applied to files:

  • biome.jsonc
🔇 Additional comments (8)
biome.jsonc (3)

10-15: LGTM!

ファイルのインクルード/エクスクルード設定は適切です。node_modulesの除外により、不要なファイルの処理を回避できます。


21-22: AI要約との不整合を検出しました。

AI要約では「linter.recommendedをトップレベルに移動し、linter.rules.recommendedを削除」と記載されていますが、実際のコードではrecommended: truelinter.rulesの下に残っています(22行目)。

過去の学習によると、この配置はBiomeの公式ドキュメントに従って有効であることが確認されています。現在のコードは正しい状態です。

Based on learnings


2-9: 影響を受けるJSONファイルの確認
以下のファイルでキーの自動ソートが発生する可能性があります。

  • biome.jsonc
  • openci-runner/firebase/firebase.json
  • openci-runner/firebase/functions/package-lock.json
  • openci-runner/firebase/functions/package.json
  • openci-runner/firebase/functions/test/fixtures/issues.opened.json
  • openci-runner/firebase/functions/tsconfig.json

assist.actions.source.useSortedKeys: "on" の適用範囲をBiomeのドキュメントで確認し、代表的なJSONファイルで動作をテストしてください。

openci.code-workspace (5)

2-31: LGTM!

推奨拡張機能のリストは包括的で、プロジェクトの要件に適合しています。Biome、Flutter、Rust、およびその他の関連ツールのサポートが含まれています。


38-40: Dockerfileフォーマッターの拡張機能が推奨リストにありません。

Dockerfileのデフォルトフォーマッターとしてms-azuretools.vscode-containersが設定されていますが、この拡張機能がextensions.recommendationsリストに含まれていません。

開発者が拡張機能をインストールしていない場合、フォーマットが機能しない可能性があります。

拡張機能リストに追加することを検討してください:

         "recommendations": [
             "aaron-bond.better-comments",
             "biomejs.biome",
             "bradlc.vscode-tailwindcss",
+            "ms-azuretools.vscode-containers",
             "cweijan.dbclient-jdbc",

57-107: LGTM!

スペルチェッカーの辞書に追加された単語は、プロジェクト固有の用語とツール名であり、適切です。


109-111: LGTM!

Biome固有のorganizeImportsアクションへの変更は、プロジェクトのBiome採用と一貫性があります。explicitモードの使用により、意図しない自動実行を防ぎます。


112-119: LGTM!

エディタ設定は適切です:

  • 保存時の自動フォーマットが有効
  • targetディレクトリ(ビルド成果物)の除外
  • ターミナルのカレントディレクトリ設定

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

@mafreud mafreud changed the title Issue作成時のProbotにunit testを追加 Issue作成時のProbotにunit testを追加 + 全体のファイルを再度フォーマット Oct 12, 2025
@sentry
Copy link

sentry bot commented Oct 12, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
openci-runner/firebase/functions/probot/github.ts (1)

16-29: ハードコードされた値とエラー処理を確認してください。

以下の点について検証をお願いします:

  1. runner_group_id: 1: デフォルトのランナーグループIDとして1がハードコードされています。すべての環境やリポジトリで適切かどうかを確認してください。

  2. エラー処理: 関数にはエラー処理が実装されていません。GitHub APIリクエストが失敗した場合(認証エラー、レート制限、ネットワークエラーなど)、Octokitのデフォルトエラー処理に依存しています。呼び出し元でエラーを適切に処理しているか確認してください。

  3. テンプレートリテラル: Lines 24-25のownerrepoでテンプレートリテラルが使用されていますが、既に文字列型のため不要です。

簡略化の提案:

-			owner: `${owner}`,
-			repo: `${repo}`,
+			owner: owner,
+			repo: repo,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea5d43 and aaeb791.

⛔ Files ignored due to path filters (1)
  • openci-runner/firebase/functions/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • biome.jsonc (1 hunks)
  • openci-runner/firebase/functions/package.json (1 hunks)
  • openci-runner/firebase/functions/probot/github.ts (1 hunks)
  • openci-runner/firebase/functions/probot/hetzner.ts (3 hunks)
  • openci-runner/firebase/functions/probot/index.ts (3 hunks)
  • openci-runner/firebase/functions/src/index.ts (2 hunks)
  • openci-runner/firebase/functions/test/fixtures/issues.opened.json (1 hunks)
  • openci-runner/firebase/functions/test/index.test.ts (2 hunks)
  • openci-runner/firebase/functions/tsconfig.json (1 hunks)
  • openci.code-workspace (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
openci-runner/firebase/functions/test/index.test.ts (1)
openci-runner/firebase/functions/probot/index.ts (1)
  • appFn (17-134)
🔇 Additional comments (16)
openci-runner/firebase/functions/test/fixtures/issues.opened.json (1)

1-18: LGTM!

テストフィクスチャのフィールド順序変更は、機能的に影響がなく問題ありません。

openci-runner/firebase/functions/tsconfig.json (1)

2-13: LGTM!

TypeScript設定の再構成により、すべての設定が適切にcompilerOptionsの下にネストされています。module: "NodeNext"はNode.js ESMプロジェクトに適しており、target: "es2017"はNode.js 22に対応しています。

openci-runner/firebase/functions/src/index.ts (2)

17-18: リソース制限が高めに設定されています。

Webhookハンドラーに対して8 CPUと16GiBのメモリが割り当てられています。Hetznerサーバーのプロビジョニング操作に必要な場合は問題ありませんが、これらのリソース制限が実際に必要かどうかを確認してください。過剰なリソース割り当てはコストに影響する可能性があります。


38-42: LGTM!

Probot設定におけるoverridesブロックの追加により、GitHub App認証情報が適切に提供されています。Firebaseシークレットから値を取得する方法は正しく、ハードコードされた機密情報はありません。

openci.code-workspace (2)

2-31: LGTM!

推奨拡張機能のリストは、プロジェクトの技術スタック(Flutter、Rust、TypeScript)に適合しており、開発体験を向上させます。


104-106: LGTM!

Biomeによる保存時のインポート整理設定により、コードの一貫性が保たれます。formatOnSaveとの組み合わせで、自動的にコードがフォーマットされます。

biome.jsonc (1)

2-9: LGTM!

assist.actions.source.useSortedKeysの有効化により、オブジェクトキーの順序が自動的に整理され、コードの一貫性が向上します。ワークスペースのBiome拡張機能推奨設定と整合しています。

openci-runner/firebase/functions/package.json (1)

18-34: LGTM!

パッケージ設定は適切です:

  • Node.js 22(現行LTS)を指定
  • type: "module"によりESMモジュールとして構成
  • tsconfig.jsonmodule: "NodeNext"設定と整合
  • Firebase Functionsプロジェクトの標準的なスクリプト構成
openci-runner/firebase/functions/probot/index.ts (3)

1-5: LGTM!

インポートの変更により、getJitConfighetzner.tsからgithub.tsに移動しています。これはJIT設定取得ロジックをGitHub関連モジュールに配置するリファクタリングの一部であり、モジュールの責務が明確になります。


21-25: LGTM!

イベントハンドラーがissues.openedに変更され、PRタイトルの「Issue作成時のProbotにunit testを追加」と整合しています。コメント本文が「Hello, World!」に変更されていますが、デバッグ用コードとして明示されているため問題ありません。


71-76: LGTM!

SSH接続設定のフィールド順序変更は、機能的に影響がなく問題ありません。

openci-runner/firebase/functions/probot/github.ts (3)

1-1: LGTM!

Octokit型のインポートにより、getJitConfig関数のパラメータに適切な型付けが行われています。


10-15: LGTM!

関数シグネチャは明確で、適切に型付けされています。index.tsでの使用方法と一致しています。


31-31: LGTM!

encoded_jit_configの返却は、GitHub APIレスポンスから正しくデータを抽出しています。

openci-runner/firebase/functions/test/index.test.ts (1)

45-47: コメント本文の完全一致チェックが良いです

toEqual で期待ボディを厳密に検証しているので、差分に敏感なリグレッションを確実に拾えます。

openci-runner/firebase/functions/probot/hetzner.ts (1)

43-48: serverId を返す形に整理された点が良いです

取得した ID をそのまま返却しておくことで、呼び出し側での追加パースが不要になり見通しが良くなりました。

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.

2 participants