Skip to content

The agent that grows with you

feat(check): run the blob-size guard in scripts/check

Teknium9c5a59c63fde
diff --git a/scripts/check b/scripts/check
index cb318c56f11..783553041f6 100755
--- a/scripts/check
+++ b/scripts/check
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Run every blocking lint check CI runs, locally, with the same pinned tools: the lint
-workflow's guards, ruff and the code-health ratchet, plus the case-collision, lazy-deps and
-profile-archive guards that CI runs in workflows of their own.
+the workflow's guards, ruff and the code-health ratchet, plus the case-collision, lazy-deps,
+profile-archive and blob-size guards that CI runs in workflows of their own.
python scripts/check # everything, against the merge-base with origin/main
python scripts/check --only health # just the code-health ratchet
@@ -100,7 +100,7 @@ exit $status
# name -> argv (relative to the repo root); mirrors the blocking steps in lint.yml, plus the
# unconditional guards CI runs in their own workflows (case-collision-check.yml,
-# lazy-deps-guard.yml, profile-artifact-check.yml).
+# lazy-deps-guard.yml, profile-artifact-check.yml, blob-size-check.yml).
_GUARDS = {
"footguns": ["scripts/check-windows-footguns.py", "--all"],
"shebangs": ["scripts/check_bash_shebangs.py"],
@@ -112,7 +112,10 @@ _GUARDS = {
"lazy-deps": ["scripts/ci/check_lazy_deps_imports.py"],
"profile-archives": ["scripts/ci/check_profile_archive_boundary.py"],
}
-_CHECKS = (*_GUARDS, "ruff", "health")
+# Guards that judge a diff, not a tree: they get the same base/head as the ratchet
+# (blob-size-check.yml).
+_DIFF_GUARDS = {"blob-size": ["scripts/ci/check_blob_size.py"]}
+_CHECKS = (*_GUARDS, *_DIFF_GUARDS, "ruff", "health")
@dataclass
@@ -166,6 +169,11 @@ def _jobs(names: list[str], base: str | None, head: str | None,
for name in names: # built only when selected: `--only shebangs` needs no ruff
if name in _GUARDS:
jobs[name] = _Job([sys.executable, *_GUARDS[name]], root, env)
+ elif name in _DIFF_GUARDS:
+ argv = [sys.executable, *_DIFF_GUARDS[name]]
+ argv += ["--base", base] if base else []
+ argv += ["--head", head] if head else []
+ jobs[name] = _Job(argv, root, env)
elif name == "ruff":
jobs[name] = _Job([*resolve_ruff(root), "check", "."], root, env)
else:
@@ -245,7 +253,7 @@ def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(prog="scripts/check", description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--only", help=f"comma list of: {', '.join(_CHECKS)}")
- parser.add_argument("--base", help="base revision for the code-health ratchet")
+ parser.add_argument("--base", help="base revision for the code-health ratchet and blob-size")
target = parser.add_mutually_exclusive_group()
target.add_argument("--staged", action="store_true",
help="check the index (what `git commit` records), not the working tree")
diff --git a/tests/scripts/test_code_health_cli.py b/tests/scripts/test_code_health_cli.py
index 904a42eff55..3ac15b7cc69 100644
--- a/tests/scripts/test_code_health_cli.py
+++ b/tests/scripts/test_code_health_cli.py
@@ -27,7 +27,7 @@ _GUARD_SCRIPTS = (
"scripts/check_no_tmp_literals.py", "scripts/check_config_yaml_writers.py",
"scripts/ci/check_os_marker_fakes.py", "scripts/check-case-collisions.py",
"scripts/ci/check_lazy_deps_imports.py", "scripts/ci/check_profile_archive_boundary.py",
- "scripts/ci/check_agents_md_size.py",
+ "scripts/ci/check_agents_md_size.py", "scripts/ci/check_blob_size.py",
)
_SUPPORT = ("scripts/ci/profile_scope_patterns.json", "agent/subdirectory_hints.py", *_GUARD_SCRIPTS)
_LEGACY = "def legacy(x):\n" + "".join(f" if x == {i}:\n return {i}\n" for i in range(21))
@@ -382,6 +382,7 @@ def test_hooks_run_with_msys_path_conversion_disabled(tmp_path):
("case-collisions", {"pkg/Notes.md": "a\n", "pkg/NOTES.md": "b\n"}),
("lazy-deps", {"pkg/uses.py": "import tools.lazy_deps\n"}),
("profile-archives", {"pkg/export.tar.gz": "not really\n"}),
+ ("blob-size", {"pkg/shot.png": "\0" * (600 * 1024)}),
])
def test_ci_only_guards_run_in_scripts_check(tmp_path, job, files):
repo = _engine_repo(tmp_path)