Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
ci: a labelled pull request runs the four required cells; a draft runs nothing (#1685)
Alpamys Makazhan7881bfde92e4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bbc40596..6219591e 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -9,9 +9,10 @@ on:branches: [main, 'release/**']pull_request:branches: [main]- # The first three are GitHub's defaults. `labeled` is what starts the full- # matrix when a maintainer adds `ci:full` (see the comment above the `plan`- # job); it stays a plain pull_request run -- never pull_request_target.+ # The first three are GitHub's defaults. `ready_for_review` is a draft's first+ # run: a draft pull request runs nothing. `labeled` is what starts the approval+ # run when a maintainer adds `ci:full`. Both are in the comment above the+ # `plan` job. It stays a plain pull_request run -- never pull_request_target.types: [opened, synchronize, reopened, ready_for_review, labeled]# The full matrix on `main`, once a night: a push to `main` itself runs only the# quick set (see the comment above the `plan` job). `workflow_dispatch` lets a@@ -119,7 +120,8 @@ concurrency:# save runner-minutes that are only ever spent when a job is already hung.jobs:- # Quick runs, the full matrix at approval, and every cell on a release branch.+ # Quick runs, the required cells at approval, the full matrix every night, and+ # every cell on a release branch.## Measured 2026-09-28 07:30Z: the Actions account sat at its free-plan cap of# 20 concurrent jobs (8 ubuntu, 8 windows, 4 macos running) with 301 jobs@@ -127,16 +129,19 @@ jobs:# nine test cells plus lint, type-check, mlx-smoke, torchao-contract,# pytorch-smoke and transformers-floor.#- # So `plan` picks one of three matrices, and every job except `lint` follows it:+ # So `plan` picks one of four matrices, and every job except `lint` follows it:## push to release/** RELEASE: all nine test cells + the five gated jobs# nightly run on main, a manual FULL: seven test cells (no Windows or macOS- # dispatch, or a pull request on 3.11) + the five gated jobs- # labelled ci:full+ # dispatch on 3.11) + the five gated jobs+ # pull request labelled ci:full APPROVAL: the four required test cells (ubuntu+ # on 3.10 and 3.12, Windows and macOS on+ # 3.12) + the five gated jobs# push to main, any other pull QUICK: lint + test (ubuntu-latest, 3.12)# request run+ # draft pull request nothing: no job starts#- # 3.11 runs on ubuntu in every full run, and on Windows and macOS only for+ # 3.11 runs on ubuntu in every FULL run, and on Windows and macOS only for# release/**, where the release checklist needs every cell green on the tagged# commit. Measured basis (soup-97): macOS was the binding limit 63% of the# time, and dropping the two cells takes a full run from 4 macOS jobs to 3@@ -144,52 +149,75 @@ jobs:# windows-3.11 alone, and a failure like that now surfaces on the release# branch instead of before merge. Branch protection requires neither cell.#+ # 2026-10-07: a labelled pull request runs APPROVAL, no longer FULL. An approval+ # run was seven test cells, two of them on macOS, the binding limit above; it is+ # four, one on macOS. What it gives up: a failure that exists only on ubuntu+ # 3.11, Windows 3.10 or macOS 3.10 is not caught before merge and shows on+ # `main` in the next nightly run instead. Branch protection must not require+ # any of the three: they come off it together with this change.+ ## A quick push costs 3 jobs (lint, plan, one ubuntu cell) instead of 15, and# none of them on Windows or macOS. A maintainer adds `ci:full` at approval.# The pull request's current labels decide, not the event, so every run on a- # labelled pull request is full -- including each later push, which a merge on- # the current head needs anyway. Remove the label to go back to quick runs. A+ # labelled pull request is an approval run -- including each later push, which+ # a merge on the current head needs anyway. Remove the label to go back to+ # quick runs. A# labelled run is an ordinary pull_request run, with the token and secrets a# push to that pull request already gets.## What this costs, and why the merge gate still holds:## - Contributors see only ubuntu / Python 3.12 until approval. A failure that- # exists only on Windows, macOS, 3.10 or 3.11 surfaces at approval (on the- # release branch, for Windows and macOS on 3.11), so that round trip starts- # later than it used to.+ # exists only on Windows, macOS or 3.10 surfaces at approval, so that round+ # trip starts later than it used to. One that needs ubuntu on 3.11, or Windows+ # or macOS on 3.10, surfaces after the merge, in the nightly run; one that+ # needs Windows or macOS on 3.11, on the release branch.# - The required smokes (mlx-smoke, pytorch-smoke, transformers-floor) read as# SKIPPED on a quick run, and branch protection counts a job skipped by its# `if:` as passing. So the smokes are not what blocks a merge; the test cells# are. `test` takes its matrix from `plan`, so a quick run never CREATES the- # other six required `test (...)` contexts, and a required context nothing+ # other three required `test (...)` contexts, and a required context nothing# reported stays "Expected" and keeps the merge button locked. Do not turn the# matrix back into a static list with a per-cell `if:`: a skipped cell passes.- # For the same reason FULL and branch protection must name the same cells: a- # required cell FULL drops is never reported and locks every merge, and a FULL- # cell that is not required gates nothing.- # - Maintainers merge only when all 11 required checks read SUCCESS on the- # current head. Skipped is not success: a quick run after a full one on the+ # For the same reason APPROVAL and branch protection must name the same+ # cells: a required cell APPROVAL drops is never reported and locks every+ # merge, and an APPROVAL cell that is not required gates nothing.+ # - Maintainers merge only when all 8 required checks read SUCCESS on the+ # current head. Skipped is not success: a quick run after an approval run on the# same head (say the label was removed and another one added) replaces the# smokes' results, a failure included, with skipped -- which the merge button# accepts.# - Adding any other label to a pull request that already carries `ci:full`- # starts a second full run, in a concurrency group of its own so it cannot+ # starts a second approval run, in a concurrency group of its own so it cannot# cancel the first, and no later push cancels it either. Add other labels# before `ci:full`.- # - Coverage uploads from the ubuntu / 3.11 cell only, so a pull request's- # Codecov report arrives at approval.+ # - Coverage uploads from the ubuntu / 3.10 cell only -- the ubuntu cell every+ # gated run has and a quick run does not -- so a pull request's Codecov report+ # arrives at approval.+ # - A draft pull request runs nothing: `plan` and `lint` are skipped by their+ # own `if:`, and every other job needs `plan`. The merge gate holds for the+ # reason above -- the required `test (...)` contexts are never created -- and+ # GitHub does not merge a draft in any case. Marking it ready+ # (`ready_for_review`) starts the quick run, or the approval run if it already+ # carries the label. Converting a pull request back to a draft does not stop a+ # run in progress. A job added here must need `plan` and must not call a+ # status function (`always()`, `failure()`, ...) in its `if:`, or it runs on+ # drafts.## `timeout-minutes: 5` is not a measurement: one shell step, no checkout, no# install.plan:+ # Everything but a draft pull request. `lint` carries the same condition, and+ # every other job needs `plan`, so it is skipped with it.+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == falseruns-on: ubuntu-latesttimeout-minutes: 5env:- # The three matrices, each declared once as a JSON literal the tests parse.+ # The four matrices, each declared once as a JSON literal the tests parse.# RELEASE is the support matrix, every cell: tests/test_requires_python_bound.py# derives requires-python from it. FULL is RELEASE minus Windows and macOS on- # 3.11, and tests/test_ci_full_matrix_on_approval.py pins it to exactly the+ # 3.11. APPROVAL is the oldest and the newest Python, the oldest on ubuntu+ # only, and tests/test_ci_full_matrix_on_approval.py pins it to exactly the# required `test (...)` contexts. QUICK is one required cell. Keep the key# order (it names the checks) and the versions as strings (a JSON 3.10 is 3.1).RELEASE_MATRIX: >-@@ -200,16 +228,22 @@ jobs:"python-version": ["3.10", "3.11", "3.12"],"exclude": [{"os": "windows-latest", "python-version": "3.11"},{"os": "macos-latest", "python-version": "3.11"}]}+ APPROVAL_MATRIX: >-+ {"os": ["ubuntu-latest", "windows-latest", "macos-latest"],+ "python-version": ["3.10", "3.12"],+ "exclude": [{"os": "windows-latest", "python-version": "3.10"},+ {"os": "macos-latest", "python-version": "3.10"}]}QUICK_MATRIX: '{"os": ["ubuntu-latest"], "python-version": ["3.12"]}'outputs:full: ${{ steps.decide.outputs.full }}matrix: ${{ steps.decide.outputs.matrix }}steps:- - name: Choose the release, full or quick matrix+ - name: Choose the release, full, approval or quick matrixid: decideenv:RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') }}- FULL: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full')) }}+ FULL: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) }}+ APPROVAL: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full') }}run: |set -euo pipefailif [ "$RELEASE" = "true" ]; then@@ -218,6 +252,9 @@ jobs:elif [ "$FULL" = "true" ]; thenfull=truematrix="$FULL_MATRIX"+ elif [ "$APPROVAL" = "true" ]; then+ full=true+ matrix="$APPROVAL_MATRIX"elsefull=falsematrix="$QUICK_MATRIX"@@ -229,6 +266,8 @@ jobs:} >> "$GITHUB_OUTPUT"lint:+ # Skipped on a draft pull request, like `plan`: see the comment above `plan`.+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == falseruns-on: ubuntu-latesttimeout-minutes: 15steps:@@ -494,10 +533,11 @@ jobs:needs: planstrategy:fail-fast: false- # From `plan`: all nine cells on a push to release/**, seven on a full run- # (no Windows or macOS 3.11), test (ubuntu-latest, 3.12) alone on a quick- # one. The cells a run leaves out are MISSING, not skipped, and that is what- # keeps a required one blocking a merge.+ # From `plan`: all nine cells on a push to release/**, seven on the nightly+ # run and a manual dispatch (no Windows or macOS 3.11), the four required+ # ones on a labelled pull request, test (ubuntu-latest, 3.12) alone on a+ # quick one. The cells a run leaves out are MISSING, not skipped, and that+ # is what keeps a required one blocking a merge.matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}runs-on: ${{ matrix.os }}timeout-minutes: 90@@ -640,7 +680,10 @@ jobs:- name: Run unit tests with coveragerun: pytest tests/ -v --tb=short --junitxml=report.xml --cov=soup_cli --cov-report=xml:coverage.xml --cov-report=term-missing:skip-covered- name: Upload coverage to Codecov- if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'+ # ubuntu / 3.10 is the ubuntu cell every gated run has (release, full,+ # approval) and a quick run does not. It was 3.11 until the approval run+ # stopped having that cell.+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'uses: codecov/codecov-action@v4with:files: coverage.xmldiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 1a8d7ce7..3eca3972 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -379,8 +379,9 @@ released as a penalty.- **A quiet pull request.** A pull request waiting on its author for 14 days gets a pingin the thread. If another 7 days pass, we close it with a note that it can be reopenedat any time.-- **Full CI.** The full test matrix runs when a maintainer adds the `ci:full` label to a+- **Full CI.** The required test cells run when a maintainer adds the `ci:full` label to apull request that is ready to merge, not on every push; other pushes run a quick subset.+ A draft pull request runs no CI at all until you mark it ready for review.### Issue difficulty@@ -553,14 +554,19 @@ GitHub Actions runs on every push and PR:required check and blocks nothing.**Pull requests run a quick subset first.** A push to a pull request runs `lint`-and the tests on Ubuntu / Python 3.12 only. The full matrix (Windows and macOS-as well as Ubuntu, Python 3.10 to 3.12 with 3.11 on Ubuntu only, plus the smoke-jobs) runs when a maintainer adds the `ci:full` label at approval, and on every-later push while the label stays. Until then the other `test (...)` checks show-as *Expected* and the smoke jobs as *skipped*; neither is a failure on your side.-A PR is merged only when the full matrix is green on its current head. After the-merge, `main` runs the same quick set on every commit and the full matrix once a-night (and on every push to a `release/**` branch).+and the tests on Ubuntu / Python 3.12 only. The required cells (Ubuntu on Python+3.10 and 3.12, Windows and macOS on 3.12, plus the smoke jobs) run when a+maintainer adds the `ci:full` label at approval, and on every later push while+the label stays. Until then the other `test (...)` checks show as *Expected* and+the smoke jobs as *skipped*; neither is a failure on your side. A PR is merged+only when those checks are green on its current head. After the merge, `main`+runs the same quick set on every commit and the full matrix (every Python from+3.10 to 3.12, with 3.11 on Ubuntu only) once a night; a push to a `release/**`+branch runs every cell.++**A draft pull request runs no CI.** Nothing starts while a pull request is a+draft, whatever is pushed to it. Mark it ready for review and the quick set+starts on its current head.See `.github/workflows/ci.yml`.diff --git a/tests/test_ci_full_matrix_on_approval.py b/tests/test_ci_full_matrix_on_approval.pyindex 31b6935f..0fa7818d 100644--- a/tests/test_ci_full_matrix_on_approval.py+++ b/tests/test_ci_full_matrix_on_approval.py@@ -1,25 +1,32 @@-"""A pull-request push runs a quick CI subset; the full matrix runs at approval.+"""A pull-request push runs a quick CI subset; the required cells run at approval.Measured 2026-09-28 07:30Z: the Actions account sat at its free-plan cap of 20concurrent jobs (8 ubuntu, 8 windows, 4 macos) with 301 jobs queued, and everypush to a pull request cost 15 jobs of ``ci.yml``. So ``plan`` picks one of-three matrices by event:+four matrices by event:* RELEASE, every cell of the 3x3 support matrix, for pushes to ``release/**``-- the release checklist needs all of them green on the tagged commit;-* FULL, the same minus Windows and macOS on 3.11, for the nightly run on ``main``,- a manual dispatch, and pull requests a maintainer has labelled ``ci:full``;+* FULL, the same minus Windows and macOS on 3.11, for the nightly run on ``main``+ and a manual dispatch;+* APPROVAL, the four cells branch protection requires (the oldest and the newest+ Python on ubuntu, the newest on Windows and macOS), for pull requests a+ maintainer has labelled ``ci:full``;* QUICK, ``test (ubuntu-latest, 3.12)`` alone, for a push to ``main`` and for anyother pull-request run.+A draft pull request runs nothing at all: ``plan`` and ``lint`` carry the draft+condition, every other job needs ``plan``, and ``ready_for_review`` starts the+first run.+The merge gate survives that because of one shape, and these tests pin it: the``test`` job's matrix is whatever the ``plan`` job outputs, so a quick run never-CREATES the other six required ``test (...)`` contexts. Branch protection+CREATES the other three required ``test (...)`` contexts. Branch protectionpasses a skipped job and waits on a missing one, so it is the missing cells ---not the skipped smokes -- that keep the merge button locked until the full-matrix has run. FULL must name exactly the required contexts: a cell it drops-that branch protection still requires would lock every merge, and a required-cell it drops silently would stop being tested before merge at all.+not the skipped smokes -- that keep the merge button locked until the approval+run has reported. APPROVAL must name exactly the required contexts: a cell it+drops that branch protection still requires would lock every merge, and a+required cell it drops silently would stop being tested before merge at all.Nothing here talks to GitHub. The workflow is read as YAML, the ``plan`` step'sshell runs under a local bash, and the expressions GitHub would evaluate are@@ -63,25 +70,40 @@ FULL_EXCLUDE = ({"os": "windows-latest", "python-version": "3.11"},{"os": "macos-latest", "python-version": "3.11"},)+#: What APPROVAL leaves out of its two Pythons: the oldest runs on ubuntu only.+APPROVAL_EXCLUDE = (+ {"os": "windows-latest", "python-version": "3.10"},+ {"os": "macos-latest", "python-version": "3.10"},+)QUICK_MATRIX = {"os": ["ubuntu-latest"], "python-version": ["3.12"]}-#: The seven ``test`` contexts branch protection on ``main`` requires, read on-#: 2026-09-28 with ``gh api repos/MakazhanAlpamys/Soup/branches/main/protection/-#: required_status_checks`` after the owner dropped Windows and macOS 3.11 (11-#: required checks: these plus lint, mlx-smoke, pytorch-smoke, transformers-floor).-#: A cell named any other way is a context nobody waits on.+#: The four ``test`` contexts a merge waits on: what APPROVAL runs, and what branch+#: protection on ``main`` must list (8 required checks: these plus lint, mlx-smoke,+#: pytorch-smoke, transformers-floor). Read on 2026-10-07 with ``gh api+#: repos/MakazhanAlpamys/Soup/branches/main/protection``, it still listed the seven+#: cells of FULL; the three in NIGHTLY_ONLY_CONTEXTS come off it right after this+#: change merges, never before. A cell named any other way is a context nobody waits on.REQUIRED_TEST_CONTEXTS = frozenset({"test (ubuntu-latest, 3.10)",- "test (ubuntu-latest, 3.11)","test (ubuntu-latest, 3.12)",- "test (windows-latest, 3.10)","test (windows-latest, 3.12)",- "test (macos-latest, 3.10)","test (macos-latest, 3.12)",})+#: The three cells only the nightly run, a manual dispatch and ``release/**`` run. A+#: failure that exists on one of them alone shows on ``main`` the next night.+NIGHTLY_ONLY_CONTEXTS = frozenset(+ {+ "test (ubuntu-latest, 3.11)",+ "test (windows-latest, 3.10)",+ "test (macos-latest, 3.10)",+ }+)#: The two cells only a push to ``release/**`` runs. Not required, so not a merge gate.RELEASE_ONLY_CONTEXTS = frozenset({"test (windows-latest, 3.11)", "test (macos-latest, 3.11)"})+#: The condition on the two jobs that wait for nothing: everything but a draft pull request.+DRAFT_GATE = "github.event_name != 'pull_request' || github.event.pull_request.draft == false"+UNGATED_JOBS = ("plan", "lint")# --- Reading the workflow ----------------------------------------------------@@ -120,7 +142,7 @@ def _decide_step() -> dict[str, Any]:return steps[0]-MATRIX_NAMES = ("RELEASE_MATRIX", "FULL_MATRIX", "QUICK_MATRIX")+MATRIX_NAMES = ("RELEASE_MATRIX", "FULL_MATRIX", "APPROVAL_MATRIX", "QUICK_MATRIX")def _literal(name: str) -> str:@@ -135,15 +157,15 @@ def _matrix(name: str) -> dict[str, Any]:return json.loads(_literal(name))-def _cells(matrix: dict[str, Any]) -> set[str]:- """The ``test (...)`` contexts GitHub creates for *matrix*.+def _cell_dicts(matrix: dict[str, Any]) -> list[dict[str, str]]:+ """The cells GitHub creates for *matrix*, each as a ``matrix`` context.- The product of the two axes, titled with the values in key order (os first),- minus every cell an ``exclude`` entry matches -- GitHub excludes on a PARTIAL- match, so ``{"python-version": "3.11"}`` alone would drop all three 3.11 cells.+ The product of the two axes minus every cell an ``exclude`` entry matches --+ GitHub excludes on a PARTIAL match, so ``{"python-version": "3.11"}`` alone+ would drop all three 3.11 cells."""assert set(matrix) <= {"os", "python-version", "exclude"}, sorted(matrix)- names = set()+ cells = []for runner in matrix["os"]:for python in matrix["python-version"]:cell = {"os": runner, "python-version": python}@@ -152,8 +174,13 @@ def _cells(matrix: dict[str, Any]) -> set[str]:for rule in matrix.get("exclude", [])):continue- names.add(f"test ({runner}, {python})")- return names+ cells.append(cell)+ return cells+++def _cells(matrix: dict[str, Any]) -> set[str]:+ """The ``test (...)`` contexts of *matrix*, titled with the values in key order."""+ return {f"test ({cell['os']}, {cell['python-version']})" for cell in _cell_dicts(matrix)}def _rules(entries: Any) -> list[tuple[tuple[str, Any], ...]]:@@ -370,12 +397,14 @@ def _pull_request(*,labels: tuple[str, ...] = (),label: str | None = None,+ draft: bool = False,run_id: str = "100",) -> dict[str, Any]:"""A pull_request context shaped like GitHub's payload.On ``labeled``, ``event.label`` is the label just added and- ``event.pull_request.labels`` already includes it.+ ``event.pull_request.labels`` already includes it. ``event.pull_request.draft``+ is a boolean on every pull_request event."""names = list(labels)event: dict[str, Any] = {"action": action, "number": 7}@@ -383,7 +412,7 @@ def _pull_request(event["label"] = {"name": label}if label not in names:names.append(label)- event["pull_request"] = {"labels": [{"name": name} for name in names]}+ event["pull_request"] = {"labels": [{"name": name} for name in names], "draft": draft}return {"github": {"workflow": "CI",@@ -408,6 +437,21 @@ def _release_for(context: dict[str, Any]) -> str:return _render(_decide_step()["env"]["RELEASE"], context)+def _approval_for(context: dict[str, Any]) -> str:+ expression = _decide_step()["env"].get("APPROVAL")+ assert isinstance(expression, str), "the decide step must compute APPROVAL in its env"+ return _render(expression, context)+++def _runs(job: str, context: dict[str, Any]) -> bool:+ """Whether *job* starts for *context*: its job-level ``if:``, true when it has none."""+ return _truthy(_Expression(str(_jobs()[job].get("if", "true")), context).value())+++#: A job-level ``if:`` that calls one of these runs even when a job it needs was skipped.+_STATUS_FUNCTION = re.compile(r"\b(?:always|cancelled|failure|success)\s*\(")++#: Which matrix each event must get: the one table both the expression tests and#: the end-to-end run of the step's shell read.EVENTS = [@@ -417,16 +461,29 @@ EVENTS = [pytest.param(_push("refs/heads/release/v0.76.0"), "RELEASE", id="push-release"),pytest.param(_pull_request("opened"), "QUICK", id="pr-opened"),pytest.param(_pull_request("synchronize", labels=("bug",)), "QUICK", id="pr-push-other-label"),- pytest.param(_pull_request("synchronize", labels=("bug", LABEL)), "FULL", id="pr-push-ci-full"),- pytest.param(_pull_request("labeled", label=LABEL), "FULL", id="adds-ci-full"),+ pytest.param(+ _pull_request("synchronize", labels=("bug", LABEL)), "APPROVAL", id="pr-push-ci-full"+ ),+ pytest.param(_pull_request("labeled", label=LABEL), "APPROVAL", id="adds-ci-full"),pytest.param(_pull_request("labeled", label="bug"), "QUICK", id="adds-other"),pytest.param(_pull_request("labeled", label="bug", labels=(LABEL,)),- "FULL",+ "APPROVAL",id="adds-other-while-ci-full",),]+#: A draft pull request, whatever starts the run and whatever it is labelled.+DRAFTS = [+ pytest.param(_pull_request("opened", draft=True), id="draft-opened"),+ pytest.param(_pull_request("synchronize", draft=True), id="draft-push"),+ pytest.param(_pull_request("reopened", draft=True), id="draft-reopened"),+ pytest.param(_pull_request("labeled", label=LABEL, draft=True), id="draft-adds-ci-full"),+ pytest.param(+ _pull_request("synchronize", labels=(LABEL,), draft=True), id="draft-push-ci-full"+ ),+]+# --- Tests -------------------------------------------------------------------@@ -496,11 +553,12 @@ class TestTriggers:class TestPlanDecision:- def test_plan_is_short_unconditional_and_exports_its_decision(self):+ def test_plan_is_short_waits_for_nothing_and_exports_its_decision(self):plan = _plan()assert plan["runs-on"] == "ubuntu-latest"assert plan["timeout-minutes"] == 5- assert "if" not in plan and "needs" not in plan+ assert plan.get("if") == DRAFT_GATE, "plan decides for everything but a draft"+ assert "needs" not in planassert plan["outputs"] == {"full": "${{ steps.decide.outputs.full }}","matrix": "${{ steps.decide.outputs.matrix }}",@@ -508,10 +566,12 @@ class TestPlanDecision:@pytest.mark.parametrize(("context", "kind"), EVENTS)def test_the_decision_follows_the_event_and_the_current_labels(self, context, kind):- """RELEASE only for a push to release/**; FULL for any other push and for a pull- request whose CURRENT labels carry ci:full, whichever event started the run."""+ """RELEASE only for a push to release/**; FULL for that, the nightly run and a+ manual dispatch; APPROVAL for a pull request whose CURRENT labels carry ci:full,+ whichever event started the run."""assert _release_for(context) == ("true" if kind == "RELEASE" else "false")- assert _full_for(context) == ("false" if kind == "QUICK" else "true")+ assert _full_for(context) == ("true" if kind in ("RELEASE", "FULL") else "false")+ assert _approval_for(context) == ("true" if kind == "APPROVAL" else "false")class TestTheBadgeStep:@@ -535,9 +595,9 @@ class TestGatedJobs:assert "plan" in _needs(job), f"{name} does not need plan"assert job.get("if") == GATE, f"{name} is not gated on plan's decision"- def test_lint_always_runs_and_waits_for_nothing(self):+ def test_lint_waits_for_nothing_and_skips_only_a_draft(self):lint = _jobs()["lint"]- assert "if" not in lint+ assert lint.get("if") == DRAFT_GATEassert "needs" not in lintdef test_every_job_is_classified(self):@@ -574,11 +634,29 @@ class TestMatrix:# such as {"python-version": "3.11"} would drop the ubuntu cell too).assert _cells(_matrix("RELEASE_MATRIX")) - _cells(full) == RELEASE_ONLY_CONTEXTS- def test_full_names_exactly_the_required_test_contexts(self):- assert _cells(_matrix("FULL_MATRIX")) == REQUIRED_TEST_CONTEXTS-- def test_release_runs_every_required_cell_and_the_two_full_skips(self):- assert _cells(_matrix("RELEASE_MATRIX")) == REQUIRED_TEST_CONTEXTS | RELEASE_ONLY_CONTEXTS+ def test_approval_is_the_oldest_and_newest_python_with_the_oldest_on_ubuntu_only(self):+ approval = _matrix("APPROVAL_MATRIX")+ assert list(approval) == ["os", "python-version", "exclude"], (+ "the key order names the checks"+ )+ assert approval["os"] == SUPPORT_MATRIX["os"]+ pythons = SUPPORT_MATRIX["python-version"]+ assert approval["python-version"] == [+ min(pythons, key=_version),+ max(pythons, key=_version),+ ]+ assert _rules(approval["exclude"]) == _rules(APPROVAL_EXCLUDE)++ def test_approval_names_exactly_the_required_test_contexts(self):+ assert _cells(_matrix("APPROVAL_MATRIX")) == REQUIRED_TEST_CONTEXTS++ def test_full_runs_every_required_cell_and_the_three_nightly_ones(self):+ assert _cells(_matrix("FULL_MATRIX")) == REQUIRED_TEST_CONTEXTS | NIGHTLY_ONLY_CONTEXTS++ def test_release_runs_every_cell_a_smaller_matrix_leaves_out(self):+ assert _cells(_matrix("RELEASE_MATRIX")) == (+ REQUIRED_TEST_CONTEXTS | NIGHTLY_ONLY_CONTEXTS | RELEASE_ONLY_CONTEXTS+ )def test_the_quick_matrix_is_the_newest_python_on_ubuntu(self):quick = _matrix("QUICK_MATRIX")@@ -648,7 +726,7 @@ class TestConcurrency:start a quick run or cancel nothing -- both silently."""event = _pull_request("labeled", label=label)joins = _group(event) == _group(_pull_request("synchronize"))- assert joins == (_full_for(event) == "true")+ assert joins == (_approval_for(event) == "true")def _posix_bash() -> str | None:@@ -677,7 +755,9 @@ BASH = _posix_bash()class TestTheDecideStepScript:"""Run the plan step's own shell, as the runner would, against a fake $GITHUB_OUTPUT."""- def _outputs(self, tmp_path: Path, *, release: str, full: str) -> tuple[str, Any]:+ def _outputs(+ self, tmp_path: Path, *, release: str, full: str, approval: str+ ) -> tuple[str, Any]:"""Run the step with the given decision values; return (full, parsed matrix)."""assert BASH is not Noneoutput = tmp_path / "github_output"@@ -689,6 +769,7 @@ class TestTheDecideStepScript:**{name: _literal(name) for name in MATRIX_NAMES},"RELEASE": release,"FULL": full,+ "APPROVAL": approval,"GITHUB_OUTPUT": output.as_posix(),}result = subprocess.run(@@ -712,28 +793,94 @@ class TestTheDecideStepScript:def test_each_event_gets_its_matrix(self, tmp_path, context, kind):"""End to end: the event, through GitHub's expressions, through the shell."""full, matrix = self._outputs(- tmp_path, release=_release_for(context), full=_full_for(context)+ tmp_path,+ release=_release_for(context),+ full=_full_for(context),+ approval=_approval_for(context),)assert matrix == _matrix(f"{kind}_MATRIX")assert full == ("false" if kind == "QUICK" else "true")@pytest.mark.parametrize(- ("release", "full", "kind"),+ ("release", "full", "approval", "kind"),[- ("false", "false", "QUICK"),- ("false", "", "QUICK"),- ("false", "yes", "QUICK"),- ("", "true", "FULL"),- ("yes", "true", "FULL"),+ ("false", "false", "false", "QUICK"),+ ("false", "", "", "QUICK"),+ ("false", "yes", "yes", "QUICK"),+ ("", "true", "false", "FULL"),+ ("yes", "true", "false", "FULL"),+ ("false", "false", "true", "APPROVAL"),+ ("yes", "", "true", "APPROVAL"),+ ("false", "true", "true", "FULL"),],)- def test_only_the_exact_string_true_selects(self, tmp_path, release, full, kind):+ def test_only_the_exact_string_true_selects(self, tmp_path, release, full, approval, kind):"""Quick is the fail-closed answer on a pull request: fewer cells, more missing- required contexts, a locked merge button."""- flag, matrix = self._outputs(tmp_path, release=release, full=full)+ required contexts, a locked merge button. Of two that are set, the larger wins."""+ flag, matrix = self._outputs(tmp_path, release=release, full=full, approval=approval)assert matrix == _matrix(f"{kind}_MATRIX")assert flag == ("false" if kind == "QUICK" else "true")+class TestADraftRunsNothing:+ """A draft costs no runner: the two jobs that wait for nothing are skipped by their+ own condition, and every other job needs ``plan``."""++ @pytest.mark.parametrize("job", UNGATED_JOBS)+ @pytest.mark.parametrize("context", DRAFTS)+ def test_a_draft_starts_neither_plan_nor_lint(self, job, context):+ assert not _runs(job, context)++ @pytest.mark.parametrize("job", UNGATED_JOBS)+ @pytest.mark.parametrize(("context", "kind"), EVENTS)+ def test_everything_that_is_not_a_draft_still_starts_them(self, job, context, kind):+ assert _runs(job, context), kind++ def test_marking_it_ready_starts_the_first_run(self):+ assert "ready_for_review" in _triggers()["pull_request"].get("types", [])+ ready = _pull_request("ready_for_review")+ assert all(_runs(job, ready) for job in UNGATED_JOBS)++ def test_every_other_job_is_skipped_with_plan(self):+ """A job whose `if:` calls a status function runs even when the job it needs was+ skipped, which is how one of these would start on a draft."""+ for name, job in _jobs().items():+ if name in UNGATED_JOBS:+ continue+ assert "plan" in _needs(job), f"{name} does not need plan"+ condition = str(job.get("if", ""))+ assert not _STATUS_FUNCTION.search(condition), f"{name}: {condition}"+++class TestCoverageUpload:+ def test_one_cell_of_every_gated_run_uploads_and_a_quick_run_uploads_nothing(self):+ """The upload is pinned to one cell. Pinned to a cell the approval run does not+ have, it would stop every pull request's Codecov report without a red mark."""+ steps = _jobs()["test"]["steps"]+ upload = [step for step in steps if step.get("name") == "Upload coverage to Codecov"]+ assert len(upload) == 1, upload+ condition = str(upload[0].get("if", ""))++ def uploading(name: str) -> list[dict[str, str]]:+ return [+ cell+ for cell in _cell_dicts(_matrix(name))+ if _truthy(_Expression(condition, {"matrix": cell}).value())+ ]++ for name in ("APPROVAL_MATRIX", "FULL_MATRIX", "RELEASE_MATRIX"):+ assert len(uploading(name)) == 1, (name, uploading(name))+ assert uploading("QUICK_MATRIX") == []+++def _contributing() -> str:+ """CONTRIBUTING.md with its line wrapping collapsed."""+ return " ".join(CONTRIBUTING.read_text(encoding="utf-8").split())++def test_contributing_tells_contributors_about_the_label():- assert f"`{LABEL}`" in CONTRIBUTING.read_text(encoding="utf-8")+ assert f"`{LABEL}`" in _contributing()+++def test_contributing_says_a_draft_runs_no_ci():+ assert "A draft pull request runs no CI" in _contributing()diff --git a/tests/test_requires_python_bound.py b/tests/test_requires_python_bound.pyindex 0eea5497..6d159b85 100644--- a/tests/test_requires_python_bound.py+++ b/tests/test_requires_python_bound.py@@ -12,8 +12,9 @@ exists to catch. Widening the matrix and widening the bound must happen togetherThe matrix is read from the `plan` job's `RELEASE_MATRIX` literal: the supportmatrix, every cell, which pushes to `release/**` run. The `test` job's own matrix-is whatever `plan` outputs -- FULL (the same minus Windows and macOS on 3.11) or-a single QUICK cell -- which is a run-time choice, not the support statement.+is whatever `plan` outputs -- FULL (the same minus Windows and macOS on 3.11), the+four APPROVAL cells or a single QUICK cell -- which is a run-time choice, not the+support statement."""import json