Sub topic 1
How CI Triggers and Status Checks Work
Prerequisites
This chapter assumes basic Git and pull requests, familiarity with a CI system, and knowledge of linting, unit tests, and integration tests.
How CI Triggers and Status Checks Work
Continuous integration (CI) runs automated checks when repository events occur. A trigger is the event that starts a workflow, such as opening a pull request, adding a commit, entering a merge queue, pushing to main, or reaching a scheduled time.
A status check is the reported result of a job. It is usually success, failure, or pending. Branch protection can require selected successful checks before a pull request can merge.
name: pr
on:
pull_request:
branches: [main]
jobs:
fast-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm testThis workflow tests proposed changes before they reach main. A merge-queue workflow should also use the merge_group trigger, because it tests the commit that combines the pull request with other approved changes.
Feedback Speed versus Confidence
Fast checks give developers useful feedback while they can still fix the change easily. Broader checks inspect more behavior, but they consume more time, compute, or external services. Running every check on every pull request may create long queues and encourage developers to ignore failures.
Use pull request checks for failures that should block review. Use merge-time checks for tests that need the final combined state. Schedule expensive or broad checks when their slower feedback is acceptable.
> callout note > A required check must run for every change that needs it. A skipped required check can block a merge or create a false sense of safety, depending on the CI provider's status behavior.
Kinds of Checks and Their Costs
| Check | Typical scope | Main cost |
|---|---|---|
| Lint and unit tests | Changed code and small components | Low runtime |
| Integration tests | Several components or services | Setup and runtime |
| End-to-end tests | Complete user flows | High runtime and flakiness |
A Decision Framework for Where a Check Belongs
For each check, ask:
- How quickly does it return a useful failure signal?
- Does it need the complete merged state?
- What is the cost of running it on every pull request?
- What risk exists if it runs later?
- Can the team assign and respond to failures?
Place fast, deterministic, high-value checks on pull requests. Place merge-sensitive checks at merge time or on main. Place expensive exploratory checks nightly, then review failures promptly.
Exercise
Where should a deterministic unit test that finishes in 30 seconds usually run?
Show answer
On every pull request, and usually again in the merge or main-branch workflow.