Skip to main content

GitHub Copilot による自動コード レビューの構成

Pull request を自動的にレビューするように Copilot を構成する方法について説明します。

はじめに

この記事では、Copilot コード レビュー を設定して、自動的に pull request をレビューする方法について説明します。 自動的な pull request のレビューの概要については、「GitHub Copilot のコード レビューについて」を参照してください。

この記事の 3 つのセクションでは、以下に対して自動的なコード レビューを構成する方法について説明します。

自分の pull request に対する自動コード レビューの構成

メモ

これは、Copilot Pro または Copilot Pro+ プランをご利用の場合にのみ使用できます。

  1. In the upper-right corner of any page, click your profile picture, then click Your Copilot.

  2. [Automatic Copilot コード レビュー] オプションを見つけて、ドロップダウン ボタンをクリックします。

    ドロップダウン メニューが表示された [Automatic Copilot コード レビュー] 設定のスクリーンショット。

  3. ドロップダウン メニューで [Enabled] を選びます。

1 つのリポジトリに対して自動コード レビューを構成する

  1. GitHub で、リポジトリのメイン ページに移動します。

  2. リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。

    タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。

  3. 左側のサイド バーの [コードと自動化] の下で、 [ルール] をクリックし、 [ルールセット] をクリックします。

    リポジトリの [設定] ページのサイド バーのスクリーンショット。 [ルール] サブメニューが展開され、[ルールセット] オプションの枠線がオレンジ色で表示されています。

  4. 新しいルールセット」をクリックします。

  5. [新しいブランチ ルールセット] をクリックします。

  6. [ルールセット名] に、ルールセットの名前を入力します。

  7. ルールセットをアクティブにするには、[Enforcement Status] で [Active] を選びます。

  8. [Target branches] で [Add target] をクリックし、オプションのいずれかを選びます。たとえば、[Include default branch] または [Include all branches] などです。

  9. Under "Target branches," click Add target and choose one of the target options.

  10. Under "Branch rules," select Automatically request Copilot コード レビュー.

    This expands a set of subsidiary options.

    Screenshot of the "Automatically request Copilot コード レビュー" branch ruleset option.

  11. Optionally, if you want Copilot to review all new pushes to the pull request, select Review new pushes.

    If this option is not selected, Copilot will only review the pull request once.

  12. Optionally, if you want Copilot to review pull requests while they are still drafts, select the Review draft pull requests.

    This can be a useful option for catching errors early, before requesting a human review.

  13. At the bottom of the page, click Create.

Organization のリポジトリについて自動コード レビューを構成する

  1. GitHub の右上隅でプロフィール写真を選んでから、 [Your organizations] をクリックします。

  2. 組織の隣の [設定] をクリックします。

  3. 左のサイド バーの [コード、計画、自動化] セクションで、[ リポジトリ] をクリックし、[ルールセット] をクリックします。

    組織の設定ページのスクリーンショット。 サイド バーで、[ルールセット] というラベルの付いたリンクがオレンジ色の枠線で囲まれています。

  4. 新しいルールセット」をクリックします。

  5. [新しいブランチ ルールセット] をクリックします。

  6. [ルールセット名] に、ルールセットの名前を入力します。

  7. ルールセットをアクティブにするには、[Enforcement Status] で [Active] を選びます。

  8. [Target repositories] で、[Add target] をクリックし、[Include by pattern] または [Exclude by pattern] を選びます。

  9. 表示されるダイアログ ボックスに、organization 内のリポジトリの名前と一致するパターンを入力します。たとえば、名前が feature で終わるすべてのリポジトリと一致するようにするには、「*feature」と入力します。

    パターンマッチング構文の詳細については、「組織内のリポジトリのルールセットを作成する」を参照してください。

  10. ダイアログ ボックスで、[Add inclusion pattern] または [Add exclusion pattern] をクリックします。

  11. 追加するパターンがある場合は、このプロセスを繰り返します。

    メモ

    複数のターゲット条件を同じルールセットに追加できます。 除外パターンは包含パターンの後に適用されます。 たとえば、パターン *cat* に一致するリポジトリを含め、パターン not-a-cat に一致するリポジトリを明示的に除外できます。

  12. Under "Target branches," click Add target and choose one of the target options.

  13. Under "Branch rules," select Automatically request Copilot コード レビュー.

    This expands a set of subsidiary options.

    Screenshot of the "Automatically request Copilot コード レビュー" branch ruleset option.

  14. Optionally, if you want Copilot to review all new pushes to the pull request, select Review new pushes.

    If this option is not selected, Copilot will only review the pull request once.

  15. Optionally, if you want Copilot to review pull requests while they are still drafts, select the Review draft pull requests.

    This can be a useful option for catching errors early, before requesting a human review.

  16. At the bottom of the page, click Create.