Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
bandit:
name: Bandit
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
analyze:
name: CodeQL
runs-on: ubuntu-26.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
# Move it to 26.04 once CodSpeed supports it; nothing here will notice when
# that happens, so it is worth trying on a branch now and then.
runs-on: ubuntu-24.04
timeout-minutes: 25

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ permissions:
jobs:
build:
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
# After a push that failed, Docker Hub still has the old image: nothing to rescan.
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ permissions:
jobs:
docker:
runs-on: ubuntu-26.04
timeout-minutes: 20
steps:
# The tag being built, not the default branch. The image is built from this
# checkout now, so a dispatched rebuild of an older version has to stand on
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
licenses:
name: License Check
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
build-and-publish:
name: Build and publish to PyPI
runs-on: ubuntu-26.04
timeout-minutes: 30
environment:
name: pypi
url: https://pypi.org/p/patchradar
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
# same answer four times.
name: Quality
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'release')
runs-on: ubuntu-26.04
timeout-minutes: 10
env:
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.workflow_run.head_branch }}
IMAGE: maksimtech/patchradar
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/security-posture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
# is rerun and succeeds, or on the next push or schedule.
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-26.04
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@v7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-26.04
timeout-minutes: 10
# GitHub passes no Actions secrets to Dependabot or fork PRs: there the
# token is empty and the scan fails with "Not authorized". A step's `if:`
# cannot read `secrets`, so the job publishes only whether it exists; the
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:
jobs:
test:
runs-on: ubuntu-26.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -83,6 +84,7 @@ jobs:
needs: [test]
if: always()
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: All test jobs succeeded
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ permissions:
jobs:
trivy:
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Expand Down Expand Up @@ -42,6 +43,7 @@ jobs:
image:
name: Trivy image
runs-on: ubuntu-26.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ what has already shipped, and for nothing else. See `RELEASING.md`.

## [Unreleased]

### Changed

- **Every job has a time limit, so a hung job no longer holds a pull request for six hours.** No job
but mutmut set `timeout-minutes`, and GitHub's default is 360 minutes; on a required check the pull
request, and the auto-merge this repository allows, waited that long. Each limit is about three
times the job's longest run in its last 40 (ten minutes at least): 25 for the benchmarks, 20 for the
published image, 10 for the rest. Two jobs wait on purpose and get more than their runs suggest, so
they still say what they were waiting for: Security Posture 40, past the 20 minutes it waits for the
scanners and three times its longest run, and publishing 30, past the 15 minutes it waits for PyPI to
show and install the new version; the test reads both waits from the workflows
(`tests/test_job_timeouts.py`, maksimtech/apkradar#113).

### Security

- **CVE-2026-124709 (OpenSSL, QUIC) stays accepted now that Trivy reports it too.** Debian moved trixie
Expand Down
72 changes: 72 additions & 0 deletions tests/test_job_timeouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Every job says how long it may run, so a hung job cannot hold a pull request for six hours.

Without `timeout-minutes` a job runs for GitHub's default of 360 minutes. When it is a
required check the pull request waits that long, and so would an auto-merge
(maksimtech/apkradar#113).

The limits are about three times the longest run of the job in its last 40 runs
(2026-11-21), and never under ten minutes: a short job is mostly installs and image pulls,
which are slow on a bad day without being stuck.

A job that waits on purpose gets more than its runs suggest: its limit has to outlast its
own wait, or GitHub kills it before it can say what it was waiting for. The tests below
read those waits from the workflows, so a longer wait cannot outgrow its limit unseen.
"""
from __future__ import annotations

import re
from pathlib import Path

import yaml

WORKFLOWS = Path(__file__).resolve().parents[1] / ".github" / "workflows"
GITHUB_DEFAULT = 360


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


def script(job: dict) -> str:
return "\n".join(step.get("run", "") for step in job.get("steps", []))


def test_there_are_jobs_to_look_at():
assert len(list(jobs())) > 10


def test_every_job_declares_a_timeout_below_the_default():
# A job that calls a reusable workflow cannot take `timeout-minutes`; the jobs of the
# workflow it calls are held here like any other.
wrong = {name: job.get("timeout-minutes") for name, job in jobs()
if "uses" not in job
and not (isinstance(job.get("timeout-minutes"), int) and 0 < job["timeout-minutes"] < GITHUB_DEFAULT)}
assert wrong == {}, f"jobs without a timeout under {GITHUB_DEFAULT} minutes: {wrong}"


def test_security_posture_outlives_its_own_wait():
# The gate waits for the scanners up to a deadline of its own and then says they did not
# finish. A job timeout shorter than that would kill it first, with no such message.
job = dict(jobs())["security-posture.yml:posture"]
wait = int(re.search(r"deadline=\$\(\( SECONDS \+ (\d+) \)\)", script(job)).group(1))
assert job["timeout-minutes"] * 60 >= wait + 5 * 60


def test_publishing_outlives_its_waits_for_pypi():
# After the upload the job installs the new version, asking again while the index
# catches up (install_from_pypi.sh: attempts x interval), and in the Radars that call it,
# first waits for the index to show it (wait_for_pypi.sh: attempts x interval, then a
# grace). A limit under those would end the job before either could say the version is
# not there. Ten more minutes for what the job does besides sleeping.
job = dict(jobs())["publish.yml:build-and-publish"]
run = script(job)
install = re.search(r'install_from_pypi\.sh \S+ \S+ "\$VERSION" (\d+) (\d+)', run)
assert install, "publish.yml no longer calls install_from_pypi.sh as this test reads it"
seconds = int(install[1]) * int(install[2])
wait = re.search(r'wait_for_pypi\.sh \S+ "\$VERSION" (\d+) (\d+)(?: (\d+))?', run)
if wait:
seconds += int(wait[1]) * int(wait[2]) + int(wait[3] or 45)
assert job["timeout-minutes"] * 60 >= seconds + 10 * 60