Sub topic 3
Reading a step log
This chapter assumes you can read workflow YAML, know the difference between a workflow, a job, and a step, and can open a run page from a failed check. Here you learn how the log of a single step is laid out and what to look for in it.
What a step log contains
Each step in a job has its own section on the run page. Click a step name to expand it. The log for that step shows the output of the command or action, one line at a time, in the order it was written.
A step log usually has these parts:
- Header lines. For a
runstep, the runner prints the command it is about to execute, often marked with##[group]Run npm ci. This shows the exact command, the shell, and anyenvvalues set for the step. - Command output. Everything the command writes to standard output and standard error.
- Final status. If the command fails, the runner adds a line such as
Error: Process completed with exit code 1.
Timestamps are hidden by default. Open the gear menu at the top right of the log and choose Show timestamps to see when each line was written. Timestamps help you spot a step that hung or a command that was much slower than usual.
Groups
Long output is folded into groups. A group has a title and a small arrow. The runner makes groups for its own setup work, and tools or your own scripts can make more with workflow commands.
steps:
- name: Install and test
run: |
echo "::group::Install"
npm ci
echo "::endgroup::"
echo "::group::Test"
npm test
echo "::endgroup::"Groups are collapsed by default, so the error you want can be hidden inside one. If a step is marked failed but you see no error, expand the groups near the end of the step.
Lines marked as errors
The runner highlights some lines:
| Marker | Meaning |
|---|---|
| `##[error]` | An error. It also creates an annotation on the run summary. |
| `##[warning]` | A warning. It does not fail the step. |
| `##[group]` and `##[endgroup]` | The start and end of a folded group. |
| `##[debug]` | Extra detail. It appears only when debug logging is on. |
A red line is not always the cause of the failure. Many tools print the word "error" in output that is harmless, and some failures print nothing in red.
Reading the log from the bottom
A practical way to read a failed step is to start at the end and work up:
- Find the final line, such as
Process completed with exit code 1. This confirms the step failed and gives the exit code. - Scroll up to the output just before it. This is often the last thing the tool printed.
- Keep scrolling up until you reach the first message that describes a real problem. Later errors are often side effects of the first one.
Here is a short example from a step running npm ci in the wrong directory:
Run npm ci
npm error code ENOENT
npm error syscall open
npm error path /home/runner/work/demo/demo/package.json
npm error errno -2
npm error enoent Could not read package.json
Error: Process completed with exit code 254.The cause is in the npm error path and enoent lines: package.json is not in the directory where the step ran. The exit code only says that something failed.
Searching and sharing
Use the search box above the log to find a word such as error, failed, or a file name. Matches are highlighted across the steps that are expanded. To share a position, click a line number. The page URL gets a fragment that opens the log at that line.
Exercise
A step log ends with Error: Process completed with exit code 1. Above it, you see three red lines. The first mentions a missing file, and the other two mention failed tests. Which line do you investigate first, and why?
Show answer
Investigate the first line, the missing file. It appears earliest, and the failed tests that follow are probably a result of it. Fixing the missing file may clear all three errors.