Sub topic 2
From a red check to the failing step
This chapter covers how to get from a failed check on a commit or pull request to the exact step that failed. It assumes you can read YAML and know the workflow, job, and step hierarchy from the previous chapter. It also assumes you have a repository with a workflow that has run at least once.
Where a failure shows up
A failed workflow run appears in several places. All of them lead to the same run page.
- Pull request checks box. Near the bottom of the Conversation tab, each job appears as a row with a status icon. A red cross means the job failed. A grey circle with a slash means it was cancelled or skipped.
- Commit status. On the commit list, a red cross next to a commit links to the checks for that commit.
- Actions tab. This tab lists every run of every workflow in the repository. You can filter by workflow, status, branch, event, and actor.
- Email and notifications. If you pushed the commit, GitHub can notify you when a run fails. The message links to the run.
A check name in the pull request box is usually <workflow name> / <job name>. For the baseline workflow, which is named CI and has a job named test, the check is CI / test. If you use a matrix, the name also includes the matrix values, for example CI / test (20).
The navigation path
The shortest path from a red check to a failing step has four moves.
- Click Details next to the failed check in the pull request box. This opens the run page on that job.
- Find the job in the left sidebar. Failed jobs have a red icon.
- In the job view, find the step with the red icon. GitHub often expands the failed step automatically.
- Read the expanded step output, starting from the bottom, then work upward.
The diagram shows the same path as a flow.
If you start from the Actions tab instead, select the workflow in the left list, click the failed run, and continue from step 2.
Anatomy of the run page
The run page has three regions. Knowing what each one is for saves time.
The summary page
When you open a run without selecting a job, you see the Summary. It shows the trigger (for example, "Triggered via push"), the commit, the total duration, and a graph of the jobs. It also lists annotations and any artifacts the run uploaded. Use this page to see which jobs failed and how jobs relate to each other. If one job failed and three others are grey, the grey jobs probably depend on the failed one through needs.
The job sidebar
The left sidebar lists the jobs in the run. Each job has a status icon:
| Icon | Meaning |
|---|---|
| Green check | Every step succeeded, or the failed steps were allowed to fail |
| Red cross | At least one step failed |
| Grey circle with slash | The job was skipped or cancelled |
| Yellow dot or spinner | Waiting, queued, or running |
The job view
Selecting a job shows its steps in order. The list starts with Set up job, which prepares the runner and records the runner image and the permissions of the GITHUB_TOKEN. Then come your steps. The list ends with Post steps and Complete job. Post steps are cleanup tasks that actions register, such as saving a cache. They appear after your own steps, even though the action that owns them appeared earlier.
Step names come from the name: key. A step without a name gets a generated one: Run actions/checkout@v4 for a uses: step, or Run npm ci for a run: step. For multi-line run: blocks, the generated name is the first line. Give important steps explicit names so the list stays readable.
Reading the step list in the baseline workflow
Here is the baseline workflow again.
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm testSuppose package.json is in an app/ subdirectory. The job view then looks like this:
| Step | Status |
|---|---|
| Set up job | Succeeded |
| Run actions/checkout@v4 | Succeeded |
| Run actions/setup-node@v4 | Succeeded |
| Run npm ci | **Failed** |
| Run npm test | Skipped |
| Post Run actions/checkout@v4 | Succeeded |
| Complete job | Succeeded |
Two details matter here. First, Run npm test is skipped, not failed. By default, a step runs only if all earlier steps succeeded. Once npm ci fails, the later steps are skipped. Second, the post step for checkout still runs, because post steps run even after a failure so that cleanup is not lost.
The failing step is Run npm ci. Expanding it shows output like this:
Run npm ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/demo/demo/package.json
npm ERR! errno -2
npm ERR! enoent Could not read package.json
Error: Process completed with exit code 254.The last line, Error: Process completed with exit code 254., is added by the runner. It tells you the step failed because the command returned a non-zero exit code. The lines above it come from npm and tell you why. The path /home/runner/work/demo/demo/package.json shows that npm looked in the repository root, where no package.json exists.
Reading a step from the bottom up
The failing line is nearly always near the end of the step, so read from the bottom. The final Error: Process completed with exit code N. line confirms that this step is the one that failed. The tool's own error message sits just above it. Keep reading upward until you find the first message that describes a problem rather than a consequence.
This is the first move of a larger method, covered in a later chapter, for telling a root cause from follow-on errors. For now, treat the step you land on as a starting point and not a verdict. The red step is where the job stopped. It is not always where the problem began. A failed test step may be caused by a configuration problem in an earlier step that exited with code 0.
Confirming the job and the environment
Before you read the log in detail, spend ten seconds on the context.
- Which commit? The run page header shows the commit SHA and message. Confirm it is the commit you think it is, especially after a force push.
- Which event? A
pull_requestrun checks out a merge of your branch into the base branch, not your branch tip. A failure that appears only in the pull request run can come from the base branch. - Which runner? Expand Set up job to see the runner image and version. A change in image version can break a workflow that did not change.
- Which attempt? If the run was re-run, the page shows an attempt selector. Logs from attempt 1 and attempt 2 are separate. Make sure you are reading the attempt you care about.
Searching and downloading logs in the browser
Long logs are hard to scan. The job view gives you several tools.
- Search logs. The search box at the top of the job view filters the log to matching lines across all steps and highlights them. Search for
error,failed, or the name of a package. - Timestamps. The gear menu at the top right of the log toggles Show timestamps. Timestamps help you spot a step that hung or took far longer than usual.
- Full screen. The gear menu also has a full screen option for long output.
- Download log archive. The same menu lets you download all logs for the job as a zip file with one text file per step. Use this when you want to search with your own tools.
- Permalinks. Click a line number to get a link to that line. Paste this link into a pull request comment or an issue so that others see exactly the line you mean.
Logs are kept for a limited time, 90 days by default for public and private repositories, and repository or organization settings can shorten this. A run whose logs have expired still appears in the list, but its steps show no output.
Common ways this navigation goes wrong
- No red step is visible. The job failed before any of your steps ran. Look at Set up job, or at the job's annotations on the summary page. Typical causes are an unavailable runner label, a missing environment approval, or a permission problem fetching an action.
- No job appears at all. If the run shows a failure with no jobs, the workflow file is invalid. The error appears as an annotation on the summary page. A later chapter covers these errors.
- The job is grey and skipped. An
if:condition evaluated to false, or a job inneedsfailed. Open the failed upstream job instead. - The check is red but the failed step is green. The job may have been cancelled by a timeout, or a post step failed. Scroll to the end of the step list and look at the post steps and Complete job.
- Checks from a fork pull request are missing. Workflows triggered by pull requests from forks may require a maintainer to approve the run before it starts.
Practice with the baseline
Use the baseline workflow to rehearse the path.
- Put a
package.jsonin a subdirectory namedapp/and push the workflow above to a test branch. - Open a pull request and wait for the check to turn red.
- Click Details and find the red step.
- Turn on timestamps and find how long the checkout step took.
- Download the log archive and find the file for the failed step.
You should not fix the workflow yet. The goal is to be able to reach the failing step quickly and to know what each part of the page tells you.
Exercise
A pull request check named "CI / test" is red. On the run page, the steps "Run npm ci" is red, "Run npm test" is grey, and "Post Run actions/checkout@v4" is green. Which step failed, why is "Run npm test" grey, and why did the post step still run?
Show answer
"Run npm ci" failed. "Run npm test" is grey because it was skipped: by default a step runs only when all earlier steps succeeded, and npm ci did not. The post step ran anyway because post steps are cleanup tasks that run even when the job has failed, so that things like cache saves and credential cleanup are not lost.
Exercise
You open a red run and find no step with a red icon. Name two places to look next and what each could reveal.
Show answer
Expand "Set up job" in the job view, which can show runner or action download problems. Check the annotations on the run's summary page, which show workflow file errors, timeouts, or cancellations. You can also look at the post steps and "Complete job" at the end of the list, because a post step can fail after your own steps pass.