summaryrefslogtreecommitdiff
path: root/.github/scripts/validate-workflow-timeouts.py
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
committerChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
commit76956486fa7ef52a51d4e56df1e13a9f19a6c93c (patch)
treefe0c394439fdc167d1970372e8998874090854dd /.github/scripts/validate-workflow-timeouts.py
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
parentffc62c792c9a5196cb4ce7a353287dfe20db6524 (diff)
Update upstream source from tag 'upstream/3.3.0_beta1+dfsg'
Update to upstream version '3.3.0~beta1+dfsg' with Debian dir 85037bbb9376721108594b59b54ead82ac6924a3
Diffstat (limited to '.github/scripts/validate-workflow-timeouts.py')
-rwxr-xr-x.github/scripts/validate-workflow-timeouts.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/.github/scripts/validate-workflow-timeouts.py b/.github/scripts/validate-workflow-timeouts.py
index 256f5782..e3539a36 100755
--- a/.github/scripts/validate-workflow-timeouts.py
+++ b/.github/scripts/validate-workflow-timeouts.py
@@ -9,6 +9,8 @@ JOB_PATTERN = re.compile(
r"^ (?P<quote>[\"']?)(?P<name>[A-Za-z_][A-Za-z0-9_-]*)(?P=quote):"
r"(?:\s+&[A-Za-z_][A-Za-z0-9_-]*)?(?:\s*#.*)?$"
)
+TIMEOUT_PATTERN = re.compile(r"^ timeout-minutes:\s*(\d+)\s*(?:#.*)?$")
+MINIMUM_JOB_TIMEOUTS = {("build-macos.yml", "build"): 180}
def unbounded_jobs(path: Path) -> list[str]:
@@ -18,10 +20,18 @@ def unbounded_jobs(path: Path) -> list[str]:
job_line = 0
has_runner = False
has_timeout = False
+ timeout_minutes: int | None = None
def finish_job() -> None:
if job_name is not None and has_runner and not has_timeout:
failures.append(f"{path}:{job_line}: job '{job_name}' has runs-on but no timeout-minutes")
+ minimum = MINIMUM_JOB_TIMEOUTS.get((path.name, job_name or ""))
+ if job_name is not None and has_runner and minimum is not None and (
+ timeout_minutes is None or timeout_minutes < minimum
+ ):
+ failures.append(
+ f"{path}:{job_line}: job '{job_name}' timeout-minutes must be at least {minimum}"
+ )
for line_number, line in enumerate(path.read_text().splitlines(), start=1):
if line == "jobs:":
@@ -40,6 +50,7 @@ def unbounded_jobs(path: Path) -> list[str]:
job_line = line_number
has_runner = False
has_timeout = False
+ timeout_minutes = None
elif (
line.startswith(" ")
and not line.startswith(" ")
@@ -54,6 +65,9 @@ def unbounded_jobs(path: Path) -> list[str]:
elif job_name is not None:
has_runner = has_runner or line.startswith(" runs-on:")
has_timeout = has_timeout or line.startswith(" timeout-minutes:")
+ timeout_match = TIMEOUT_PATTERN.match(line)
+ if timeout_match:
+ timeout_minutes = int(timeout_match.group(1))
else:
finish_job()