Sub topic 7
Reading logs and status checks
This chapter assumes you have a workflow that runs your tests on push and pull_request, as built in the earlier chapters. Here you learn to read what that workflow reports and to find the cause of a failure quickly.
Where results appear
GitHub shows the same run in three places:
- The Actions tab lists every run, grouped by workflow.
- A pull request has a Checks section at the bottom of the conversation. It has one line per job.
- A commit has a small icon next to it in the commit list. It is a yellow dot, a green check, or a red cross.
Each place links to the same run page. The run contains jobs, and each job contains steps. A step is the smallest unit that can pass or fail.
What the statuses mean
| Status | Meaning |
|---|---|
| Queued or in progress | Waiting for a runner, or running now |
| Success | Every step exited with code 0 |
| Failure | A step exited with a non-zero code, so the job stopped |
| Cancelled | A person or a `concurrency` rule stopped the run |
| Skipped | A condition such as `if:` or `needs:` prevented the job from running |
A step fails when its command exits with a non-zero code. npm test exits non-zero when any test fails, so a failing test turns the step red. By default, later steps are skipped after a failure.
Reading a log
Open the failing job and expand the step with the red cross. Then read the log in this order:
- Find the first error, not the last line. The last lines are often a summary such as
Process completed with exit code 1, which says nothing about the cause. - Scroll up to the test runner's output. Look for the test name, the expected and actual values, and the file and line number.
- If the failing step is
npm cior the setup step, the problem is the environment, not your tests.
Name your steps, because the name is the label you scan in the log. You can also fold long output into a collapsible section with the ::group:: command.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: |
echo "::group::Test environment"
node --version
npm --version
echo "::endgroup::"
npm testThe versions print inside a folded group called "Test environment". The test output stays visible below it.
Triage flow
Re-running and extra detail
On the run page, Re-run failed jobs repeats only the jobs that failed. If a failure looks random, run it again. The same test passing on a re-run is evidence of a flaky test, not a fixed bug. The re-run dialog also offers Enable debug logging, which adds extra runner detail to the log.
Common errors
- Reading a skipped job as a pass. A skipped job shows a grey icon and ran no tests.
- Renaming a job without noticing. The check name comes from the job. Matrix jobs get the matrix values added, for example
test (ubuntu-latest, 20). A later chapter requires specific check names before merging, so a rename can leave a required check waiting forever. - Stopping at the summary line.
exit code 1only says that something failed.
Exercise
A pull request shows a red cross on the job test. In the log, the last line is "Process completed with exit code 1". What should you read first, and why?
Show answer
Find the first error in the failed step, which is usually the test runner's output above the last line. The exit-code line only reports that the command failed. It does not say which test failed or why.