Sub topic 12
Reading the graph and troubleshooting
This chapter assumes you can write a workflow with on, jobs, runs-on, and steps, and that you know how needs, if, outputs, and matrix jobs work from earlier chapters. Here you will learn to read the workflow graph that GitHub draws for a run and to diagnose the most common needs problems.
Reading the workflow graph
Open a workflow run in the Actions tab. The summary page draws each job as a box. Lines connect a job to the jobs it lists in needs, and the graph reads from left to right. Jobs with no needs sit in the leftmost column. Jobs in the same column can run at the same time.
The icon on each box tells you the outcome:
- A green check means the job succeeded.
- A red cross means it failed.
- A grey circle with a slash means it was skipped.
- A grey stop sign means it was cancelled.
- A yellow dot or spinner means it is queued or running.
A skipped job is not a failure. It means a job it needed did not succeed and no if condition overrode that.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Workflow is rejected before any job starts | `needs` names a job ID that does not exist, or the jobs depend on each other in a cycle | Check spelling against the keys under `jobs:` and remove the cycle |
| A job is skipped and you expected it to run | A needed job failed or was skipped, and the default is to skip | Fix the upstream job, or add an `if` with a status check function |
| A cleanup job is skipped after a failure | `if: always()` is missing | Add `if: ${{ always() }}` to the job |
| A job with `if: failure()` never runs | `failure()` is true only when a job it depends on failed, and the job has no `needs` | Add the failing job to `needs` |
| An output is empty | The output was not mapped under `outputs:`, the step has no `id`, or the job did not list the producer in `needs` | Fix the mapping, as shown below |
| Files are missing in a later job | Each job has a fresh runner, so the filesystem is not shared | Use `upload-artifact` and `download-artifact` |
Rejected workflows
GitHub validates the dependency graph when it parses the file. Two errors appear often. The first is a reference to an unknown job, such as needs: biuld. The second is a cycle, such as a needing b while b needs a. The run does not start, and the error shows on the workflow file instead of in a job log. Job IDs are case sensitive, and needs takes the ID, not the name: display text.
Empty outputs
Here is a broken workflow. The step has no id, so the job output can never find it.
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
steps:
- run: echo "version=1.2.3" >> "$GITHUB_OUTPUT"
publish:
needs: prepare
runs-on: ubuntu-latest
steps:
- run: echo "Publishing version ${{ needs.prepare.outputs.version }}"The expression steps.ver.outputs.version refers to a step whose id is ver, but no step has that id. The publish job prints an empty version and nothing reports an error. The fix is to add id: ver to the step.
Jobs that never start
A job that stays queued is usually waiting for a runner, not for needs. Check that the runs-on label matches an available runner, and that a concurrency group is not holding the run in a pending state behind another run. A job that waits on needs shows as queued until every needed job finishes.
Debugging a skipped job
Work upstream from the skipped box:
- Find the job it lists in
needsand check its result. - If an upstream job failed, read its logs first. Fixing it usually fixes the skip.
- If the upstream job succeeded but your job was skipped, read the job's own
ifcondition. - To see the values, add a temporary step in a job that always runs.
jobs:
inspect:
needs: [build, test]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- run: echo "build=${{ needs.build.result }} test=${{ needs.test.result }}"The result of each needed job is success, failure, cancelled, or skipped. Printing these values shows which condition your if is actually evaluating.
Exercise
A deploy job has needs: [build, test]. The run shows test failed, build succeeded, and deploy skipped. You want a report job to post a message in this situation only when something failed. What if should report use, and what must its needs contain?
Show answer
report needs needs: [build, test] so it can see their results. Use if: ${{ always() && contains(needs.*.result, 'failure') }}. Without always(), report would also be skipped because test failed.