What to do when CI checks fail on a pull request
When CI checks fail on a GitHub pull request: find which check failed, read the log, decide whether it's your change or flaky, fix or re-run, and keep reviewers informed.
On this page
When CI checks fail on a pull request, start by finding exactly which check failed and reading its log, since the first error usually tells you the cause. Then decide: is it caused by your change, by something on the main branch, or is it a flaky test? Fix your code and push, update your branch, or re-run the check. Keep reviewers informed so they don't review a moving target.
Step 1: find the failing check
On the pull request, the merge box and the Checks tab show which checks failed. Open the failed one and its job to see the steps; the failing step is marked.
OneNotch can save you the trip: on its GitHub screen, each pull request's summary reads, for example, "12 checks · 1 failing". Press C to list the checks, failing ones first, with each one's state, duration and a link straight to its log. It shows up to eight checks, then "and N more on GitHub".
Step 2: read the log
- Scroll to the first error, not the last line. Later errors are often consequences of the first.
- Look for the test name, file and line.
- Compare with a passing run on the main branch if the error is confusing.
Step 3: decide the cause
| Cause | Signs | What to do |
|---|---|---|
| Your change | The failing test or build touches code you changed | Fix it locally, push a new commit |
| The main branch | The same failure happens on main or other pull requests | Update your branch once main is fixed; tell the team |
| Out-of-date branch | Passes on main, conflicts with recent changes | Merge or rebase the latest base branch |
| Flaky test | Passes when re-run, fails at random | Re-run, and report the flaky test |
| Infrastructure | Timeouts, runner errors, network failures | Re-run; report if it repeats |
Step 4: fix or re-run
- Fix: reproduce locally if you can, fix, push. Checks run again on the new commit.
- Re-run: on GitHub, open the workflow run and use the re-run option for failed jobs. You need the right repository permissions. OneNotch doesn't re-run checks; open the log from the notch and re-run on GitHub.
Don't re-run repeatedly hoping for green. If a test is flaky, report it so it gets fixed; flaky tests waste everyone's time.
Step 5: keep reviewers informed
- If your pull request is under review and checks fail, comment that you're fixing it, or convert it to a draft. See draft pull requests on GitHub.
- After fixing, mention reviewers if their approvals were dismissed by the new commit.
As a reviewer
When a pull request you're reviewing has failing checks, look at what failed before reading the code. A failure in the changed area means the code may change; it's often better to wait. An unrelated failure is worth a comment so the author knows. See a pull request review checklist.
Prevent the common causes
- Run tests and linters locally before pushing.
- Keep your branch up to date with the base branch for long-running work.
- Fix or quarantine flaky tests promptly.
- Make required checks the ones that matter, so failures always mean something. See required reviews and branch protection.
FAQs
How do I see why a GitHub check failed?
Open the pull request's Checks tab, choose the failed check and read its log. In OneNotch, C lists checks with links to their logs.
Can I merge with a failing check?
Not if the check is required, unless someone with bypass permission overrides it.
Who can re-run a failed check?
People with suitable permissions on the repository, typically write access or above.
Will OneNotch alert me when CI fails?
Not yet. A notch preview for failing CI is on the roadmap. Today, the check summary shows on each pull request in the GitHub screen.