Sub topic 14
Reviewing and moving checks over time
Check placement is not a one-time decision. Test suites grow, flaky tests appear, and teams change how they work. A check that fit on pull requests last year may now take 25 minutes. A nightly check may have started catching bugs that cost your team a day each time. This chapter covers how to review placement with data and how to move checks safely.
It assumes you already know the three stages (pull request, merge, nightly), how triggers and required status checks work, and how flaky tests and nightly triage are handled.
Why placement drifts
Placement drifts for predictable reasons:
- Test suites get slower as code and test counts grow, so a check that was cheap becomes expensive.
- A flaky test erodes trust in a stage until people ignore its failures.
- A nightly check that fails often tells you it protects something important, but it also tells you the failures arrive too late.
- Team habits change. A team that once merged weekly may now merge twenty times a day, which changes the cost of every merge-time check.
Without a review habit, the pipeline only changes when someone is annoyed enough to complain. Scheduled reviews turn that annoyance into evidence.
The three signals to collect
Review decisions rest on three kinds of data: runtime, failures, and escapes.
| Signal | What it measures | Where to get it | What it tells you |
|---|---|---|---|
| Runtime | Median and 90th percentile (p90) duration per check, plus queue time | CI run history, workflow run API | Whether a check is too slow for its stage |
| Failure | Failure rate, and how many failures were real versus flaky | CI run history, rerun counts | Whether a check gives a trustworthy signal |
| Escape | Bugs that reached a later stage or production that a check should have caught | Incident reports, bug tracker, nightly failures | Whether a check is too late or missing |
Use p90 rather than the average for runtime. Developers feel the slow runs, and the average hides them.
An escape is a defect that passed one stage and was caught later, or never caught. Escapes are the most useful signal and the hardest to collect, because someone has to record where each bug was found and where it could have been found. A simple label on bug reports such as caught-in:nightly or caught-in:production is enough to start.
Pulling runtime data
GitHub's REST API returns run timing for a workflow. The script below computes the median and p90 duration of recent successful runs. It uses only the Python standard library and needs a token in the GITHUB_TOKEN environment variable.
import json
import os
import statistics
import sys
import urllib.request
from datetime import datetime
def fetch_runs(repo, workflow_file, per_page=100):
url = (
f"https://api.github.com/repos/{repo}/actions/workflows/"
f"{workflow_file}/runs?status=success&per_page={per_page}"
)
request = urllib.request.Request(
url,
headers={
"Authorization": f"Bearer {os.environ['GITHUB_TOKEN']}",
"Accept": "application/vnd.github+json",
},
)
with urllib.request.urlopen(request) as response:
return json.load(response)["workflow_runs"]
def minutes(run):
start = datetime.fromisoformat(run["run_started_at"].replace("Z", "+00:00"))
end = datetime.fromisoformat(run["updated_at"].replace("Z", "+00:00"))
return (end - start).total_seconds() / 60
def main():
repo, workflow_file = sys.argv[1], sys.argv[2]
durations = sorted(minutes(run) for run in fetch_runs(repo, workflow_file))
if len(durations) < 2:
print("Not enough runs to compute statistics.")
return
p90 = durations[int(len(durations) * 0.9) - 1]
print(f"runs: {len(durations)}")
print(f"median: {statistics.median(durations):.1f} min")
print(f"p90: {p90:.1f} min")
if __name__ == "__main__":
main()Run it as python durations.py my-org/my-repo pr.yml. The updated_at field is an approximation of the end time, and it includes time spent on reruns of the same run. For exact per-job timings, use the jobs endpoint for each run. The approximation is good enough to spot a trend.
Triggers for moving a check
Set explicit thresholds so that moves are decisions rather than arguments. The numbers below are examples. Choose your own and write them down.
| Observation | Likely move |
|---|---|
| PR stage p90 exceeds your budget (for example 10 minutes) | Move the slowest check to merge time, or parallelize it |
| Merge-time check never fails on its own, and the PR stage catches the same problems | Remove it or move it to nightly |
| Nightly check fails often with real bugs that take hours to trace | Move it earlier, or add a cheaper subset to merge time |
| A check fails more than a few percent of runs with no code change | Quarantine it and fix it before it stays in a blocking stage |
| A bug escaped to production and no check at any stage covers it | Add a check, starting at the cheapest stage that can detect it |
Moves go in both directions. People tend to think of review as a way to push checks later. Escapes often argue the opposite, for example promoting a fast subset of a nightly suite to the pull request.
A review cadence
Run a short review on a fixed schedule, such as monthly or once per quarter. Trigger an extra review after any incident that escaped CI.
- Export the runtime and failure data for the period.
- List the slowest checks at each stage and compare them with the stage budgets.
- List checks with a flaky rate above your threshold, and confirm each has an owner.
- List escapes since the last review and note which stage should have caught each.
- Propose moves, with the data behind each one.
- Apply the moves, record them, and set a date to look at the effect.
Keep the output of each review in the repository, for example in a docs/ci-placement.md file. A short table of check name, stage, owner, runtime, and reason for placement makes the next review faster, and new team members can learn why the pipeline looks the way it does.
Moving a check safely
A move can break the protection that a required status check gives you, so do it in a defined order.
Promoting a check to an earlier stage
Moving a check earlier, for example from nightly to merge, adds cost for every developer. Do it in steps:
- Run the check in the new stage as non-blocking, so failures are visible but do not stop merges.
- Watch it for one to two weeks. Measure runtime and failure rate.
- If the failure rate is low and the runtime fits the budget, make it required.
- Keep the nightly copy for a short time, then remove it if it duplicates the new placement.
In GitHub Actions, you can run a check without blocking by simply not adding it to the required status checks in branch protection. The check still reports on the pull request, but it cannot stop a merge.
Demoting a check to a later stage
Moving a check later reduces cost but also reduces protection. Before demoting:
- Confirm the check has not caught real problems at its current stage during the review period.
- Confirm that a cheaper check at the earlier stage covers the most common failures.
- Add the check to the later stage first, and confirm it runs.
- Remove it from the earlier stage and from the required list.
Order matters here. If you remove the check before the new one is running, there is a window with no coverage.
Required check names and renames
Branch protection matches required checks by name. If you rename a job or a workflow while moving it, the required check with the old name never reports. GitHub then waits for it forever, and every pull request is stuck as "Expected". This is the most common way a placement change blocks merges by accident.
To avoid it, add the new check name to the required list while the old one is still reporting, and remove the old name only after the new one has passed on several pull requests.
A related gotcha affects path filters. If you move a check into a workflow that uses paths, the workflow does not run when the paths do not match, and a required check from that workflow stays pending. A common fix is to run the workflow always and decide inside the job whether to do the work, so that the check reports a result in every case.
Example: an evolution
The diagram shows a check that starts at the pull request stage, is moved as it slows down, and returns as a fast subset after an escape.
Each move comes with a reason drawn from data. The suite is slow, so it moves later. An escape shows that the merge-only placement is too late for one class of bug, so a cheap subset returns to the pull request. Neither move needs the check to be deleted.
Pitfalls
- Reviewing only runtime. A fast check that never catches anything still costs attention. A slow check that catches many real bugs may still be worth its place.
- Counting reruns as passes. If a developer reruns a failing job until it passes, the final status looks clean. Count the number of attempts, not only the final result.
- Treating nightly failures as background noise. If nobody owns the nightly failures, the stage stops providing information. Review the age of open nightly failures as part of the cadence.
- Moving many checks at once. If you change five placements in one review, you cannot tell which one caused a later problem. Move a few at a time and compare the results.
- Skipping the record. Without a note on why a check lives where it does, the next review repeats the same debate.
Exercise
Your pull request stage has a 10-minute budget. Over the last month, the end-to-end smoke check has a p90 of 16 minutes, fails 1% of the time, and caught two real bugs. A different integration check has a p90 of 4 minutes, fails 12% of the time, and half of those failures pass on rerun. What would you do with each, and in what order would you apply the changes?
Show answer
For the smoke check, the failure rate is low and it catches real bugs, so keep its protection but fix its cost. Options are to parallelize it or split out a faster subset for pull requests and run the full suite at merge time. If you move the full suite, first add it to the merge stage, then reduce the pull request version, then update required checks. For the integration check, runtime is fine but the signal is poor: about 6% of runs fail only because of flakiness. Quarantine the flaky tests (or make the check non-required while you fix them) and assign an owner. Apply the integration check change first because it is cheap and blocks developers now, then plan the smoke check split with the new stage running non-blocking before it becomes required.
Exercise
You rename the job integration to integration-tests while moving it to a merge queue workflow. Afterward, every open pull request shows "Expected - Waiting for status to be reported" and cannot merge. Why did this happen, and how should the move have been done?
Show answer
Branch protection still lists the old name integration as required. No job with that name runs anymore, so the status is never reported. The move should have added integration-tests to the required list while the old job was still running, confirmed it reported on several pull requests, and only then removed integration from the required list.