Sub topic 12
Owning and Triaging Nightly Failures
Nightly checks catch problems that pull requests and merge builds do not. A failed nightly run has no author waiting on it, though, so nobody feels responsible for it. If nobody owns the failure, the run turns red and stays red. People then learn to ignore it, and the slow, expensive suite you built stops protecting you.
This chapter covers how to assign ownership, how to triage a failure, and how to keep the nightly signal trustworthy. It assumes you know how scheduled workflows are configured (see the earlier chapters on triggers and nightly checks) and that you have read the chapter on flaky tests.
Why nightly failures need explicit ownership
A pull request check has a built-in owner: the author of the PR. They see the red mark, and they can't merge until it clears. A nightly run has none of that:
- It runs on the default branch, not on someone's change.
- It covers every commit merged since the last green run, so the cause could be any of them.
- Nothing blocks, so nothing forces a response.
- Failures can come from outside the code, such as an expired credential, a down third-party service, or a changed base image.
Without a named owner, the typical pattern is that everyone assumes someone else saw it. A failure that goes unseen for three days is then three days of commits to search.
Decide who owns what
There are two common ownership models. Pick one deliberately.
| Model | How it works | Strengths | Weaknesses |
|---|---|---|---|
| Rotating triager | One person per day or week is on duty for all nightly failures | Clear single point of contact, spreads the load | Triager may lack context for every suite |
| Suite or area owner | Each test suite or directory maps to a team | Owner knows the code | Cross-cutting failures fall between teams |
Many teams combine them. The rotating triager looks at the result each morning and makes the first decision. They then route the failure to the owning team. The triager's job is to classify and assign, not to fix everything.
Record ownership in the repository so it is not tribal knowledge. GitHub supports a CODEOWNERS file for review requests. You can also keep a simple mapping from suite to team that your notification script reads.
Make failures visible
A red run that nobody opens is the same as no run. Push the result to where people already look.
- Send a message to a team chat channel when the nightly workflow fails.
- Open or update an issue automatically, labelled with the suite and the failing date.
- Include a link to the run, the failing job, and the commit range since the last success.
The workflow below adds a notification job that runs only when the e2e job fails. It opens an issue so the failure is tracked, not just announced. It assumes the nightly workflow from the earlier chapter.
name: nightly
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run test:e2e
report:
needs: e2e
if: failure()
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Open an issue for the failed run
env:
GH_TOKEN: ${{ github.token }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
gh issue create \
--repo "$GITHUB_REPOSITORY" \
--title "Nightly e2e failed on $(date -u +%F)" \
--label nightly-failure \
--body "The nightly e2e run failed. Run: $RUN_URL"The if: failure() condition makes the report job run only when a job it depends on failed. Without it, the job would be skipped after a failure, because the default condition is success.
One issue per failed night can become noise if the same problem persists. A refinement is to search for an open issue with the same label first and add a comment instead of creating a duplicate. That keeps one issue per problem and shows how long it has lasted.
A triage process you can repeat
Triage is the first look at a failure. Its goal is to answer one question quickly: what kind of failure is this, and who should act? Work through the same steps each time.
- Open the run and read the first failure. Later errors are often side effects of the first one.
- Check whether it is new. Compare with the previous nights. A failure that began last night points to a recent change. One that has been red for a week is a neglected problem.
- Classify it using the categories below.
- Assign an owner and a deadline. Put both on the issue.
- Decide on containment. Either fix forward, revert the suspect change, or quarantine the check while the fix is in progress.
Classify the failure
| Category | Typical signs | Usual action |
|---|---|---|
| Real regression | Fails consistently, started after a specific commit | Revert or fix the change, notify its author |
| Flaky test | Passes on rerun, fails intermittently, no related change | Quarantine and file a fix ticket |
| Environment or infrastructure | Timeouts, network errors, runner problems, failed dependency download | Rerun once, then fix the environment |
| Expired secret or external dependency | Authentication errors, third-party service errors | Rotate the secret or contact the provider |
| Test data or state drift | Fails only on the nightly environment, depends on shared data | Reset or isolate the data |
Rerunning once is a legitimate triage step, but it is a diagnostic, not a fix. If the rerun passes, you have learned that the failure is intermittent. You have not learned that it is fine. Record it so the pattern is visible.
Find the commit that broke it
Because a nightly run covers many commits, finding the culprit is often the longest part of triage. Narrow it down in this order.
- Find the last green nightly run and the first red one.
- List the commits between them. In Git,
git log <last-green-sha>..<first-red-sha> --onelinedoes this. - If the list is short, read it for obvious suspects.
- If it is long, use
git bisectto find the first bad commit, running the failing test at each step.
Merge queue and main-branch runs help here. If your merge stage already runs integration tests on every candidate commit, then the nightly failure is more likely to come from the slow suite's own scope or from the environment. That narrows the search before you read a single log.
git bisect start
git bisect bad <first-red-sha>
git bisect good <last-green-sha>
git bisect run npm run test:e2e -- --grep "checkout flow"Bisecting works only when the failure is deterministic. If the test is flaky, git bisect run will mark good commits as bad and send you to the wrong place. Confirm that the failure reproduces several times before you bisect.
Set response expectations
Agree on how fast a nightly failure must be handled. Without a stated target, urgent and unimportant failures wait equally long.
A reasonable starting policy:
- Acknowledge the failure the same working morning. The triager comments on the issue with a classification.
- Contain within one working day. Revert, quarantine, or fix.
- Resolve within an agreed window, such as one week for quarantined checks.
Write the policy down where the team can find it. A policy nobody has read does not change behavior.
Keep the signal trustworthy
The measure of a nightly build is whether a red result means something. Several habits protect that.
- Do not leave it red. A permanently red build hides new failures behind old ones. Fix, revert, or quarantine so that the next failure is visible as a change.
- Quarantine with a time limit. A quarantined check should have an owner, an issue, and an expiry date. If it passes the date, either fix it or delete it.
- Track the green rate. Count how many nights in the last 30 were green. A falling rate is an early warning.
- Separate infrastructure failures from test failures. If a third of red nights are caused by the environment, the problem is the pipeline, and fixing it is real work.
- Do not blame by default. Triage records what happened and what to change. The goal is a shorter path from failure to fix.
Feed triage results back into placement
Each triaged failure is data about where the check lives. Look for these patterns:
- A nightly check that fails often on real regressions may be catching things that matter now. Consider moving a fast subset to the merge stage.
- A nightly check that fails only because of its environment may need a more stable setup before it can move anywhere.
- A check that has never failed in months may be a candidate for a lower frequency, or for review of whether it still tests something useful.
The chapter on reviewing and moving checks covers how to make these decisions using runtime, failure, and escape data. Triage notes, classified consistently, are the raw material for that review.
Common mistakes
- Treating the nightly as someone else's job. Without a named triager, no one acts.
- Rerunning until it passes. This hides flaky tests and infrastructure faults.
- Bisecting a flaky failure. The result will be wrong.
- Letting issues pile up. Duplicates and stale issues bury the live ones. Update an existing issue instead of opening another.
- Never recording the cause. Without categories, you cannot see that half of your failures come from one source.
Exercise
Your nightly e2e job has failed on three of the last ten nights. Two of those failures passed on rerun with no code change. One failed consistently after a commit that changed the checkout flow. How should you classify and handle each, and what should you do before running git bisect on the two intermittent failures?
Show answer
The two failures that passed on rerun are most likely flaky tests or environment problems. Quarantine the affected test with an owner, an issue, and an expiry date, or fix the environment if logs show timeouts or network errors. The consistent failure after the checkout commit is a real regression. Revert or fix that change and notify its author. Do not run git bisect on the intermittent failures, because a non-deterministic test makes bisect mark good commits as bad. If you want to bisect them, first confirm that you can reproduce the failure reliably over several runs.
Exercise
A team's nightly build has been red for nine days. New failures keep appearing, and nobody can tell which are new. List two concrete changes that would restore the value of the signal.
Show answer
First, contain the existing failures so the build can go green: fix or revert real regressions, and quarantine flaky checks, each with an owner and an expiry date. Second, assign a rotating triager who acknowledges every failure the same working morning and records its classification. Tracking the green rate over the last 30 nights afterwards would show whether the signal is recovering.