Status check
- Git course
- Advanced
- Lesson 51/56
- 4 min
Learn the required status check rule.
What Is a Status Check?
A status check is a result that indicates whether a pull request has passed specific automated checks. CI tools such as GitHub Actions report whether tests and other validations have succeeded or failed. These checks can be required before merging into a protected branch.
test:
result: success
build:
result: successThis helps prevent changes with failing tests from reaching the main branch.
Selecting Required Checks
You can select which status check results are required in GitHub branch protection settings. For example, a pull request cannot be merged until the CI job named test succeeds. The check name must match the name reported by CI.
required_status_checks:
strict: true
contexts:
- teststrict: true also requires the branch to be up to date with the target branch, so changes that fall behind the target can be validated again.
Practice Require the Test Check
Create a required_status_checks section for the main branch. Set strict to true and add the test check to the contexts list.
Starter code
# Zorunlu durum kontrollerini ekle
# Güncellik şartını etkinleştir
# Kontrol listesini oluşturSample solution
main:
required_status_checks:
strict: true
contexts:
- testExpected output
test kontrolü zorunlu hale getirildi.
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What happens if a required test check fails on a pull request?
- The test result automatically becomes successful
- The pull request is automatically deleted
- The Git repository is closed
- The merge requirement is not satisfied Correct answer
Explanation: When a required status check fails, the merge is blocked because the required condition has not been met.
2 Specify a Required Check Name
required_status_checks:
strict: true
contexts:
- ____
required_status_checks:
strict: true
contexts:
- test
Explanation: Including <code>test</code> in the <code>contexts</code> list requires the check reported with that name to succeed.
3 Status Check Components
| Term | Meaning |
|---|---|
Status check |
An automated check result |
CI |
Runs tests and builds |
contexts |
Contains required check names |
strict |
Requires target branch updates |