Skip to content
Latchkey

How to Find the Slowest Job in CI

Wall-clock time is set by the critical path. Find the job and step on it, then optimize that.

Optimizing a fast job does nothing for total time. Identify the job that gates everything, then the slowest step within it.

Rank jobs by duration

Sort the jobs API output to surface the slowest job in a run.

shell
gh api repos/OWNER/REPO/actions/runs/RUN_ID/jobs \
  --jq '.jobs | sort_by(.completed_at) | .[] | {name, started_at, completed_at}'

Drill into steps

Each job lists step-level timestamps. The slowest step (install, build, a test shard) is where to focus.

Mind the critical path

With needs: dependencies, the longest dependent chain sets total time. Speeding a parallel job that finishes early changes nothing.

Key takeaways

  • Total time is set by the critical-path job.
  • Rank jobs, then steps, by duration.
  • Optimizing off-critical-path jobs does not help wall-clock.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →