Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
Expand Down Expand Up @@ -60,6 +61,7 @@ jobs:
# validates and stops, because a fork's build must never reach Pages.
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
pages: write
id-token: write
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ permissions:
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 5
environment: npm
permissions:
contents: read # job-level permissions replace the workflow block
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand All @@ -35,6 +36,7 @@ jobs:
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
environment: pypi
permissions:
id-token: write # OIDC token for Trusted Publishing
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
# tests such as test_era_algotune's reference speedup measured 0.07x there.
# Move this deliberately, with the matrix, when 3.9 support is dropped.
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -49,6 +50,7 @@ jobs:
# nothing listens on: the refusal must be logged and contained, never raised
# out of `export_run`, and a real export must still return its count.
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand Down
5 changes: 5 additions & 0 deletions changelog.d/1235-workflow-job-timeouts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed
Every workflow job now declares a `timeout-minutes` -- 5 or 10 for the short
report, build and publish jobs, 60 for the five-version `tests` matrix -- so a
stalled deploy, publish or test run fails in minutes instead of holding a
runner for GitHub's 360-minute default (#1235).
76 changes: 76 additions & 0 deletions tests/test_workflow_timeouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Every workflow job bounds its own run time.

A job without ``timeout-minutes`` inherits GitHub's 360-minute default, so a
stalled step -- a Pages deploy waiting on its OIDC exchange, a publish job
holding ``id-token: write``, a test runner blocked on a hung fixture -- reads as
a slow check for six hours instead of a stuck one.

The bounds are calibrated from this repository's own run history (Actions API,
read 2026-11-23), not from round numbers:

==================== ================= =====
job observed minutes bound
==================== ================= =====
docs build 1.3 - 2.8 10
docs deploy 0.0 - 0.1 5
publish build 0.6 - 0.9 10
publish publish 0.3 - 0.4 5
publish-npm publish 0.2 - 0.3 5
tests test (per Py) 15.7 - 29.9 60
tests otel-wire 1.2 - 1.4 10
==================== ================= =====

``tests`` keeps the largest bound on purpose: a 5- or 10-minute cap on a matrix
job that takes twenty would turn green PRs red, and these caps exist to catch a
hang, not to race a healthy run.
"""

from __future__ import annotations

from pathlib import Path

import yaml

WORKFLOWS = Path(__file__).resolve().parent.parent / ".github" / "workflows"
MAXIMUM = 60


def _jobs():
for path in sorted(WORKFLOWS.glob("*.yml")):
wf = yaml.safe_load(path.read_text(encoding="utf-8"))
for name, job in (wf.get("jobs") or {}).items():
yield path.name, name, job


def test_every_job_declares_timeout_minutes():
missing = [
f"{wf}:{job}"
for wf, job, spec in _jobs()
if spec.get("timeout-minutes") is None
]
assert not missing, (
"a job without `timeout-minutes` inherits GitHub's 360-minute default, "
f"so one stalled step holds the runner for six hours: {missing}"
)


def test_no_job_is_bound_above_the_slowest_observed_suite():
too_long = [
(wf, job, spec.get("timeout-minutes"))
for wf, job, spec in _jobs()
if not 1 <= spec.get("timeout-minutes", 0) <= MAXIMUM
]
assert not too_long, (
f"keep every job bound at or below {MAXIMUM} minutes, or a hang still "
f"reads as a slow check: {too_long}"
)


def test_the_test_matrix_keeps_headroom_above_its_measured_runtime():
wf = yaml.safe_load((WORKFLOWS / "tests.yml").read_text(encoding="utf-8"))
limit = wf["jobs"]["test"].get("timeout-minutes")
assert limit is not None and limit >= 45, (
"the test job runs the whole offline suite across five Pythons and "
"measured 15.7-29.9 minutes per version on 2026-11-23, so a bound "
"under 45 would cut a healthy run instead of catching a hung one"
)
Loading