Lesson 15 / 25

Timeouts, Sizing and Splitting

Bound runaway jobs.

Default timeouts are very long

A job's default timeout is 6 hours, so a hung test can burn hours of minutes. Set timeout-minutes on jobs (and on risky steps) to a little above normal duration. Speed up slow suites by splitting them across matrix shards, running only affected tests in monorepos, using larger runners for CPU-bound builds, and moving rarely needed checks to scheduled workflows. Measure: the Actions usage and workflow run timing views show where minutes go.

Sharding a slow test suite

Not linted or run here; check the GitHub Actions documentation for current syntax.

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    strategy:
      matrix:
        shard: [1, 2, 3, 4]
    steps:
      - uses: actions/checkout@v4
      - run: npx playwright test --shard=${{ matrix.shard }}/4

Always set timeout-minutes

A timeout slightly above the usual duration turns a silent six-hour hang into a quick, visible failure.

Quick check: What is the default job timeout?

  • 6 hours
  • 5 minutes
  • 30 seconds
  • There is no limit
Answer

6 hours — Set your own.