Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

ci: stop per-cell waste (HF warm retry, coverage in one cell, docs-only main pushes, PR-only extras) (#2036)

Alpamys Makazhane79341ef5bd4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0c7329ba..78c25ada 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,6 +7,21 @@ on:
# main, which for a release cut from an older tag is not the tree that
# ships, so a PR run cannot stand in for this one.
branches: [main, 'release/**']
+ # A push that touches only these paths starts no run (a pull request is NOT
+ # filtered: it has no `paths` / `paths-ignore`, so every required context still
+ # reports on every pull request). Measured 2026-10-19 over 7 days: 15 of 131
+ # pushes to main were docs-only credit commits, each a full quick run (about 20
+ # runner-minutes), 303 minutes in all. What it gives up: tests read these paths
+ # (the changelog fragments, CONTRIBUTING.md, CONTRIBUTORS.md, docs/), so a docs-only
+ # push that breaks one of them shows in the nightly run instead of on its own
+ # commit; the same change as a pull request is still tested. `release/**` shares the
+ # filter, which is fine: a release cut carries a version bump and code, never docs
+ # alone, and a docs-only tip can be run by hand with workflow_dispatch.
+ paths-ignore:
+ - 'docs/**'
+ - 'changelog.d/**'
+ - 'CONTRIBUTORS.md'
+ - 'CONTRIBUTING.md'
pull_request:
branches: [main]
# The first three are GitHub's defaults. `ready_for_review` is a draft's first
@@ -136,7 +151,9 @@ jobs:
# dispatch on 3.11) + the six 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 six gated jobs
+ # 3.12) + the four gated jobs that run on a
+ # pull request (not type-check, not
+ # torchao-contract: 2026-10-19, below)
# push to main, any other pull QUICK: lint + test (ubuntu-latest, 3.12)
# request run
# draft pull request nothing: no job starts
@@ -193,7 +210,9 @@ jobs:
# before `ci:full`.
# - 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.
+ # arrives at approval. That cell is also the only one that MEASURES coverage
+ # (2026-10-19), so the 77% floor is enforced there: a quick run has no such cell
+ # and does not check it, while the approval run a merge waits for does.
# - 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
@@ -334,7 +353,11 @@ jobs:
type-check:
needs: plan
- if: needs.plan.outputs.full == 'true'
+ # Not on a pull request, approval run included: it is not a required check and
+ # never fails (see below), so a pull request gained nothing from it. Measured
+ # 2026-10-19: 206 pull-request runs in 7 days, 59 job-minutes. It still runs in
+ # the nightly, manual and release runs.
+ if: needs.plan.outputs.full == 'true' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
# Non-blocking type-check baseline. The codebase adopts annotations
@@ -383,7 +406,11 @@ jobs:
run: pytest -o addopts= -q tests/test_rewind_mlx.py
torchao-contract:
needs: plan
- if: needs.plan.outputs.full == 'true'
+ # Not on a pull request, approval run included: it is not a required check.
+ # Measured 2026-10-19: 206 pull-request runs in 7 days, 421 job-minutes (2.0 each).
+ # It still runs in the nightly, manual and release runs, so a torchao release that
+ # renames a class shows on `main` the next night.
+ if: needs.plan.outputs.full == 'true' && github.event_name != 'pull_request'
# #826: every torchao class Soup names is resolved against the REAL package
# here. The 3x3 matrix cannot do it -- `torchao` is not in `[dev]`, so those
# cells skip these tests, which is how three names torchao never exported
@@ -646,10 +673,13 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- cache: ${{ runner.os == 'Linux' && matrix.python-version == '3.12' && 'pip' || '' }}
- cache-dependency-path: |
- pyproject.toml
- .github/constraints/*.txt
+ # No pip cache (dropped 2026-10-19; it was ubuntu / 3.12 only). Measured over the
+ # last 12 pull-request runs: the cached ubuntu / 3.12 cell spent 0.49 min (0.33
+ # to 0.60) restoring the cache plus 1.54 min installing = 2.03 min, the uncached
+ # ubuntu / 3.10 cell 1.80 min installing, so the cache cost more than it saved.
+ # It also held 6.1 GB of the 8.8 GB the repository uses of its 10 GB Actions
+ # cache (two 3 GB entries, a new one whenever pyproject.toml or a constraints
+ # file changes), which is what evicted the small HF caches.
# The Web UI escaping tests run `safe_html.js` under node, and skip when
# node is absent. Runner images happen to ship one, so the skip would be
# silent: pin it, or the only tests that execute the real escaping logic
@@ -700,8 +730,24 @@ jobs:
# "gpt2" is deliberately unqualified: tests ask for the bare id, which
# caches as models--gpt2. Warming "openai-community/gpt2" instead would
# fill a different directory and every test would still miss.
+ #
+ # 2026-10-19: on macOS and Windows this step failed on `gpt2` in EVERY cell since
+ # about 2026-10-16 17Z -- the Hub answers 404 on
+ # `/api/models/gpt2/xet-read-token/<sha>`, the token the hf_xet download path asks
+ # for, and a 404 is retried like a 429 until the budget runs out. Measured over the
+ # last 12 pull-request runs: 6.3 min per macOS and Windows cell (6.25 to 6.37),
+ # about 57 cells a day = 362 runner-minutes a day, and the cache was never
+ # saved (`warmed` stayed `partial`), so every cell paid it again. Linux never hit it
+ # because its restored cache already held the file. HF_HUB_DISABLE_XET (read by
+ # huggingface_hub's constants.py, in v2.2.0 which the pinned stack installs and in
+ # the newest release) makes `is_xet_available()` false, so the download takes the
+ # plain HTTP path and never asks for that token. The budget below is 120 s, not
+ # 360: it is only ever spent in full when the Hub is refusing a repo, and a step
+ # that cannot warm everything never fails the job anyway.
id: warm
shell: python
+ env:
+ HF_HUB_DISABLE_XET: "1"
run: |
import os
import time
@@ -738,7 +784,7 @@ jobs:
# second. The Hub had cut that runner off for the duration — so
# burning a fresh retry ladder on repo #2 the moment repo #1 gave up
# just spends the budget faster without ever waiting out the block.
- deadline = time.monotonic() + 360
+ deadline = time.monotonic() + 120
pending = list(models)
delay = 10
@@ -787,7 +833,22 @@ jobs:
# 1390 s, macOS 2003 s -> 992 s, with the same tests passing and coverage
# unchanged. `--dist load` hands the tests of one file to several workers
# and is not used: it was no faster, and one timing test failed under it.
+ #
+ # 2026-10-19: coverage is measured in ONE cell, ubuntu / 3.10, the cell that
+ # uploads it. The 77% floor (`--cov-fail-under` in pyproject.toml's `addopts`) is
+ # enforced there; every other cell runs the next step with `--no-cov`, which turns
+ # the tracer and the floor off for it. A coverage floor measured on seven more
+ # cells says nothing the one cell does not, and the tracer slows the suite on all
+ # of them: measured locally, serial, on 147 CLI tests (Python 3.12), 33 s without
+ # coverage and 85 s with it (CI itself is not measured yet). The two steps carry
+ # opposite conditions, so exactly one runs in a cell.
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
run: pytest tests/ -n logical --dist loadfile -v --tb=short --junitxml=report.xml --cov=soup_cli --cov-report=xml:coverage.xml --cov-report=term-missing:skip-covered
+ - name: Run unit tests without coverage
+ # Same options as the step above minus the coverage reports; `--junitxml` stays,
+ # because the nightly test-count badge reads report.xml from ubuntu / 3.11.
+ if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.10'
+ run: pytest tests/ -n logical --dist loadfile -v --tb=short --junitxml=report.xml --no-cov
- name: Upload coverage to Codecov
# 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
diff --git a/.github/workflows/merge-freshness.yml b/.github/workflows/merge-freshness.yml
index 24651c1b..5a6a1afd 100644
--- a/.github/workflows/merge-freshness.yml
+++ b/.github/workflows/merge-freshness.yml
@@ -23,6 +23,9 @@ name: merge freshness
on:
pull_request:
branches: [main]
+ # `ready_for_review` is what starts the first run of a draft pull request: the `gate`
+ # job skips a draft (2026-10-19; see the job).
+ types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [main]
workflow_dispatch:
@@ -40,7 +43,12 @@ concurrency:
jobs:
gate:
- if: github.event_name == 'pull_request'
+ # A pull request that is not a draft: a draft is not merged, so its freshness is
+ # not worth a runner. Measured 2026-10-19 over 7 days: 70 runs on a head whose CI run
+ # was a skipped draft, 19 job-minutes; marking it ready runs the gate
+ # (`ready_for_review` above). `reeval-open-prs` below is a push / dispatch job and
+ # needs no draft condition.
+ if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
diff --git a/.github/workflows/recipe-attach.yml b/.github/workflows/recipe-attach.yml
index 950e7bb1..169a3021 100644
--- a/.github/workflows/recipe-attach.yml
+++ b/.github/workflows/recipe-attach.yml
@@ -40,6 +40,9 @@ on:
- '.github/constraints/pinned-upstream.txt'
pull_request:
branches: [main]
+ # `ready_for_review` is what starts the first run of a draft pull request: a draft
+ # is skipped by the job's own `if:` (2026-10-19; see the job).
+ types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'src/soup_cli/recipes/**'
- 'src/soup_cli/config/**'
@@ -68,6 +71,10 @@ concurrency:
jobs:
verify:
name: attach every shipped config on the meta device
+ # Not on a draft pull request (not a required check). Measured 2026-10-19 over 7
+ # days: 13 runs on a head whose CI run was a skipped draft, 37 job-minutes. Marking
+ # the pull request ready runs it (`ready_for_review` above).
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 30
env:
diff --git a/.github/workflows/recipe-validation.yml b/.github/workflows/recipe-validation.yml
index e2276260..405c581b 100644
--- a/.github/workflows/recipe-validation.yml
+++ b/.github/workflows/recipe-validation.yml
@@ -25,6 +25,9 @@ on:
- '.github/constraints/pinned-upstream.txt'
pull_request:
branches: [main]
+ # `ready_for_review` is what starts the first run of a draft pull request: a draft
+ # is skipped by the job's own `if:` (2026-10-19; see the job).
+ types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'src/soup_cli/recipes/**'
- 'src/soup_cli/config/**'
@@ -77,6 +80,10 @@ concurrency:
jobs:
validate-recipes:
+ # Not on a draft pull request (not a required check). Measured 2026-10-19 over 7
+ # days: 15 runs on a head whose CI run was a skipped draft, 32 job-minutes. Marking
+ # the pull request ready runs it (`ready_for_review` above).
+ if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
PYTHONUTF8: "1"
diff --git a/tests/test_ci_extra_workflows_skip_drafts.py b/tests/test_ci_extra_workflows_skip_drafts.py
new file mode 100644
index 00000000..b04d4854
--- /dev/null
+++ b/tests/test_ci_extra_workflows_skip_drafts.py
@@ -0,0 +1,114 @@
+"""The three workflows that are not required checks skip a draft pull request.
+
+Measured 2026-10-19 over 7 days: `recipe attach`, `Recipe Validation` and `merge freshness`
+started 13, 15 and 70 runs on a head whose `CI` run was a skipped draft (88 job-minutes, and a
+runner start each). A draft is not merged, none of the three is a required check, and marking a
+draft ready fires `ready_for_review`, which they now list so the first run still happens then.
+
+`ci.yml` does the same for `plan` and `lint` (tests/test_ci_full_matrix_on_approval.py,
+`TestADraftRunsNothing`). The contexts below are the ones that file builds.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+from typing import Any
+
+import pytest
+import yaml
+
+from tests.test_ci_full_matrix_on_approval import (
+ _STATUS_FUNCTION,
+ _Expression,
+ _on_event,
+ _pull_request,
+ _push,
+ _truthy,
+)
+
+WORKFLOWS = Path(__file__).resolve().parents[1] / ".github" / "workflows"
+#: file -> the job that runs on a pull request
+PULL_REQUEST_JOBS = {
+ "recipe-attach.yml": "verify",
+ "recipe-validation.yml": "validate-recipes",
+ "merge-freshness.yml": "gate",
+}
+#: The events GitHub starts a pull_request workflow on unless `types:` says otherwise.
+DEFAULT_TYPES = ("opened", "synchronize", "reopened")
+
+
+def _workflow(file: str) -> dict[str, Any]:
+ data = yaml.safe_load((WORKFLOWS / file).read_text(encoding="utf-8"))
+ assert isinstance(data, dict), file
+ return data
+
+
+def _triggers(file: str) -> dict[str, Any]:
+ data = _workflow(file)
+ # PyYAML (YAML 1.1) reads the bare key `on` as the boolean True.
+ return data.get("on", data.get(True))
+
+
+def _starts(file: str, job: str, context: dict[str, Any]) -> bool:
+ condition = str(_workflow(file)["jobs"][job].get("if", "true"))
+ return _truthy(_Expression(condition, context).value())
+
+
[email protected](("file", "job"), sorted(PULL_REQUEST_JOBS.items()))
+class TestADraftStartsNothing:
+ @pytest.mark.parametrize("action", DEFAULT_TYPES)
+ def test_a_draft_pull_request_is_skipped(self, file: str, job: str, action: str) -> None:
+ assert not _starts(file, job, _pull_request(action, draft=True)), (file, action)
+
+ @pytest.mark.parametrize("action", (*DEFAULT_TYPES, "ready_for_review"))
+ def test_a_pull_request_that_is_ready_still_runs(
+ self, file: str, job: str, action: str
+ ) -> None:
+ assert _starts(file, job, _pull_request(action, draft=False)), (file, action)
+
+ def test_marking_a_draft_ready_starts_its_first_run(self, file: str, job: str) -> None:
+ types = _triggers(file)["pull_request"]["types"]
+ assert "ready_for_review" in types, types
+ for default in DEFAULT_TYPES:
+ assert default in types, f"{default} is a GitHub default that `types:` replaces"
+
+ def test_the_condition_calls_no_status_function(self, file: str, job: str) -> None:
+ """`always()` and friends run a job whatever its condition says about a draft."""
+ assert not _STATUS_FUNCTION.search(str(_workflow(file)["jobs"][job].get("if", "")))
+
+ def test_it_is_still_an_ordinary_pull_request_run(self, file: str, job: str) -> None:
+ assert "pull_request_target" not in _triggers(file)
+ assert "pull_request" in _triggers(file)
+
+
+ ("file", "job", "context"),
+ [
+ pytest.param("recipe-attach.yml", "verify", _push(), id="attach-push"),
+ pytest.param(
+ "recipe-attach.yml", "verify", _on_event("workflow_dispatch"), id="attach-dispatch"
+ ),
+ pytest.param("recipe-validation.yml", "validate-recipes", _push(), id="validation-push"),
+ ],
+)
+def test_a_push_or_a_manual_run_is_not_a_draft(
+ file: str, job: str, context: dict[str, Any]
+) -> None:
+ assert _starts(file, job, context), file
+
+
+class TestMergeFreshnessKeepsItsTwoShapes:
+ """`gate` is the pull-request job and `reeval-open-prs` the push / dispatch one."""
+
+ def test_the_gate_does_not_run_on_a_push_or_a_manual_run(self) -> None:
+ for context in (_push(), _on_event("workflow_dispatch")):
+ assert not _starts("merge-freshness.yml", "gate", context)
+
+ def test_the_reevaluation_runs_on_a_push_and_a_manual_run_and_not_on_a_pull_request(
+ self,
+ ) -> None:
+ for context in (_push(), _on_event("workflow_dispatch")):
+ assert _starts("merge-freshness.yml", "reeval-open-prs", context)
+ for draft in (False, True):
+ context = _pull_request("synchronize", draft=draft)
+ assert not _starts("merge-freshness.yml", "reeval-open-prs", context)
diff --git a/tests/test_ci_full_matrix_on_approval.py b/tests/test_ci_full_matrix_on_approval.py
index 2eac8fbb..6931e2ca 100644
--- a/tests/test_ci_full_matrix_on_approval.py
+++ b/tests/test_ci_full_matrix_on_approval.py
@@ -77,6 +77,12 @@ GATED_JOBS = (
"transformers-floor",
"core-floor",
)
+#: The two gated jobs that are not required checks and never fail the build: they run in the
+#: nightly, manual and release runs but not on a pull request, approval run included
+#: (2026-10-19: 206 pull-request runs in 7 days, 480 job-minutes, for a signal that is not a
+#: merge gate). The other four gated jobs run on a pull request at approval.
+PR_SKIPPED_JOBS = ("type-check", "torchao-contract")
+PR_SKIP = "github.event_name != 'pull_request'"
#: The support matrix: what RELEASE runs, and what requires-python must match.
SUPPORT_MATRIX = {
"os": ["ubuntu-latest", "windows-latest", "macos-latest"],
@@ -572,6 +578,26 @@ class TestTriggers:
def test_pushes_to_main_and_release_branches_still_trigger(self):
assert _triggers()["push"]["branches"] == ["main", "release/**"]
+ def test_a_push_that_only_touches_docs_starts_no_run(self):
+ """2026-10-19: 15 of 131 pushes to main in a week were docs-only credit commits, each
+ a quick run of about 20 runner-minutes. The filter is `paths-ignore`, so any push that
+ also touches one other path still runs, and it is exactly these four."""
+ push = _triggers()["push"]
+ assert push["paths-ignore"] == [
+ "docs/**",
+ "changelog.d/**",
+ "CONTRIBUTORS.md",
+ "CONTRIBUTING.md",
+ ]
+ assert "paths" not in push, "an allow-list would skip every path it forgot"
+
+ def test_a_pull_request_is_never_path_filtered(self):
+ """Every required context must report on every pull request: a filter on the pull_request
+ trigger would leave a docs-only pull request with "Expected" checks and no merge."""
+ pull_request = _triggers()["pull_request"]
+ for key in ("paths", "paths-ignore", "branches-ignore"):
+ assert key not in pull_request, key
+
def test_the_nightly_full_run_and_the_manual_dispatch_exist(self):
"""A push to main runs only the quick set, so the full matrix on main has to come
from somewhere: without these two the seven-cell run would never happen on main."""
@@ -624,7 +650,24 @@ class TestGatedJobs:
def test_the_smoke_and_contract_jobs_run_only_on_a_full_run(self, name):
job = _jobs()[name]
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"
+ expected = f"{GATE} && {PR_SKIP}" if name in PR_SKIPPED_JOBS else GATE
+ assert job.get("if") == expected, f"{name} is not gated on plan's decision"
+
+ @pytest.mark.parametrize(("context", "kind"), EVENTS)
+ @pytest.mark.parametrize("name", GATED_JOBS)
+ def test_which_gated_jobs_start_for_each_kind_of_run(self, name, context, kind):
+ """The two jobs that are not required checks run in the nightly, manual and release
+ runs only; the other four also run at approval; nothing runs for a quick run."""
+ full = kind in ("RELEASE", "FULL", "APPROVAL")
+ decided = {"needs": {"plan": {"outputs": {"full": "true" if full else "false"}}}}
+ expected = full and not (name in PR_SKIPPED_JOBS and kind == "APPROVAL")
+ assert _runs(name, {**context, **decided}) is expected, (name, kind)
+
+ def test_nothing_depends_on_the_two_jobs_a_pull_request_skips(self):
+ """A job that needs a skipped one is skipped with it, so nothing may wait on them."""
+ for name, job in _jobs().items():
+ for skipped in PR_SKIPPED_JOBS:
+ assert skipped not in _needs(job), f"{name} needs {skipped}"
def test_lint_waits_for_nothing_and_skips_only_a_draft(self):
lint = _jobs()["lint"]
@@ -1445,6 +1488,81 @@ class TestCoverageUpload:
assert uploading("QUICK_MATRIX") == []
+COVERAGE_STEP = "Run unit tests with coverage"
+NO_COVERAGE_STEP = "Run unit tests without coverage"
+#: The one cell that measures coverage, enforces the floor and uploads the report.
+COVERAGE_CELL = {"os": "ubuntu-latest", "python-version": "3.10"}
+ALL_MATRICES = ("RELEASE_MATRIX", "FULL_MATRIX", "APPROVAL_MATRIX", "QUICK_MATRIX")
+
+
+def _test_step(name: str) -> dict[str, Any]:
+ steps = [step for step in _jobs()["test"]["steps"] if step.get("name") == name]
+ assert len(steps) == 1, (name, steps)
+ return steps[0]
+
+
+def _cells_running(step: dict[str, Any], matrix: str) -> list[dict[str, str]]:
+ condition = str(step.get("if", "true"))
+ return [
+ cell
+ for cell in _cell_dicts(_matrix(matrix))
+ if _truthy(_Expression(condition, {"matrix": cell}).value())
+ ]
+
+
+class TestCoverageIsMeasuredInOneCell:
+ """2026-10-19: coverage is measured in ubuntu / 3.10 only, the cell that uploads it. The
+ floor is enforced there; every other cell runs the suite with `--no-cov`."""
+
+ @pytest.mark.parametrize("matrix", ("RELEASE_MATRIX", "FULL_MATRIX", "APPROVAL_MATRIX"))
+ def test_every_gated_run_measures_coverage_in_exactly_the_uploading_cell(self, matrix):
+ assert _cells_running(_test_step(COVERAGE_STEP), matrix) == [COVERAGE_CELL]
+ assert _cells_running(_test_step("Upload coverage to Codecov"), matrix) == [COVERAGE_CELL]
+
+ def test_a_quick_run_measures_no_coverage_and_so_does_not_check_the_floor(self):
+ """Known and accepted: the quick run has no ubuntu / 3.10 cell. The approval run a
+ merge waits for has it, and so does the nightly run."""
+ assert _cells_running(_test_step(COVERAGE_STEP), "QUICK_MATRIX") == []
+
+ @pytest.mark.parametrize("matrix", ALL_MATRICES)
+ def test_every_cell_runs_the_suite_exactly_once(self, matrix):
+ """A cell that ran neither step would test nothing; one that ran both would run the
+ suite twice. The two conditions are opposites."""
+ with_coverage = _cells_running(_test_step(COVERAGE_STEP), matrix)
+ without = _cells_running(_test_step(NO_COVERAGE_STEP), matrix)
+ cells = _cell_dicts(_matrix(matrix))
+ assert len(with_coverage) + len(without) == len(cells), matrix
+ assert not [cell for cell in with_coverage if cell in without], matrix
+ assert sorted(with_coverage + without, key=str) == sorted(cells, key=str), matrix
+
+ def test_the_coverage_step_measures_and_the_other_one_does_not(self):
+ measured = shlex.split(str(_test_step(COVERAGE_STEP)["run"]))
+ assert "--cov=soup_cli" in measured
+ assert "--cov-report=xml:coverage.xml" in measured # the Codecov upload sends it
+ assert "--no-cov" not in measured
+ unmeasured = shlex.split(str(_test_step(NO_COVERAGE_STEP)["run"]))
+ assert "--no-cov" in unmeasured
+ assert not [arg for arg in unmeasured if arg.startswith("--cov")], unmeasured
+
+ def test_the_floor_is_left_to_pyproject_and_the_measuring_step_does_not_switch_it_off(self):
+ """`--cov-fail-under` lives in `addopts`: dropping it, or a `-o addopts=` / `-p no:cov`
+ / `--cov-fail-under=0` on the measuring step, would measure coverage and enforce nothing."""
+ pyproject = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
+ addopts = re.search(r'^addopts\s*=\s*"(.*)"\s*$', pyproject, re.M)
+ assert addopts is not None
+ assert "--cov-fail-under=77" in shlex.split(addopts.group(1)), addopts.group(1)
+ measured = str(_test_step(COVERAGE_STEP)["run"])
+ for switch in ("addopts", "no:cov", "--cov-fail-under", "--no-cov"):
+ assert switch not in measured, switch
+
+ @pytest.mark.parametrize("step", (COVERAGE_STEP, NO_COVERAGE_STEP))
+ def test_both_steps_still_write_what_later_steps_read(self, step):
+ """The nightly test-count badge reads report.xml from ubuntu / 3.11, a cell that now
+ runs the unmeasured step: `--junitxml` must not be left to the measuring one."""
+ args = shlex.split(str(_test_step(step)["run"]))
+ assert "--junitxml=report.xml" in args, step
+
+
def _contributing() -> str:
"""CONTRIBUTING.md with its line wrapping collapsed."""
return " ".join(CONTRIBUTING.read_text(encoding="utf-8").split())
diff --git a/tests/test_ci_hf_cache_warm_step.py b/tests/test_ci_hf_cache_warm_step.py
new file mode 100644
index 00000000..d4a2e453
--- /dev/null
+++ b/tests/test_ci_hf_cache_warm_step.py
@@ -0,0 +1,81 @@
+"""The `Warm HF Hub cache` step of the `test` job downloads over plain HTTP, on a short budget.
+
+Measured 2026-10-19 over the last 12 pull-request runs: on macOS and Windows the step took 6.3
+minutes in every cell (6.25 to 6.37) and the cache behind it was never saved. The Hub answers
+404 on `/api/models/gpt2/xet-read-token/<sha>` -- the token the `hf_xet` download path asks for
+-- and the retry loop treats a 404 like a 429 until its budget runs out. About 57 such cells a
+day, 362 runner-minutes a day, since about 2026-10-16 17Z. Linux never hit it: its restored
+cache already held the file.
+
+`HF_HUB_DISABLE_XET` makes huggingface_hub's `is_xet_available()` false (constants.py and
+utils/_runtime.py, read at v2.2.0, the version `.github/constraints/pinned-upstream.txt`
+installs), so the download takes the plain HTTP path and never asks for that token. The budget
+is 120 s, not 360: it is spent in full only when the Hub refuses a repo, and the step never
+fails the job either way.
+"""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+from typing import Any
+
+import pytest
+import yaml
+
+ROOT = Path(__file__).resolve().parents[1]
+CI = ROOT / ".github" / "workflows" / "ci.yml"
+WARM_STEP = "Warm HF Hub cache (models the tests load)"
+SAVE_STEP = "Save HF Hub cache"
+
+
+def _test_steps() -> list[dict[str, Any]]:
+ return yaml.safe_load(CI.read_text(encoding="utf-8"))["jobs"]["test"]["steps"]
+
+
+def _step(name: str) -> dict[str, Any]:
+ steps = [step for step in _test_steps() if step.get("name") == name]
+ assert len(steps) == 1, (name, steps)
+ return steps[0]
+
+
+class TestTheWarmStepAvoidsTheXetTokenPath:
+ def test_the_step_disables_xet_for_its_own_downloads(self) -> None:
+ env = _step(WARM_STEP).get("env") or {}
+ assert env.get("HF_HUB_DISABLE_XET") == "1", env
+
+ def test_it_is_a_python_step_whose_downloads_read_that_environment(self) -> None:
+ """Scoped to this step, not the job: a job-level `env:` would also change how every test
+ that downloads fetches its model."""
+ step = _step(WARM_STEP)
+ assert step.get("shell") == "python"
+ assert "snapshot_download" in str(step["run"])
+ job_env = yaml.safe_load(CI.read_text(encoding="utf-8"))["jobs"]["test"].get("env") or {}
+ assert "HF_HUB_DISABLE_XET" not in job_env
+
+ def test_the_variable_is_a_name_huggingface_hub_still_reads(self) -> None:
+ """A renamed variable would be ignored silently, and the step would go back to 6 minutes."""
+ hub = pytest.importorskip("huggingface_hub")
+ if int(hub.__version__.split(".")[0]) < 1:
+ pytest.skip("hf_xet is a hard dependency from huggingface_hub 1.0")
+ from huggingface_hub import constants
+
+ assert hasattr(constants, "HF_HUB_DISABLE_XET"), hub.__version__
+
+
+class TestTheWarmStepBudget:
+ def _deadline(self) -> int:
+ script = str(_step(WARM_STEP)["run"])
+ match = re.search(r"deadline\s*=\s*time\.monotonic\(\)\s*\+\s*(\d+)", script)
+ assert match is not None, "the warm step has no single retry budget"
+ return int(match.group(1))
+
+ def test_the_whole_list_shares_one_budget_of_120_seconds(self) -> None:
+ assert self._deadline() == 120
+
+ def test_it_never_fails_the_job_and_saves_only_a_complete_warm(self) -> None:
+ script = str(_step(WARM_STEP)["run"])
+ assert "except Exception" in script
+ assert "partial" in script and "all" in script
+ condition = str(_step(SAVE_STEP).get("if", ""))
+ assert "steps.warm.outputs.warmed == 'all'" in condition, condition
diff --git a/tests/test_ci_pip_download_cache.py b/tests/test_ci_pip_download_cache.py
index 8a1c2e4b..cc0425ad 100644
--- a/tests/test_ci_pip_download_cache.py
+++ b/tests/test_ci_pip_download_cache.py
@@ -1,11 +1,18 @@
-"""Only the Ubuntu/Python 3.12 test cell reuses pip downloads.
-
-The cache inputs include the project metadata and every committed constraints file,
-including the compatibility floor. Checkout must precede setup-python so those inputs
-can be hashed. A cache hit must never bypass installation: nightly jobs still resolve
-the newest allowed versions, and the floor job still installs its constrained stack.
-The remaining test cells and the four smoke/contract jobs leave pip caching disabled
-to limit large dependency archives competing with the existing HF model caches.
+"""No test cell of CI caches pip downloads.
+
+The ubuntu / Python 3.12 cell used to restore a pip cache (#1970). Measured on 2026-10-19
+over the last 12 pull-request runs, that cost more than it saved: restoring it took 0.49 min
+(0.33 to 0.60) and the install then 1.54 min, 2.03 min in all, where the uncached ubuntu /
+3.10 cell installed in 1.80 min. The cache entries were also 3 GB each (two of them, a new
+one whenever ``pyproject.toml`` or a constraints file changes) and filled 6.1 GB of the
+8.8 GB the repository used of its 10 GB Actions cache, which is what evicted the small
+Hugging Face caches next to them. So no cell declares ``cache:`` or ``cache-dependency-path:``
+any more, and these tests pin that for every kind of run and every cell of the support matrix.
+
+What stays pinned: a cache must never bypass installation (nightly jobs still resolve the
+newest allowed versions, the floor job still installs its constrained stack), and the
+project install follows ``setup-python``. A job that wants a pip cache again has to bring a
+measurement that beats the one above, and change this file with it.
"""
from __future__ import annotations
@@ -30,7 +37,6 @@ from tests.test_ci_full_matrix_on_approval import (
ROOT = Path(__file__).absolute().parents[1]
CI = ROOT / ".github" / "workflows" / "ci.yml"
PROJECT_JOBS = ("test", "mlx-smoke", "torchao-contract", "pytorch-smoke", "transformers-floor")
-UNCACHED_JOBS = ("mlx-smoke", "torchao-contract", "pytorch-smoke", "transformers-floor")
RUN_KINDS = (
pytest.param((_push(), _pull_request("opened")), "QUICK", id="quick-main-and-pr"),
pytest.param(
@@ -41,17 +47,17 @@ RUN_KINDS = (
pytest.param((_push("refs/heads/release/v0.76.0"),), "RELEASE", id="release"),
)
# Literal outcomes over the entire supported 3x3 matrix, independent of the policy
-# expression and of which cells a particular workflow kind currently selects.
+# expression and of which cells a particular workflow kind currently selects: none caches.
SUPPORT_CELLS = (
- ("ubuntu-latest", "Linux", "3.10", ""),
- ("ubuntu-latest", "Linux", "3.11", ""),
- ("ubuntu-latest", "Linux", "3.12", "pip"),
- ("windows-latest", "Windows", "3.10", ""),
- ("windows-latest", "Windows", "3.11", ""),
- ("windows-latest", "Windows", "3.12", ""),
- ("macos-latest", "macOS", "3.10", ""),
- ("macos-latest", "macOS", "3.11", ""),
- ("macos-latest", "macOS", "3.12", ""),
+ ("ubuntu-latest", "Linux", "3.10"),
+ ("ubuntu-latest", "Linux", "3.11"),
+ ("ubuntu-latest", "Linux", "3.12"),
+ ("windows-latest", "Windows", "3.10"),
+ ("windows-latest", "Windows", "3.11"),
+ ("windows-latest", "Windows", "3.12"),
+ ("macos-latest", "macOS", "3.10"),
+ ("macos-latest", "macOS", "3.11"),
+ ("macos-latest", "macOS", "3.12"),
)
RUNNER_OS = {"ubuntu-latest": "Linux", "windows-latest": "Windows", "macos-latest": "macOS"}
@@ -82,17 +88,16 @@ def _project_installs(job_name: str) -> list[tuple[int, dict[str, Any]]]:
return installs
-class TestPipDownloadCache:
+class TestNoPipDownloadCache:
@pytest.mark.parametrize(("contexts", "kind"), RUN_KINDS)
- @pytest.mark.parametrize(("runner", "runner_os", "python_version", "expected"), SUPPORT_CELLS)
- def test_only_ubuntu_python312_caches_pip_for_every_run_kind(
+ @pytest.mark.parametrize(("runner", "runner_os", "python_version"), SUPPORT_CELLS)
+ def test_no_cell_caches_pip_for_any_run_kind(
self,
contexts: tuple[dict[str, Any], ...],
kind: str,
runner: str,
runner_os: str,
python_version: str,
- expected: str,
) -> None:
_, setup = _python_setup("test")
policy = setup.get("with", {}).get("cache", "")
@@ -102,12 +107,12 @@ class TestPipDownloadCache:
"runner": {"os": runner_os},
"matrix": {"os": runner, "python-version": python_version},
}
- assert _render(policy, cell_context) == expected, (
- f"{kind}: {runner}/{python_version} must select pip cache {expected!r}"
+ assert _render(policy, cell_context) == "", (
+ f"{kind}: {runner}/{python_version} must not select a pip cache"
)
@pytest.mark.parametrize(("contexts", "kind"), RUN_KINDS)
- def test_each_selected_workflow_matrix_has_only_one_cached_cell(
+ def test_each_selected_workflow_matrix_has_no_cached_cell(
self, contexts: tuple[dict[str, Any], ...], kind: str
) -> None:
_, setup = _python_setup("test")
@@ -118,32 +123,20 @@ class TestPipDownloadCache:
cell_context = {**context, "runner": {"os": RUNNER_OS[cell["os"]]}, "matrix": cell}
if _render(policy, cell_context):
cached.add((cell["os"], cell["python-version"]))
- assert cached == {("ubuntu-latest", "3.12")}, (kind, cached)
+ assert cached == set(), (kind, cached)
- @pytest.mark.parametrize("job_name", UNCACHED_JOBS)
- def test_smoke_and_contract_jobs_leave_pip_cache_disabled(self, job_name: str) -> None:
+ @pytest.mark.parametrize("job_name", PROJECT_JOBS)
+ def test_no_project_job_declares_a_pip_cache_or_its_inputs(self, job_name: str) -> None:
_, setup = _python_setup(job_name)
- assert not setup.get("with", {}).get("cache"), (
- f"{job_name}: pip caching is reserved for the Ubuntu/Python 3.12 test cell"
+ assert "cache" not in setup.get("with", {}), (
+ f"{job_name}: pip caching is off (2026-10-19: the cache cost more than it saved)"
)
assert "cache-dependency-path" not in setup.get("with", {}), (
- f"{job_name}: uncached setup must not declare pip cache dependency inputs"
+ f"{job_name}: no pip cache, so no cache dependency inputs"
)
- def test_cache_inputs_cover_project_and_all_constraints(self) -> None:
- _, setup = _python_setup("test")
- dependency_paths = setup.get("with", {}).get("cache-dependency-path", "")
- assert isinstance(dependency_paths, str), "test: cache inputs must be paths"
- patterns = [line.strip() for line in dependency_paths.splitlines() if line.strip()]
- matched = {path for pattern in patterns for path in ROOT.glob(pattern) if path.is_file()}
- constraints = set((ROOT / ".github" / "constraints").glob("*.txt"))
- assert constraints, "the constraint check must cover committed constraints files"
- required = {ROOT / "pyproject.toml", *constraints}
- missing = sorted(str(path.relative_to(ROOT)) for path in required - matched)
- assert not missing, f"test: pip cache does not hash dependency inputs: {missing}"
-
@pytest.mark.parametrize("job_name", PROJECT_JOBS)
- def test_checkout_precedes_python_cache_restore(self, job_name: str) -> None:
+ def test_checkout_precedes_python_setup(self, job_name: str) -> None:
setup_index, _ = _python_setup(job_name)
checkouts = [
index
@@ -151,11 +144,11 @@ class TestPipDownloadCache:
if str(step.get("uses", "")).startswith("actions/checkout@")
]
assert checkouts and min(checkouts) < setup_index, (
- f"{job_name}: checkout must make cache dependency inputs available before setup-python"
+ f"{job_name}: checkout must come before setup-python (a cache hashes the project files)"
)
@pytest.mark.parametrize("job_name", PROJECT_JOBS)
- def test_project_install_follows_cache_restore(self, job_name: str) -> None:
+ def test_project_install_follows_python_setup(self, job_name: str) -> None:
setup_index, _ = _python_setup(job_name)
for install_index, step in _project_installs(job_name):
assert setup_index < install_index, (
diff --git a/tests/test_ci_test_cells_run_in_parallel.py b/tests/test_ci_test_cells_run_in_parallel.py
index 0013d478..c4341dc5 100644
--- a/tests/test_ci_test_cells_run_in_parallel.py
+++ b/tests/test_ci_test_cells_run_in_parallel.py
@@ -29,6 +29,11 @@ PYPROJECT = ROOT / "pyproject.toml"
CONTRIBUTING = ROOT / "CONTRIBUTING.md"
RUN_STEP = "Run unit tests with coverage"
+# 2026-10-19: every cell but ubuntu / 3.10 runs this one, with `--no-cov`. Coverage is
+# measured in one cell (tests/test_ci_full_matrix_on_approval.py::TestCoverageIsMeasuredInOneCell);
+# the parallelism pins below hold for both steps, because most cells now run the second.
+NO_COV_STEP = "Run unit tests without coverage"
+RUN_STEPS = (RUN_STEP, NO_COV_STEP)
INSTALL_STEP = "Install dependencies"
@@ -42,8 +47,8 @@ def _step(name: str) -> dict[str, Any]:
return steps[0]
-def _pytest_args() -> list[str]:
- args = shlex.split(str(_step(RUN_STEP)["run"]))
+def _pytest_args(step: str = RUN_STEP) -> list[str]:
+ args = shlex.split(str(_step(step)["run"]))
assert args[:2] == ["pytest", "tests/"], args
return args
@@ -56,13 +61,15 @@ def _option(args: list[str], flag: str) -> list[str]:
class TestTheTestJobRunsInParallel:
- def test_one_worker_per_logical_cpu(self) -> None:
- assert _option(_pytest_args(), "-n") == ["logical"]
+ @pytest.mark.parametrize("step", RUN_STEPS)
+ def test_one_worker_per_logical_cpu(self, step: str) -> None:
+ assert _option(_pytest_args(step), "-n") == ["logical"]
- def test_one_test_file_per_worker(self) -> None:
+ @pytest.mark.parametrize("step", RUN_STEPS)
+ def test_one_test_file_per_worker(self, step: str) -> None:
"""`load` hands the tests of one file to several workers: module-level state and
test order inside a file are lost, and a timing test failed under it."""
- assert _option(_pytest_args(), "--dist") == ["loadfile"]
+ assert _option(_pytest_args(step), "--dist") == ["loadfile"]
def test_the_plugin_is_installed_with_its_cpu_counter(self) -> None:
"""Without the `psutil` extra `-n logical` falls back to another count."""
@@ -73,21 +80,38 @@ class TestTheTestJobRunsInParallel:
def test_the_plugin_is_installed_before_the_tests_run(self) -> None:
names = [step.get("name") for step in _jobs()["test"]["steps"]]
- assert names.index(INSTALL_STEP) < names.index(RUN_STEP)
+ for step in RUN_STEPS:
+ assert names.index(INSTALL_STEP) < names.index(step)
+
+ @pytest.mark.parametrize("step", RUN_STEPS)
+ @pytest.mark.parametrize(
+ "argument",
+ [
+ "--junitxml=report.xml", # the nightly badge parses it, from an unmeasured cell
+ "-v",
+ "--tb=short",
+ ],
+ )
+ def test_the_reports_the_later_steps_read_are_still_written(
+ self, step: str, argument: str
+ ) -> None:
+ assert argument in _pytest_args(step)
@pytest.mark.parametrize(
"argument",
[
- "--junitxml=report.xml", # the nightly test-count badge parses it
"--cov=soup_cli",
"--cov-report=xml:coverage.xml", # the Codecov upload sends it
"--cov-report=term-missing:skip-covered",
- "-v",
- "--tb=short",
],
)
- def test_the_reports_the_later_steps_read_are_still_written(self, argument: str) -> None:
- assert argument in _pytest_args()
+ def test_the_measuring_step_still_writes_the_coverage_reports(self, argument: str) -> None:
+ assert argument in _pytest_args(RUN_STEP)
+
+ def test_the_other_step_turns_coverage_off_and_writes_no_coverage_report(self) -> None:
+ args = _pytest_args(NO_COV_STEP)
+ assert "--no-cov" in args
+ assert not [arg for arg in args if arg.startswith("--cov")], args
def test_no_step_of_any_job_spreads_one_file_over_workers(self) -> None:
text = CI.read_text(encoding="utf-8")
diff --git a/tests/test_issue1017_merge_freshness.py b/tests/test_issue1017_merge_freshness.py
index 943c6126..654a2d34 100644
--- a/tests/test_issue1017_merge_freshness.py
+++ b/tests/test_issue1017_merge_freshness.py
@@ -591,7 +591,10 @@ class TestWorkflowPins:
def test_job_if_conditions_are_pinned(self):
jobs = self._loaded()["jobs"]
- assert jobs["gate"]["if"] == "github.event_name == 'pull_request'"
+ # A pull request that is not a draft (2026-10-19; test_ci_extra_workflows_skip_drafts.py).
+ assert jobs["gate"]["if"] == (
+ "github.event_name == 'pull_request' && github.event.pull_request.draft == false"
+ )
reeval_if = jobs["reeval-open-prs"]["if"]
assert "push" in reeval_if
assert "pull_request" not in reeval_if