Skip to content

Commit 3d52788

Browse files
tachyonicClockhmgomes
authored andcommitted
feat: add PYTEST_TIMEOUT_FACTOR to scale timeouts for release CI
Release CI (release.yml) matrices across Windows/macOS, which run noticeably slower than the Linux runner the pytest-timeout (90s) and per-cell notebook timeout (180s) were tuned against. Rather than loosening those timeouts for everyone, add PYTEST_TIMEOUT_FACTOR (env var, default 1) that tasks.py's pytest/doctest/notebooks tasks scale their timeout by, and set it to 2 in release.yml's test job. Assisted-by: claude-code:claude-sonnet-5
1 parent 1dd01ed commit 3d52788

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
name: Tests
1414
timeout-minutes: 120
1515
runs-on: ${{ matrix.operating-system }}
16+
env:
17+
# Windows/macOS runners are noticeably slower than the Linux runner the
18+
# pytest/doctest/notebook timeouts in tasks.py are tuned for. Double
19+
# them here rather than loosening the timeouts everyone else runs with.
20+
PYTEST_TIMEOUT_FACTOR: "2"
1621
strategy:
1722
fail-fast: true
1823
matrix:

tasks.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
IS_CI = environ.get("CI", "false").lower() == "true"
2121
COVERAGE_DEFAULT = False
2222

23+
# Scales the pytest/doctest/notebook timeouts below. Release CI runs on
24+
# Windows/macOS runners that are noticeably slower than the Linux runner the
25+
# base timeouts are tuned for, so `release.yml` sets this to `2` to double
26+
# them. Keep the base values here in sync with pyproject.toml's
27+
# `[tool.pytest.ini_options] timeout`, which is the fallback used when pytest
28+
# is invoked directly (bypassing these tasks and thus this factor).
29+
PYTEST_TIMEOUT_FACTOR = float(environ.get("PYTEST_TIMEOUT_FACTOR", "1"))
30+
PYTEST_TIMEOUT = int(90 * PYTEST_TIMEOUT_FACTOR)
31+
NOTEBOOK_FAST_TIMEOUT = int(60 * 3 * PYTEST_TIMEOUT_FACTOR)
32+
2333

2434
def python_exe(profile: Optional[str] = None) -> str:
2535
if profile:
@@ -235,7 +245,7 @@ def notebooks(
235245
environ["NB_FAST"] = "true"
236246
# Per-cell timeout. Windows CI runners are several times slower than
237247
# Linux/macOS, so keep some headroom over local fast-mode timings.
238-
timeout = 60 * 3
248+
timeout = NOTEBOOK_FAST_TIMEOUT
239249
else:
240250
timeout = -1
241251

@@ -294,6 +304,7 @@ def pytest(
294304
"-m pytest",
295305
"--durations=5", # Show the duration of each test
296306
"--exitfirst", # Exit instantly on first error or failed test
307+
f"--timeout={PYTEST_TIMEOUT}",
297308
]
298309
cmd += ["--cov"] if coverage else []
299310
cmd += ["-n=auto"] if parallel else []
@@ -329,6 +340,7 @@ def doctest(
329340
"--durations=5", # Show the duration of each test
330341
"--exitfirst", # Exit instantly on first error or failed test
331342
"src/capymoa", # Don't run tests in the `tests` directory
343+
f"--timeout={PYTEST_TIMEOUT}",
332344
]
333345
cmd += ["--cov"] if coverage else []
334346
cmd += ["-n=auto"] if parallel else []

0 commit comments

Comments
 (0)