Skip to content
Open
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
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2214,10 +2214,12 @@ jobs:
#
# NOT a required context of its own: it rides the `ci-gate` roll-up, exactly as `webconsole` does and
# for the same reason recorded there -- a new required context needs a branch-protection change, and
# until that lands every PR carries a check it can never satisfy. Each windows-2025 test shard
# until that lands every PR carries a check it can never satisfy. Each test shard
# below is one more leg of this job, so each rides the roll-up the same way.
#
# windows-2025 RUNS THE TIER AS 3 TEST SHARDS, ubuntu-latest as one leg, under an owner ruling of
# EACH OS RUNS THE TIER AS THE SAME 3 TEST SHARDS. ubuntu-latest was one leg until 2026-12-02, when
# its step was killed at the 48-minute cap with no test failing (job 143796847829, among others).
# windows-2025 was split first, under an owner ruling of
# 2026-11-24 in the Manager's session: asked "Approve the split?", the owner answered "Shard into 3
# (Recommended)". It reverses the 2026-11-14 ruling quoted below for this leg. The windows-2025
# junit of run 45415735678 (job 138521635567) held 11,506 testcases and 15,414 s of test time at
Expand Down Expand Up @@ -2513,9 +2515,10 @@ jobs:
#
# RE-DERIVE IF a GREEN windows-2025 test shard of this tier is observed above 76:55 -- the
# 100-minute cap divided by the 1.30 floor scripts/ci/step_margin.py applies to the steps it
# gates -- or if any shard is killed at the 100-minute step cap, or if TOOLING_WORKERS or the
# shard count changes. Both caps are unchanged by the split and apply per shard; a shard is
# predicted to run about a third of the 86 minutes above, so re-sizing them is its own change. The
# gates -- or a GREEN ubuntu one above 36:55, the same rule on its 48, or if any test shard is
# killed at its step cap, or if TOOLING_WORKERS or the test shard count changes. Both caps are unchanged by the split and apply per shard; a shard is
# predicted to run about a third of the 86 minutes above, so re-sizing them is its own change.
# ubuntu's 60/48 also apply per test shard, unchanged. The
# earlier triggers, at 51:32, 36:55 and 29 minutes, are in this file's git history.
# `pytest_workers` is NOT this tier's knob and never was -- see the TOOLING_WORKERS note on the
# step below.
Expand Down Expand Up @@ -2544,7 +2547,7 @@ jobs:
#
# That is also why the install line below cannot be trimmed to a harness-only set: collection
# imports the whole suite regardless of what this job intends to execute. Since the test
# shards, the harness step names only its shard's files; the partition guard, ubuntu only,
# shards, the harness step names only its shard's files; the partition guard, ubuntu test shard 1,
# is what still collects the whole suite and needs both.
- name: Install Qt offscreen system libraries
if: runner.os == 'Linux'
Expand Down Expand Up @@ -2664,7 +2667,7 @@ jobs:
# `PYTEST_WORKERS`.
TOOLING_WORKERS: "${{ matrix.os == 'windows-2025' && '3' || '4' }}"
# The leg's test shard of the manifest files, as an `@file` argument the way the engine test
# shards pass theirs; ubuntu's one shard is the whole tier. `--ignore-glob` prunes nothing
# shards pass theirs. `--ignore-glob` prunes nothing
# from a named file, and stays so this selection and the guard's below are one.
run: |
mkdir -p out/tooling-shard
Expand All @@ -2686,7 +2689,7 @@ jobs:
#
# The floor is deliberately loose (1,000 against ~1,545 executing on ubuntu and ~1,882 on
# Windows when this was written), and `--shards` divides it by the leg's shard count, rounding
# up, so each windows-2025 test shard is held to its third. It is a DEAD-MARKER backstop, not a coverage assertion: a tight floor would go red
# up, so each test shard is held to its third. It is a DEAD-MARKER backstop, not a coverage assertion: a tight floor would go red
# every time the tier legitimately grows or a platform gate moves, and a gate that cries wolf gets
# deleted. Coverage drift is tests/test_tooling_partition.py's job, on evidence, not this one's.
# A SCRIPT, NOT AN INLINE HEREDOC. The logic and its reasoning live in the script, where they can
Expand All @@ -2702,11 +2705,11 @@ jobs:

# THE PARTITION GUARD, the `test-shards` job's for the engine suite applied to this tier. It
# runs pytest's own collection under the tier's selection and fails if a collected file is in
# no test shard or a file is in two. The split is a pure function of the tree, so the ubuntu
# leg answers for the windows-2025 shards, and it runs on docs-only PRs too. Only after a
# no test shard or a file is in two. The split is a pure function of the tree, so ubuntu test
# shard 1 answers for every test shard on both OSes, and it runs on docs-only PRs too. Only after a
# passing suite, for the job-cap reason the engine guard states.
- name: Tooling shards partition pytest's collection
if: ${{ !cancelled() && steps.tests.outcome == 'success' && runner.os == 'Linux' }}
if: ${{ !cancelled() && steps.tests.outcome == 'success' && runner.os == 'Linux' && matrix.shard == '1' }}
timeout-minutes: 6
env:
QT_QPA_PLATFORM: offscreen
Expand Down Expand Up @@ -3005,7 +3008,7 @@ jobs:
# output above is untouched: `docs/` is a GENUINE trigger for this tier, because 22 of the 130
# files in tests/tooling_manifest.txt read documents and tests/test_ci_tooling_gate.py asserts
# `docs/security/THREAT-MODEL.md -> True` outright. Skip the tier on docs and those 22 files stop
# guarding anything. This keeps every one of them running, on one leg.
# guarding anything. This keeps every one of them running, on ubuntu.
tooling_matrix: ${{ steps.f.outputs.tooling_matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -3144,12 +3147,13 @@ jobs:
# because unlike the two matrices above it depends on `code`, which is not known until the PR
# arm at the bottom of this step. Every arm that writes `code` also writes this. A fork gets
# ubuntu only either way, for the same reason the other two matrices do.
# A leg's `shard` and `of` go to shard_tests.py `--suite tooling`: windows-2025 in 3 test
# shards, ubuntu in 1 (the `tooling` job's note says why).
TU='{"os":"ubuntu-latest","shard":"1","of":"1"}'
TW='{"os":"windows-2025","of":"3","shard":'
# A leg's `shard` and `of` go to shard_tests.py `--suite tooling`: each OS in 3 test shards
# (the `tooling` job's note says why).
TU='{"os":"ubuntu-latest","of":"3","shard":'
TU="$TU\"1\"},$TU\"2\"},$TU\"3\"}"
TW="${TU//ubuntu-latest/windows-2025}"
if [ "${GITHUB_REPOSITORY:-}" = "MEFORORG/MessageFoundry" ]; then
TOOLING_FULL="{\"include\":[$TU,$TW\"1\"},$TW\"2\"},$TW\"3\"}]}"
TOOLING_FULL="{\"include\":[$TU,$TW]}"
else
TOOLING_FULL="{\"include\":[$TU]}"
fi
Expand Down
10 changes: 6 additions & 4 deletions scripts/quality/shard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
it twice. And it holds the connscale smoke in shard 1, because scripts/connscale_harvest.py joins
the smoke's readings to the `test (...)` jobs, and the herd floor is armed only there.

`--suite tooling` IS ci.yml's `tooling` JOB, THE REPO HARNESS TIER, split across its windows-2025
legs (owner ruling 2026-11-24). It is the complement of the other two: exactly the files
`--suite tooling` IS ci.yml's `tooling` JOB, THE REPO HARNESS TIER, split across its legs, the
same 3 test shards on each OS (windows-2025 by owner ruling 2026-11-24).
It is the complement of the other two: exactly the files
tests/tooling_manifest.txt names, and nothing else. Its hash is SALTED, `crc32("<salt>:<path>")`,
because the unsalted hash split the measured tier badly; `TOOLING_SALT` below holds the
measurement, how the salt was chosen and when to choose again. A salt is still a pure function of
Expand Down Expand Up @@ -75,8 +76,9 @@
#: non-negative integer that puts every shard within 5 percent of the mean there: 4883 / 5208 / 5323
#: against 5138. About a quarter of salts land within 15 percent on that junit, so the unsalted
#: split was not unlucky, only ordinary. A file added later lands by its own hash and moves nothing, so the balance drifts
#: as the tier grows rather than jumping. RE-PICK IT when a shard's junit test-time sum is observed
#: more than 15 percent off the mean of the three, by the same search over a fresh junit; a re-pick
#: as the tier grows rather than jumping. RE-PICK IT when a windows-2025 test shard's
#: junit test-time sum is observed more than 15 percent off the mean of that OS's three (ubuntu
#: uses the same split, and its balance was not what chose the salt), by the same search over a fresh junit; a re-pick
#: moves files between shards, which costs nothing but a cold read of the next run's balance.
TOOLING_SALT = "9"

Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ def _private_pwsh_startup_cache(tmp_path_factory: pytest.TempPathFactory) -> Ite
folder instead, which is just as private to the test.

The cost: every pwsh in the suite now starts with no startup profile and no module analysis
cache, so each start is slower. That is unmeasured on Linux. The duration of the ubuntu leg of
``repo harness tests`` will show it. The pytest process and every other child that reads
cache, so each start is slower. That is unmeasured on Linux. The summed durations of
the ubuntu test shards of ``repo harness tests`` are not comparable with those of the old
single ubuntu leg. The pytest process and every other child that reads
``XDG_CACHE_HOME`` (at least pip, uv and pre-commit) also start each test with an empty cache.
A test that runs a real installer would fetch afresh.

Expand Down
57 changes: 34 additions & 23 deletions tests/test_ci_tooling_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_the_regex_is_read_not_copied() -> None:
# LEGS", which is a separate decision with a separate failure mode.
#
# `tooling_matrix` narrows the tier to ubuntu on a docs-only PR. That is safe only because the tier
# still RUNS -- the 22 document-reading files in the manifest keep their coverage, on one leg instead
# still RUNS -- the 22 document-reading files in the manifest keep their coverage, on one OS instead
# of two. If a future edit ever narrows the FILTER instead, the tests above go red. That is the
# division of labour between the two blocks, and neither can cover for the other.
#
Expand All @@ -236,6 +236,12 @@ def test_the_regex_is_read_not_copied() -> None:

_SOURCE_REPO = "MEFORORG/MessageFoundry"

#: The ubuntu half of `tooling_matrix`: the whole tier, one leg per test shard. A docs-only PR and a
#: fork run exactly these, so a missing one would drop files with no other leg to run them.
_UBUNTU_LEGS = [{"os": "ubuntu-latest", "of": "3", "shard": str(n)} for n in (1, 2, 3)]
#: The whole matrix, on this repository, for every arm that runs the tier on code.
_FULL_LEGS = _UBUNTU_LEGS + [{**leg, "os": "windows-2025"} for leg in _UBUNTU_LEGS]


def _changes_step_script() -> str:
"""The `changes` job's detector step, read out of the workflow rather than restated here."""
Expand Down Expand Up @@ -330,7 +336,7 @@ def test_the_tooling_job_reads_the_matrix_and_does_not_carry_a_literal() -> None
matrix = doc["jobs"]["tooling"]["strategy"]["matrix"]
assert isinstance(matrix, str) and "tooling_matrix" in matrix, (
"the tooling job's matrix is no longer the `changes` output -- a literal list here restores "
"the full two-leg tier on every docs-only PR, with nothing to say so"
"the full two-OS tier on every docs-only PR, with nothing to say so"
)


Expand All @@ -344,13 +350,15 @@ def test_every_non_pr_arm_emits_a_matrix(tmp_path: Path, event: str) -> None:
"the job -- it does not fall back to a full matrix"
)
assert _legs(outputs["tooling_matrix"]), f"the `{event}` arm emitted an empty leg list"
if outputs["tooling"] == "true":
assert json.loads(outputs["tooling_matrix"])["include"] == _FULL_LEGS


def test_a_docs_only_pr_gets_one_leg_and_a_code_pr_gets_both(tmp_path: Path) -> None:
def test_a_docs_only_pr_gets_the_ubuntu_legs_and_a_code_pr_gets_both(tmp_path: Path) -> None:
"""The narrowing itself, end to end, through the step's own git diff.

Both halves in one test on purpose: the property worth asserting is the DIFFERENCE. A docs-only
assertion that passed because the full matrix had also collapsed to one leg would be a green
assertion that passed because the full matrix had also collapsed to ubuntu would be a green
proving nothing.
"""
bash = require_bash(tmp_path)
Expand All @@ -372,9 +380,10 @@ def test_a_docs_only_pr_gets_one_leg_and_a_code_pr_gets_both(tmp_path: Path) ->
code_out = _run_detector(bash, code, "pull_request", base_sha=base)
assert code_out["code"] == "true"
code_legs = _legs(code_out["tooling_matrix"])
assert json.loads(code_out["tooling_matrix"])["include"] == _FULL_LEGS

assert docs_legs == ["ubuntu-latest"], (
f"docs-only PR should run one ubuntu leg, got {docs_legs}"
assert json.loads(docs_out["tooling_matrix"])["include"] == _UBUNTU_LEGS, (
f"docs-only PR should run every ubuntu test shard and nothing else, got {docs_legs}"
)
assert len(code_legs) > len(docs_legs), (
f"a code PR must run MORE legs than a docs-only one ({code_legs} vs {docs_legs}); equal "
Expand All @@ -390,16 +399,17 @@ def test_a_fork_never_pays_for_the_windows_leg(tmp_path: Path) -> None:
"""The rule the `matrix` and `ide_matrix` outputs already follow, asserted for this one too."""
bash = require_bash(tmp_path)
outputs = _run_detector(bash, tmp_path, "push", repo="someone/MessageFoundry")
legs = _legs(outputs["tooling_matrix"])
assert legs == ["ubuntu-latest"], (
legs = json.loads(outputs["tooling_matrix"])["include"]
assert legs == _UBUNTU_LEGS, (
f"a fork should build this tier on ubuntu only, got {legs} -- the 2x-billed Windows leg "
"would be spending a contributor's own minutes"
)


# ---------------------------------------------------------------------------------------------
# THE TEST SHARDS (owner ruling 2026-11-24): windows-2025 runs the tier as 3 test shards, ubuntu as
# one leg. A leg's `shard` and `of` reach scripts/quality/shard_tests.py `--suite tooling`; that
# THE TEST SHARDS (windows-2025 by owner ruling 2026-11-24, ubuntu since 2026-12-02): each OS runs the
# tier as the same 3 test shards. A leg's `shard` and `of` reach
# scripts/quality/shard_tests.py `--suite tooling`; that
# script's own tests hold the split, these hold the wiring. A leg whose shards had a gap, a second
# `of`, a shared check name or a shared artifact name would drop files, fail the upload, or hide a
# red leg behind its sibling's name, each with every other check here green.
Expand Down Expand Up @@ -434,15 +444,12 @@ def full_matrix(tmp_path_factory: pytest.TempPathFactory) -> list[dict[str, str]
return list(json.loads(outputs["tooling_matrix"])["include"])


def test_windows_2025_runs_the_tier_in_three_test_shards_and_ubuntu_in_one(
def test_each_os_runs_the_tier_in_the_same_three_test_shards(
full_matrix: list[dict[str, str]],
) -> None:
"""Falsified by dropping `$TW"3"}` from TOOLING_FULL in ci.yml: RED. Restored."""
"""Falsified by dropping shard 3 from TU in ci.yml: RED. Restored."""
legs = full_matrix
assert legs == [
{"os": "ubuntu-latest", "shard": "1", "of": "1"},
*({"os": "windows-2025", "of": "3", "shard": str(n)} for n in (1, 2, 3)),
], legs
assert legs == _FULL_LEGS, legs


def test_every_tooling_leg_has_its_own_check_name_and_junit_artifact(
Expand All @@ -461,7 +468,6 @@ def test_every_tooling_leg_has_its_own_check_name_and_junit_artifact(
leg["os"] if leg["of"] == "1" else f"{leg['os']}, shard {leg['shard']} of {leg['of']}"
for leg in legs
]
assert "ubuntu-latest" in names, "the ubuntu leg's check name changed"
assert len(set(names)) == len(names), names
upload = _tooling_step("Upload the tier's junit")
template = str(dict(upload["with"])["name"]) # type: ignore[call-overload]
Expand Down Expand Up @@ -497,20 +503,25 @@ def test_each_leg_runs_its_own_shard_of_the_tier() -> None:
def test_the_partition_guard_reads_the_tier_s_selection_on_one_leg(
full_matrix: list[dict[str, str]],
) -> None:
"""Falsified by `--of 2` on the guard line: RED on the count. Restored."""
"""Falsified by `--of 2` on the guard line: RED on the count. Restored. And by dropping the
`matrix.shard` clause from its `if:`: RED on the condition. Restored."""
harness = str(_tooling_step(_HARNESS_STEP)["run"])
pytest_line = next(line for line in harness.splitlines() if line.startswith("pytest "))
guard = _tooling_step(_GUARD_STEP)
condition = str(guard["if"])
for needle in ("!cancelled()", "steps.tests.outcome == 'success'", "runner.os == 'Linux'"):
assert needle in condition, condition
# Pinned whole: without the `matrix.shard` clause the guard runs three times, and with a number
# no ubuntu leg has it never runs.
assert condition == (
"${{ !cancelled() && steps.tests.outcome == 'success' && runner.os == 'Linux'"
f" && matrix.shard == '{_UBUNTU_LEGS[0]['shard']}' }}}}"
)
match = re.fullmatch(
r"python scripts/quality/shard_tests\.py --suite tooling --of (\d+) --check-collection"
r" -- (.+)",
str(guard["run"]).strip(),
)
assert match, guard["run"]
shard_counts = {leg["of"] for leg in full_matrix if leg["of"] != "1"}
shard_counts = {leg["of"] for leg in full_matrix}
assert shard_counts == {match.group(1)}, (shard_counts, match.group(1))
# The selection is every `-m` and every `--ignore-glob` the harness line carries, and the
# guard's tail must be exactly that: a narrower or broader guard compares the wrong collection.
Expand Down Expand Up @@ -561,8 +572,8 @@ def receipt(executed: int, skipped: int, shards: int) -> int:
#
# The damage shape is what makes it worth an arm of its own. Without the utilities the detector's
# `grep -qE` cannot run, the `if` takes its else branch, the step writes `tooling=false`, and
# `test_a_docs_only_pr_gets_one_leg_and_a_code_pr_gets_both` fails saying THE FILTER MUST NOT
# NARROW -- a sentence about ci.yml, produced by a box that never read ci.yml's answer. A reader
# `test_a_docs_only_pr_gets_the_ubuntu_legs_and_a_code_pr_gets_both` fails saying THE FILTER MUST
# NOT NARROW -- a sentence about ci.yml, produced by a box that never read ci.yml's answer. A reader
# acting on it edits a workflow that was never wrong. Measured on one variable before the fix: this
# module was 27 passed with coreutils on PATH and 1 failed without.
# ---------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/test_quality_shard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def run(*_a: object, **_k: object) -> subprocess.CompletedProcess[str]:
@pytest.fixture(scope="module")
def tooling_shards() -> int:
"""ci.yml's tooling shard count, read from its partition guard, which
tests/test_ci_tooling_gate.py holds to the windows-2025 legs' `of`. A fixture, so a drifted
tests/test_ci_tooling_gate.py holds to every leg's `of`. A fixture, so a drifted
guard line fails these tests rather than this module's collection."""
text = (_ROOT / ".github" / "workflows" / "ci.yml").read_text(encoding="utf-8")
counts = set(re.findall(r"shard_tests\.py --suite tooling --of (\d+) --check-collection", text))
Expand Down
Loading
Loading