Skip to main content

Restricting code coverage on pull requests

Protect your test coverage by automatically blocking pull requests that fall below the coverage levels your team requires.

この機能を使用できるユーザーについて

リポジトリの所有者、組織の所有者、および 管理者 ロールを持つユーザー

この記事で

メモ

This feature is in パブリック プレビュー and subject to change.

Prerequisites

Creating a coverage threshold rule

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

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

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

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

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

  4. Create a new branch ruleset or click an existing one to edit it.

  5. Under "Branch rules", select Restrict code coverage.

  6. Expand Additional settings to configure thresholds. A value of 0 means that the threshold is disabled.

    • Minimum coverage percentage: enter a value to block pull requests where aggregated coverage falls below this percentage.
    • Maximum coverage drop: enter a value to block pull requests where coverage drops by more than this many percentage points relative to the default branch.
  7. Click Create or Save changes.