mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
feat(ci): cut redundant coverage from the deploy matrix
A clone and a row an earlier one already embeds prove nothing the sweep does not already prove, but both still took a slot. Drop them when the regular line is chunked, so the budget buys unique coverage only, and mark them in the plan table with a status of their own instead of letting them read as 'beyond the budget'. A priority row is exempt: an operator who pins a clone asked for that deploy, and dropping it would be the silent withdrawal 6605c7ef9 just removed. The cut sits in chunks_of, not in entries_of, so the plan still lists every candidate while no chunk can see one. 55 of 254 rows are cut on this branch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7b57ba4898
commit
e846063f5e
6 files changed
+86
-11
No files matched your search
+13
-2
@@ -140,6 +140,13 @@ def offset_index(raw: int | str | None, regular: list[dict[str, str]]) -> int:
|
||||
)
|
||||
|
||||
|
||||
def redundant(entry: dict[str, str]) -> bool:
|
||||
"""Whether the sweep drops this row as coverage an earlier row already has."""
|
||||
if entry["priority"] == "true":
|
||||
return False
|
||||
return entry["clone"] == "true" or entry["covered"] != "0"
|
||||
|
||||
|
||||
def chunks_of(
|
||||
entries: list[dict[str, str]], offset: int | str | None = 0
|
||||
) -> list[list[dict[str, str]]]:
|
||||
@@ -149,7 +156,11 @@ def chunks_of(
|
||||
*inside* a chunk is then sorted
|
||||
(:func:`utils.github.variant.axes.sort_key`), so the job list reads by role
|
||||
rather than by rank."""
|
||||
regular = [entry for entry in entries if entry["priority"] != "true"]
|
||||
regular = [
|
||||
entry
|
||||
for entry in entries
|
||||
if entry["priority"] != "true" and not redundant(entry)
|
||||
]
|
||||
return [
|
||||
sorted(chunk, key=axes.sort_key)
|
||||
for chunk in chunks.plan(
|
||||
@@ -216,7 +227,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
offset=resolve_offset(args.offset),
|
||||
)
|
||||
chunk = plan[args.index] if 0 <= args.index < len(plan) else []
|
||||
dropped = ("priority", "weight", "id", "covered")
|
||||
dropped = ("priority", "weight", "id", "covered", "clone")
|
||||
print(json.dumps([{k: v for k, v in e.items() if k not in dropped} for e in chunk]))
|
||||
return 0
|
||||
|
||||
|
||||
+6
-2
@@ -11,7 +11,8 @@ diverge. One row per ``role#variant`` candidate in global query order, with
|
||||
the chunk it falls into and the axes it was assigned.
|
||||
|
||||
Status per row: ⭐ a priority row, ✅ deployed by this sweep, ❌ beyond the
|
||||
sweep's budget (raise ``--offset`` to reach it). ``--chunk`` marks the
|
||||
sweep's budget (raise ``--offset`` to reach it), ✂️ cut as redundant coverage —
|
||||
a clone or a row an earlier one already embeds, which no sweep deploys. ``--chunk`` marks the
|
||||
block the calling job is running, so a chunk's summary shows its own slice in
|
||||
the context of the whole chain. ``--cli`` renders fixed-width terminal tables
|
||||
instead of Markdown.
|
||||
@@ -38,6 +39,7 @@ _STAR = to_emoji("priority")
|
||||
_OK = to_emoji("enabled")
|
||||
_OFF = to_emoji("disabled")
|
||||
_HERE = to_emoji("skip")
|
||||
_CUT = to_emoji("redundant")
|
||||
|
||||
_COLUMNS = ("chunk", "id", "covered_by", "name", "weight", "variant", "mode", "distros")
|
||||
_HEADERS = (
|
||||
@@ -74,7 +76,9 @@ def cells(
|
||||
rows = []
|
||||
for counter, entry in enumerate(entries, start=1):
|
||||
chunk = _chunk_of(entry, plan)
|
||||
if chunk is None:
|
||||
if matrix.redundant(entry):
|
||||
status, where = _CUT, ""
|
||||
elif chunk is None:
|
||||
status, where = _OFF, ""
|
||||
else:
|
||||
status = _STAR if entry["priority"] == "true" else _OK
|
||||
|
||||
@@ -6,13 +6,23 @@ import unittest.mock as mock
|
||||
from cli.meta.ci import matrix
|
||||
|
||||
|
||||
def _entry(app: str, variant: str, mode: str, *, priority: bool = False) -> dict:
|
||||
def _entry(
|
||||
app: str,
|
||||
variant: str,
|
||||
mode: str,
|
||||
*,
|
||||
priority: bool = False,
|
||||
covered: str = "0",
|
||||
clone: bool = False,
|
||||
) -> dict:
|
||||
return {
|
||||
"apps": app,
|
||||
"variant": variant,
|
||||
"mode": mode,
|
||||
"tor": "false",
|
||||
"priority": "true" if priority else "false",
|
||||
"covered": covered,
|
||||
"clone": "true" if clone else "false",
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +75,32 @@ _REGULAR = [
|
||||
]
|
||||
|
||||
|
||||
class TestRedundant(unittest.TestCase):
|
||||
def _chunked(self, entries: list[dict]) -> list[dict]:
|
||||
with (
|
||||
mock.patch.object(matrix.slots, "chunk_size", return_value=10),
|
||||
mock.patch.object(matrix.slots, "chunk_count", return_value=4),
|
||||
mock.patch.object(matrix.slots, "available", return_value=99),
|
||||
):
|
||||
return [row for chunk in matrix.chunks_of(entries, 0) for row in chunk]
|
||||
|
||||
def test_a_covered_row_never_reaches_a_chunk(self) -> None:
|
||||
entries = [_entry("web-app-a", "0", "compose", covered="7")]
|
||||
self.assertEqual(self._chunked(entries), [])
|
||||
|
||||
def test_a_clone_never_reaches_a_chunk(self) -> None:
|
||||
entries = [_entry("web-app-a", "0", "compose", clone=True)]
|
||||
self.assertEqual(self._chunked(entries), [])
|
||||
|
||||
def test_a_plain_row_still_reaches_a_chunk(self) -> None:
|
||||
entries = [_entry("web-app-a", "0", "compose")]
|
||||
self.assertEqual(len(self._chunked(entries)), 1)
|
||||
|
||||
def test_a_pinned_clone_is_kept(self) -> None:
|
||||
entries = [_entry("web-app-a", "0", "compose", priority=True, clone=True)]
|
||||
self.assertEqual(len(self._chunked(entries)), 1)
|
||||
|
||||
|
||||
class TestOffsetIndex(unittest.TestCase):
|
||||
def test_nothing_given_starts_at_the_head(self) -> None:
|
||||
for raw in (None, "", 0, "0"):
|
||||
|
||||
@@ -14,6 +14,7 @@ def _entry(
|
||||
priority: bool = False,
|
||||
identifier: str = "0",
|
||||
covered: str = "0",
|
||||
clone: bool = False,
|
||||
) -> dict:
|
||||
return {
|
||||
"apps": app,
|
||||
@@ -25,16 +26,18 @@ def _entry(
|
||||
"weight": "42",
|
||||
"id": identifier,
|
||||
"covered": covered,
|
||||
"clone": "true" if clone else "false",
|
||||
"label": f"{to_emoji(mode)}{app} {variant}",
|
||||
}
|
||||
|
||||
|
||||
_PRIORITY = [_entry("web-app-a", "0", "compose", priority=True, identifier="3")]
|
||||
_REGULAR = [
|
||||
_entry("web-app-b", "0", "swarm", identifier="5", covered="7"),
|
||||
_entry("web-app-b", "0", "swarm", identifier="5"),
|
||||
_entry("web-app-b", "1", "compose", identifier="9"),
|
||||
]
|
||||
_ENTRIES = _PRIORITY + _REGULAR
|
||||
_CUT = [_entry("web-app-c", "0", "compose", identifier="11", covered="7")]
|
||||
_ENTRIES = _PRIORITY + _REGULAR + _CUT
|
||||
|
||||
|
||||
class TestCells(unittest.TestCase):
|
||||
@@ -42,7 +45,7 @@ class TestCells(unittest.TestCase):
|
||||
rows = plan.cells(
|
||||
_ENTRIES, [_PRIORITY, _REGULAR], distros="debian", current=None
|
||||
)
|
||||
self.assertEqual([row[0] for row in rows], ["0", "1", "1"])
|
||||
self.assertEqual([row[0] for row in rows], ["0", "1", "1", ""])
|
||||
|
||||
def test_a_priority_row_is_starred_not_ticked(self) -> None:
|
||||
rows = plan.cells(
|
||||
@@ -75,14 +78,33 @@ class TestCells(unittest.TestCase):
|
||||
_ENTRIES, [_PRIORITY, _REGULAR], distros="debian", current=None
|
||||
)
|
||||
self.assertEqual(rows[0][covered], "")
|
||||
self.assertEqual(rows[1][covered], "7")
|
||||
self.assertEqual(rows[3][covered], "7")
|
||||
|
||||
def test_a_covered_row_is_cut_instead_of_deployed(self) -> None:
|
||||
rows = plan.cells(
|
||||
_ENTRIES, [_PRIORITY, _REGULAR], distros="debian", current=None
|
||||
)
|
||||
self.assertEqual(rows[3][-1], to_emoji("redundant"))
|
||||
self.assertEqual(rows[3][0], "")
|
||||
|
||||
def test_a_clone_is_cut_as_well(self) -> None:
|
||||
entries = _ENTRIES + [_entry("web-app-d", "0", "compose", clone=True)]
|
||||
rows = plan.cells(
|
||||
entries, [_PRIORITY, _REGULAR], distros="debian", current=None
|
||||
)
|
||||
self.assertEqual(rows[-1][-1], to_emoji("redundant"))
|
||||
|
||||
def test_a_pinned_clone_stays_in_the_run(self) -> None:
|
||||
entries = [_entry("web-app-d", "0", "compose", priority=True, clone=True)]
|
||||
rows = plan.cells(entries, [entries], distros="debian", current=None)
|
||||
self.assertEqual(rows[0][-1], to_emoji("priority"))
|
||||
|
||||
def test_the_id_is_the_discovery_id_the_covered_by_points_at(self) -> None:
|
||||
identifier = plan._COLUMNS.index("id")
|
||||
rows = plan.cells(
|
||||
_ENTRIES, [_PRIORITY, _REGULAR], distros="debian", current=None
|
||||
)
|
||||
self.assertEqual([row[identifier] for row in rows], ["3", "5", "9"])
|
||||
self.assertEqual([row[identifier] for row in rows], ["3", "5", "9", "11"])
|
||||
|
||||
def test_the_tor_state_is_rendered_as_its_glyph(self) -> None:
|
||||
rows = plan.cells(
|
||||
@@ -114,7 +136,7 @@ class TestRender(unittest.TestCase):
|
||||
out = plan.render_markdown("sweep 0", self._rows())
|
||||
body = [line for line in out.splitlines() if line.startswith("| web")]
|
||||
self.assertEqual(len(body), 0)
|
||||
self.assertEqual(len([ln for ln in out.splitlines() if ln.startswith("| ")]), 4)
|
||||
self.assertEqual(len([ln for ln in out.splitlines() if ln.startswith("| ")]), 5)
|
||||
|
||||
def test_cli_pads_to_display_width(self) -> None:
|
||||
out = plan.render_cli("sweep 0", self._rows())
|
||||
|
||||
@@ -433,6 +433,7 @@ def assign(
|
||||
"weight": str(row.get("weight", 0)),
|
||||
"id": str(row.get("id", 0)),
|
||||
"covered": str(row.get("covered_by", 0)),
|
||||
"clone": "true" if row.get("clone") else "false",
|
||||
"artifact": artifact_slug(mode, app, variant_csv, enabled),
|
||||
"label": f"{glyphs}{label}"
|
||||
+ (f" {to_emoji('priority')}" if priority else ""),
|
||||
|
||||
@@ -48,6 +48,7 @@ SYMBOLS: dict[str, str] = {
|
||||
"clone": "🐑",
|
||||
"siblings": "👯",
|
||||
"covered_by": "🔰",
|
||||
"redundant": "✂️",
|
||||
"planned": "🧭",
|
||||
"pre-alpha": "🧪",
|
||||
"alpha": "🐣",
|
||||
|
||||
Reference in new issue
Block a user