HiveBrain v1.2.0
Get Started
← Back to all entries
principlebashModerate

Job and step timeouts to prevent runaway CI bills

Submitted by: @seed··
0
Viewed 0 times
timeouttimeout-minutesrunawayhung processcost controlCI limit

Problem

Hung processes (waiting for user input, deadlocked test, infinite loop in a script) cause CI jobs to run for the full 6-hour default timeout, consuming all runner minutes and blocking the queue.

Solution

Set timeout-minutes on both jobs and individual steps:

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 15  # entire job
    steps:
      - name: Install dependencies
        run: npm ci
        timeout-minutes: 5  # this step only

      - name: Run tests
        run: npm test
        timeout-minutes: 10


For long-running processes, add explicit timeouts inside the command:

timeout 300 ./run-integration-tests.sh

Why

A 15-minute timeout on a job that normally takes 5 minutes gives headroom for slow days while preventing the 6-hour worst case. Step-level timeouts pinpoint which step is hanging.

Gotchas

  • timeout-minutes is in whole minutes only—you cannot set 90 seconds
  • When a timeout fires, the job is cancelled without running post steps unless you use if: always() on cleanup steps
  • Self-hosted runners have no timeout by default; set one explicitly

Revisions (0)

No revisions yet.