Description

Ensure the ruleset on the default branch requires specified status checks, such as CI builds, tests, linting, or security scans, to pass before a pull request can be merged.

Rationale

Without required status checks, a pull request can be merged even if automated builds, tests, or security scans are failing or have not run at all. Requiring these checks to pass enforces a consistent quality gate and catches regressions and vulnerabilities before they reach the default branch.

Impact

  • Prevents merging code that fails automated builds, tests, linting, or security scans

  • Catches regressions and vulnerabilities before they reach the default branch

  • Enforces consistent quality gates across all contributors

  • Reduces the operational risk of deploying broken or insecure code

Default Value

By default, no status checks are required before merging; pull requests can be merged even if CI checks are failing or have not run.

Pre-Requisites

  • Admin access to the repository

  • CI/CD workflows or checks already configured and reporting status to pull requests

Test Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  5. Select the ruleset that targets the default branch.

  6. Verify that Require status checks to pass is enabled and the expected checks are listed as required.

  1. If it is not enabled, or the required checks are missing, follow the implementation steps.

Implementation Steps

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  1. Select the existing ruleset that targets the default branch, or click New ruleset, then New branch ruleset.

  2. Under Rules, enable Require status checks to pass.

  3. Click Add checks and select the checks that must pass, such as build, test, or security-scan workflows.

  4. Optionally select Require branches to be up to date before merging.

  1. Click Create, or Save changes.

Backout Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  5. Select the ruleset that targets the default branch.

  6. Disable Require status checks to pass.

  7. Click Save changes.

Reference