diff options
| author | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
| commit | 82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch) | |
| tree | 1a1f782d3e576b758be0bc61171574a7cd8f2376 /.github/scripts/validate-workflow-timeouts.py | |
| parent | 061658210acb6425517733ea012dda803a7f72a1 (diff) | |
| parent | 61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff) | |
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to '.github/scripts/validate-workflow-timeouts.py')
| -rwxr-xr-x | .github/scripts/validate-workflow-timeouts.py | 14 |
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() |
