diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7016bbc..885b6e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ permissions: jobs: test: + # The ruleset of main requires the stable rows under this name + # (tests/test_python_matrix.py). + name: Tests (Python ${{ matrix.python-version }}) runs-on: ubuntu-26.04 timeout-minutes: 10 # id-token: write lets the coverage upload prove to Codecov, through GitHub's @@ -22,10 +25,16 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11", "3.12", "3.13", "3.14"] + # The same list as the classifiers in pyproject.toml, which + # tests/test_python_matrix.py checks. + python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"] experimental: [false] include: - - python-version: "3.15-dev" + # The next Python, from its development branch, allowed to fail and + # never a required check: 3.16.0 ships on 2027-10-05 (PEP 826), and a + # dependency without a wheel for it should show up here first, not + # after the classifier. + - python-version: "3.16-dev" experimental: true continue-on-error: ${{ matrix.experimental }} @@ -83,9 +92,10 @@ jobs: summary: # The branch ruleset needs one check name that survives a change to the - # matrix. The matrix job cannot be it: its contexts carry the Python version - # and the experimental flag — "test (3.11, false)" — so they move whenever - # the matrix does, and a ruleset pinned to them silently stops matching. + # matrix. The matrix job cannot be it alone: its contexts carry the Python + # version — "Tests (Python 3.11)" — so they move whenever the matrix does, + # and a ruleset pinned only to them silently stops matching. The ruleset + # requires this name and each stable row. # # always(): a skipped required check counts as passed, so this has to run # even when the matrix fails, and fail explicitly in that case. diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e16fd..02b31b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,19 @@ what has already shipped, and for nothing else. See `RELEASING.md`. ### Changed +- **Python 3.15 is supported, and 3.16 is the row allowed to fail.** 3.15.0 went final on 2026-10-09; + it moves from the experimental `3.15-dev` row to the stable matrix, the classifiers and the README + badge, and `3.16-dev` takes its place as the one row with `continue-on-error`, as in apkradar. + Nothing tied the matrix to the classifiers before: `tests/test_python_matrix.py` now holds the two + as one list, the `-dev` row as the next minor, and the job name. The matrix jobs report as + `Tests (Python 3.11)` … `Tests (Python 3.16-dev)` rather than `test (3.11, false)`, so main's + ruleset can require each stable row by name. On 3.15 every dependency installs from a published + wheel; nothing is built from source but PatchRadar itself. The `3.16-dev` row is red today, as it + may be, and not at the install: pyyaml, libcst, librt, pydantic-core and setproctitle build from + source there, but every test then errors at setup, because pytest-asyncio 1.5.0 calls + `asyncio.get_event_loop_policy()`, which 3.16 removes. pytest-asyncio 2.0.0a1 handles it + (pytest-dev/pytest-asyncio#1593); the row should turn green with 2.0 final, a major update that + `pytest-asyncio (>=1.4.0,<2.0.0)` does not let in by itself. - **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 diff --git a/README.md b/README.md index 49b82cb..edcd7cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PatchRadar -![Python](https://img.shields.io/badge/python-3.11%20|%203.12%20|%203.13%20|%203.14%20|%203.15--dev-blue) +![Python](https://img.shields.io/badge/python-3.11%20|%203.12%20|%203.13%20|%203.14%20|%203.15%20|%203.16--dev-blue) [![CI](https://github.com/maksimtech/patchradar/actions/workflows/test.yml/badge.svg)](https://github.com/maksimtech/patchradar/actions/workflows/test.yml) [![PyPI](https://img.shields.io/pypi/v/patchradar)](https://pypi.org/project/patchradar/) [![Docker](https://img.shields.io/docker/v/maksimtech/patchradar?label=docker)](https://hub.docker.com/r/maksimtech/patchradar) diff --git a/pyproject.toml b/pyproject.toml index d995a5f..0b16300 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Topic :: Security", "Topic :: System :: Monitoring", ] diff --git a/tests/test_python_matrix.py b/tests/test_python_matrix.py new file mode 100644 index 0000000..4404479 --- /dev/null +++ b/tests/test_python_matrix.py @@ -0,0 +1,72 @@ +"""The Python versions the suite runs on are the ones the package claims. + +test.yml listed its matrix with nothing tying it to the classifiers in +pyproject.toml, and nothing checked the `-dev` row either: when 3.15.0 went +final on 2026-10-09 the classifiers still stopped at 3.14 and 3.15 was still the +row allowed to fail, with no test to say so. The same tests exist in apkradar +(tests/test_ci_dependencies.py), whose matrix the other Radars follow. + +The classifiers are the versions the package says it supports, and the matrix +is where that is checked, so the two are one list. One more row runs the version +after the last stable one, from its development branch, and may fail. A new +Python goes final every October (PEP 602), and a dependency without a wheel for +it should turn up there before the classifier promises it. +""" + +from __future__ import annotations + +import re +import tomllib +from pathlib import Path + +import yaml + +ROOT = Path(__file__).resolve().parents[1] +TEST_WORKFLOW = ROOT / ".github" / "workflows" / "test.yml" +PYPROJECT = ROOT / "pyproject.toml" +CLASSIFIED = re.compile(r"^Programming Language :: Python :: (3\.\d+)$") + + +def _classified_versions() -> list[str]: + data = tomllib.loads(PYPROJECT.read_text(encoding="utf-8")) + found = [m.group(1) for c in data["project"]["classifiers"] if (m := CLASSIFIED.match(c))] + assert found, "pyproject.toml names no Python version" + return found + + +def _test_job() -> dict: + return yaml.safe_load(TEST_WORKFLOW.read_text(encoding="utf-8"))["jobs"]["test"] + + +def _next_minor(version: str) -> str: + major, minor = version.split(".") + return f"{major}.{int(minor) + 1}" + + +def test_the_suite_runs_on_every_version_the_classifiers_claim_and_no_other(): + matrix = _test_job()["strategy"]["matrix"] + # str(): an unquoted 3.10 reaches here as the float 3.1, and is then the + # version the classifier does not name, which is the right outcome. + assert [str(v) for v in matrix["python-version"]] == _classified_versions() + assert matrix.get("experimental") == [False], "the stable rows have to say they are not experimental" + + +def test_the_next_python_runs_as_a_row_that_may_fail(): + job = _test_job() + stable = _classified_versions() + rows = [row for row in job["strategy"]["matrix"].get("include", []) if row.get("experimental") is True] + + assert rows == [{"python-version": f"{_next_minor(stable[-1])}-dev", "experimental": True}], ( + f"the experimental row is the version after {stable[-1]}, from its development branch" + ) + assert job.get("continue-on-error") == "${{ matrix.experimental }}", ( + "the experimental row has to be allowed to fail, and the stable rows must not be" + ) + + +def test_each_row_reports_under_a_name_the_ruleset_can_require(): + """The ruleset of main requires the stable rows by name, "Tests (Python + 3.11)" and so on, as in every Radar. Without a job name GitHub reports the + raw matrix values, "test (3.11, false)", and a renamed row is a required + check that never arrives.""" + assert _test_job()["name"] == "Tests (Python ${{ matrix.python-version }})"