Skip to content

Commit b96c3ad

Browse files
authored
feat(ci-lint): scan fixes + runtime commands (units, tests size, wheel, gate, local mode) (#11)
* fix(ci-lint): scan file scope, comment/string stripping, PKG-003 tables, CACHE-004 pre-prune Fixes five round-1A defects found by running precheck against the restructured template: 1. Every text/AST scan (LAYOUT-001, GEN-005's tracked-script scan, TOOL-001's Python AST scan, RUST-011's cfg(feature) scan, PKG-005) now iterates git-tracked files via the new ci_lint.repo_files.list_repo_files (git ls-files -co --exclude-standard) when --repo is a git work tree, falling back to a filesystem walk (skipping .git/target/.venv*/ .cargo/registry/node_modules/dist/__pycache__) only for a non-git fixture dir. Previously a plain filesystem walk scanned gitignored .cargo/registry/** unconditionally (1,750 bogus findings on the template). 2. New ci_lint.rust_lexer and ci_lint.py_lexer strip comment and string-literal content (preserving line numbers) before LAYOUT-001 and RUST-011's cfg(feature) scans run, so a doc comment merely mentioning a selector is no longer flagged as real code. 3. PKG-003 now accepts soldr's documented list-of-tables `bundle-bins` shape ([{ bin = "...", package = "..." }]) in addition to plain strings. 4. CACHE-004: `pre-prune = true` on every writer flow now removes only the lockfile-change-peak term from the worst-case sum (worst = steady + pr.budget) instead of waiving the whole budget proof; the arithmetic output states which formula applied. 5. examples/rust-pypi-app/ci.toml: dylint-out max lowered to 150MB and pre-prune = true added to flow.main/flow.nightly, which CACHE-004 (with the fixed formula) now requires to fit the example under its declared 9GB budget. Each defect has RED (pre-fix behavior, captured by running round-1A's original module code against the new fixtures) -> GREEN (fixed code) evidence and a permanent regression test. * feat(ci-lint): runtime commands (units, tests size, wheel, gate, local mode, selftest) Implements round-2A part 2: the runtime commands that read a real cargo build's --message-format=json output, a built wheel, or an installed venv -- replacing round-1A's stubs for `units`/`tests`, and adding `wheel`, `gate` and `selftest`. - ci_lint.cargo_messages: typed parser for cargo's compiler-artifact JSON Lines output (ignores non-artifact/non-JSON lines). - `ci_lint units --repo <path> --artifacts <file.jsonl>`: counts distinct (features, profile, target kind, target triple) combinations per workspace crate; RUST-011 if a private crate compiled with >1 feature set in one profile, or the public crate compiled outside [rust].ship. Target triple is read from the build output path against declared [platforms].*.target, never guessed from a generic regex. - `ci_lint tests size --repo <path> --artifacts <file.jsonl>`: maps profile.test executables to the <crate>:lib/:bin:<name>/:test:<name> naming scheme and checks them against [rust.tests] (RUST-012): undeclared, declared-but-missing, over max-binary, or sum over max-total. - `ci_lint wheel check --repo <path> --wheel <path.whl> [--sdist ...]`: stdlib zipfile only. PKG-003 (bundled CLI present, no shebang, magic bytes match the wheel's platform tag via ELF/PE/Mach-O header parsing, no console_scripts shadow), PKG-004 (WHEEL Generator reported as needs_review if it doesn't mention soldr; abi3 tag check; optional sdist backend check), PKG-005 (_native extension present). - `ci_lint wheel installed --repo <path> --venv <dir>`: same magic check against the host, `<cli> --version` exits 0, and the venv python can import `<pkg>._native` as a compiled extension. - `ci_lint gate --repo <path> --plan <plan.json> --needs <needs.json>`: the CI OK aggregator. Every plan.required_jobs entry must be needs[job].result == "success" (a skip is TEST-001; a job absent from needs is needs_review, never a silent pass). plan.mergeable == false always fails with "not mergeable: tag(s) ... remove required coverage". - `ci_lint precheck --local` (or env ACT=true) is now wired through (it was previously parsed and ignored): explicitly reports each not-yet-implemented live-GitHub-API check (CACHE-005/006/008, ACT-001) as needs_review "skipped (local): ...", never silently passing them. - `ci_lint selftest` runs the package's own unittest suite (stdlib only; zccache#1760 -- agents must be able to run it directly). - ci_lint.plan.Plan gained `required_jobs` (the job-id convention ci-lint gate expects; documented in _required_job_ids) and `needs_platform_lanes`; `dylint_targets` now correctly lists every declared platform when [lint.dylint].targets = "all-platforms", decoupled from the tag-selected build platforms (it was previously narrowed to the selected subset, which undercounted Dylint's coverage for an untagged PR). `--github-output` gained dylint_targets_json and needs_platform_lanes. Tests use small recorded --message-format=json / wheel / plan+needs fixtures under ci_lint/tests/fixtures/runtime/, never a real cargo/soldr invocation. * fix(ci-lint): amend gate job-id convention, per enum, needs_platform_lanes Orchestrator amendments to round-2A: 1. Job-id convention for `ci-lint gate`/`Plan.required_jobs` is now: precheck, fast (default linux-x64 build+unit+smoke lane), dylint (when dylint_targets is non-empty), and -- only when needs_platform_lanes -- platform-build/platform-run (matrix jobs; GitHub aggregates every leg into one needs.<id>.result). Drops the previous build-<platform-id>-per-platform convention. "ci-ok" (the gate job itself) is never in required_jobs. Updated ci_lint.plan._required_job_ids, gate/plan fixtures, docs/ci-toml.md, and added a test that feeds a needs.json with exactly the platform-lanes id set. 2. [cache.family.<id>].per is now a strict enum (CACHE_FAMILY_PER_VALUES = none/platform/cross-platform/os) validated in ci_lint.schema; any other value (e.g. the template's former "target") is CT-002 with a fix message listing the allowed values, never a silent fallback to cardinality 1 in CACHE-004's arithmetic. RED/GREEN fixtures: CT-002/red-cache-per (per = "target") and CT-002/green-cache-per (per = "platform"). 3. needs_platform_lanes is now true exactly when the plan selects any platform other than [flow.pr]'s own default fast-lane platform(s), not merely "more than one platform" -- release/nightly's platforms = "all" base is itself already beyond that fixed baseline, so they still need the platform matrix even though no tag added anything. Added ci_lint.plan._default_fast_lane_platforms and tests for flow.pr (false), [ci-windows] (true), release and nightly (true, even with zero tags), and push:main (false, inherits pr's base). 126 tests pass with and without PyYAML (was 119); `ci_lint selftest` confirms both ways too.
1 parent 913eeee commit b96c3ad

67 files changed

Lines changed: 3800 additions & 139 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This repository defines fleet CI policy and the planned checker. Read the policy
1010
4. [README.md](README.md) is the public summary and links to the source issues.
1111
5. [proposal.md](proposal.md) is the consolidated CI normalization proposal, repository evidence inventory, fbuild mapping, and implementation acceptance plan. Its proposed release-cycle and event-selection rules supersede earlier design examples; enforcement is not implemented.
1212
6. `docs/case-studies/` holds evidence-first writeups of a specific repository incident or investigation: [clud-ci-cost.md](docs/case-studies/clud-ci-cost.md), [soldr-ci-cost.md](docs/case-studies/soldr-ci-cost.md), [zccache-ci-cost.md](docs/case-studies/zccache-ci-cost.md), [fbuild-ci-cost.md](docs/case-studies/fbuild-ci-cost.md). A case study is not policy: it becomes binding only once its candidate rules are reviewed and written into `policy-general.md` or `policy-rust.md`. Candidate rule IDs across all case studies so far: `RUST-005`–`RUST-007`, `GEN-005`–`GEN-008`; keep new candidates numbered past these to avoid collisions.
13-
7. [`ci_lint/`](ci_lint/) is the standard-library-only Python package implementing the checker: `ci_lint.schema` loads and strictly validates `ci.toml` schema 3, `ci_lint.precheck` runs the static rule groups (`python3 -m ci_lint precheck`), and `ci_lint.plan` computes a run's flow/tag selection (`python3 -m ci_lint plan`). Runtime commands (`units`, `tests`, `cache`, `audit`) are stubs pending later rounds. [docs/ci-toml.md](docs/ci-toml.md) is the schema-3 field-by-field reference and rule catalog. [`examples/rust-pypi-app/ci.toml`](examples/rust-pypi-app/ci.toml) is the canonical example, copied verbatim from issue #6's draft.
13+
7. [`ci_lint/`](ci_lint/) is the standard-library-only Python package implementing the checker: `ci_lint.schema` loads and strictly validates `ci.toml` schema 3, `ci_lint.precheck` runs the static rule groups (`python3 -m ci_lint precheck`, `--local` skips GitHub-API-dependent checks explicitly), and `ci_lint.plan` computes a run's flow/tag selection (`python3 -m ci_lint plan`). Round-2A added the runtime commands that need a real build/artifact/venv: `ci_lint.runtime.units` (`python3 -m ci_lint units`), `ci_lint.runtime.tests_size` (`python3 -m ci_lint tests size`), `ci_lint.runtime.wheel` (`python3 -m ci_lint wheel check|installed`), `ci_lint.runtime.gate` (`python3 -m ci_lint gate`, the `CI OK` aggregator), and `ci_lint.selftest` (`python3 -m ci_lint selftest`, agents must be able to run this directly per zackees/zccache#1760). `cache` and `audit` are still stubs pending later rounds. [docs/ci-toml.md](docs/ci-toml.md) is the schema-3 field-by-field reference and rule catalog. [`examples/rust-pypi-app/ci.toml`](examples/rust-pypi-app/ci.toml) is the canonical example, copied verbatim from issue #6's draft.
1414

1515
## Working rules
1616

‎ci_lint/cargo_messages.py‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""Parse `cargo ... --message-format=json` output into typed records.
2+
3+
Round-2A brief, part 2a/2b: `ci-lint units` and `ci-lint tests size` both
4+
read the JSON Lines a `cargo build`/`cargo test --no-run` (etc.) run wrote
5+
with `--message-format=json`. That stream interleaves several message
6+
`reason`s (`compiler-message`, `build-script-executed`, `build-finished`,
7+
...) -- this module keeps only `compiler-artifact` records, converts them
8+
into a frozen dataclass (AGENTS.md: never a raw dict past the JSON
9+
boundary), and ignores everything else, including lines that are not even
10+
valid JSON (cargo/rustc occasionally interleave plain text on the same
11+
stream in practice).
12+
"""
13+
14+
from __future__ import annotations
15+
16+
import json
17+
from dataclasses import dataclass
18+
from pathlib import Path
19+
20+
# The JSON wire boundary itself, typed concretely per AGENTS.md -- never `Any`.
21+
JsonValue = None | bool | int | float | str | list["JsonValue"] | dict[str, "JsonValue"]
22+
23+
24+
@dataclass(frozen=True)
25+
class CompilerArtifact:
26+
"""One `{"reason": "compiler-artifact", ...}` cargo message, narrowed
27+
to the fields `units`/`tests size` need."""
28+
29+
package_name: str
30+
package_version: str
31+
manifest_path: str
32+
features: tuple[str, ...] # sorted
33+
opt_level: str
34+
debuginfo: str
35+
profile_test: bool
36+
target_name: str
37+
target_kinds: tuple[str, ...]
38+
filenames: tuple[str, ...]
39+
executable: str | None
40+
fresh: bool
41+
42+
43+
def _as_dict(value: JsonValue) -> dict[str, JsonValue]:
44+
return value if isinstance(value, dict) else {}
45+
46+
47+
def _as_str_tuple(value: JsonValue) -> tuple[str, ...]:
48+
if isinstance(value, list):
49+
return tuple(v for v in value if isinstance(v, str))
50+
return ()
51+
52+
53+
def _parse_package_id(package_id: JsonValue) -> tuple[str, str]:
54+
"""`package_id` is either the legacy `"name version (source)"` string
55+
or (cargo >= 1.77 with `-Znext-lockfile-bump`/newer toolchains) a
56+
`"registry+source#name@version"`-shaped SPEC string. Handle both; an
57+
unrecognized shape yields `("", "")` rather than raising, since a
58+
malformed/missing package_id must never crash the whole scan."""
59+
60+
if not isinstance(package_id, str):
61+
return "", ""
62+
if " " in package_id:
63+
parts = package_id.split(" ", 2)
64+
if len(parts) >= 2:
65+
return parts[0], parts[1]
66+
return parts[0], ""
67+
if "#" in package_id:
68+
tail = package_id.rsplit("#", 1)[1]
69+
if "@" in tail:
70+
name, version = tail.rsplit("@", 1)
71+
return name, version
72+
return tail, ""
73+
return package_id, ""
74+
75+
76+
def _one_artifact(doc: dict[str, JsonValue]) -> CompilerArtifact:
77+
name, version = _parse_package_id(doc.get("package_id"))
78+
manifest_path = doc.get("manifest_path")
79+
target = _as_dict(doc.get("target"))
80+
profile = _as_dict(doc.get("profile"))
81+
opt_level = profile.get("opt_level")
82+
debuginfo = profile.get("debuginfo")
83+
profile_test = profile.get("test")
84+
executable = doc.get("executable")
85+
fresh = doc.get("fresh")
86+
return CompilerArtifact(
87+
package_name=name,
88+
package_version=version,
89+
manifest_path=manifest_path if isinstance(manifest_path, str) else "",
90+
features=tuple(sorted(_as_str_tuple(doc.get("features")))),
91+
opt_level=str(opt_level) if opt_level is not None else "",
92+
debuginfo="none" if debuginfo is None else str(debuginfo),
93+
profile_test=profile_test is True,
94+
target_name=str(target.get("name") or ""),
95+
target_kinds=_as_str_tuple(target.get("kind")),
96+
filenames=_as_str_tuple(doc.get("filenames")),
97+
executable=executable if isinstance(executable, str) else None,
98+
fresh=fresh is True,
99+
)
100+
101+
102+
def parse_compiler_artifacts(lines: list[str]) -> list[CompilerArtifact]:
103+
"""Every `compiler-artifact` message in `lines`, in order. Non-JSON
104+
lines and JSON messages with a different `reason` are silently
105+
skipped -- that is the documented shape of `--message-format=json`
106+
output, not an error."""
107+
108+
out: list[CompilerArtifact] = []
109+
for raw_line in lines:
110+
line = raw_line.strip()
111+
if not line:
112+
continue
113+
try:
114+
msg: JsonValue = json.loads(line)
115+
except json.JSONDecodeError:
116+
continue
117+
doc = _as_dict(msg)
118+
if doc.get("reason") != "compiler-artifact":
119+
continue
120+
out.append(_one_artifact(doc))
121+
return out
122+
123+
124+
def load_artifacts_file(path: Path) -> list[CompilerArtifact]:
125+
text = path.read_text(encoding="utf-8")
126+
return parse_compiler_artifacts(text.splitlines())

‎ci_lint/cargo_scan.py‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
from dataclasses import dataclass
1616
from pathlib import Path
1717

18+
from ci_lint.repo_files import list_repo_files
19+
from ci_lint.rust_lexer import strip_comments_and_strings
20+
1821

1922
@dataclass(frozen=True)
2023
class CargoBinTarget:
@@ -241,15 +244,22 @@ def has_any_rust_test_attr(crate_src_dir: Path) -> bool:
241244
return False
242245

243246

244-
def has_cfg_feature(crate_dir: Path) -> bool:
245-
src_dir = crate_dir / "src"
246-
if not src_dir.is_dir():
247-
return False
248-
for f in src_dir.rglob("*.rs"):
247+
def has_cfg_feature(repo_root: Path, crate_dir_rel: str) -> bool:
248+
"""True if any git-tracked `.rs` file under `<crate_dir_rel>/src` uses
249+
`cfg(feature = ...)` / `cfg_attr(feature = ...)` in real code -- not
250+
merely mentioned inside a `//`/`///`/`//!`/`/* */` doc comment or a
251+
string literal (round-2A brief, defect 2: a doc comment mentioning
252+
`cfg(feature = "json")` was flagged as though it were real code)."""
253+
254+
prefix = f"{crate_dir_rel}/src/" if crate_dir_rel != "." else "src/"
255+
for rel in list_repo_files(repo_root):
256+
if not (rel.startswith(prefix) and rel.endswith(".rs")):
257+
continue
249258
try:
250-
text = f.read_text(encoding="utf-8", errors="replace")
259+
text = (repo_root / rel).read_text(encoding="utf-8", errors="replace")
251260
except OSError:
252261
continue
253-
if "cfg(feature" in text or "cfg_attr(feature" in text:
262+
code = strip_comments_and_strings(text)
263+
if "cfg(feature" in code or "cfg_attr(feature" in code:
254264
return True
255265
return False

‎ci_lint/cli.py‎

Lines changed: 149 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import sys
99
from pathlib import Path
1010

11+
from ci_lint.cargo_messages import load_artifacts_file
12+
from ci_lint.cargo_scan import discover_workspace
13+
from ci_lint.finding import Status
1114
from ci_lint.plan import Plan, PlanError, build_act_event, compute_plan
1215
from ci_lint.precheck import (
1316
has_violations,
@@ -16,8 +19,21 @@
1619
run_precheck,
1720
write_step_summary,
1821
)
22+
from ci_lint.runtime.gate import compute_gate
23+
from ci_lint.runtime.gate import render_text as render_gate_text
24+
from ci_lint.runtime.gate import to_json_dict as gate_to_json_dict
25+
from ci_lint.runtime.tests_size import compute_tests_size
26+
from ci_lint.runtime.tests_size import render_text as render_tests_size_text
27+
from ci_lint.runtime.tests_size import to_json_dict as tests_size_to_json_dict
28+
from ci_lint.runtime.units import compute_units
29+
from ci_lint.runtime.units import render_text as render_units_text
30+
from ci_lint.runtime.units import to_json_dict as units_to_json_dict
31+
from ci_lint.runtime.wheel import check_installed, check_wheel
32+
from ci_lint.runtime.wheel import installed_check_to_json_dict, wheel_check_to_json_dict
33+
from ci_lint.runtime.wheel import render_installed_check, render_wheel_check
1934
from ci_lint.runtime_stub import run_stub
20-
from ci_lint.schema import load_ci_toml
35+
from ci_lint.schema import CiToml, load_ci_toml
36+
from ci_lint.selftest import run_selftest
2137

2238

2339
def _load_event(path: str | None) -> dict[str, object]:
@@ -50,7 +66,7 @@ def _cmd_precheck(args: argparse.Namespace) -> int:
5066
event = _load_event(args.event)
5167
title = args.title if args.title is not None else (_title_from_event(event) or "")
5268

53-
result = run_precheck(repo_root, title=title)
69+
result = run_precheck(repo_root, title=title, local=args.local)
5470

5571
if args.json:
5672
print(render_json(result))
@@ -118,16 +134,104 @@ def _cmd_plan(args: argparse.Namespace) -> int:
118134
[p.id for p in plan.platforms if p.group != "linux"]
119135
)
120136
suites_json = json.dumps(list(plan.suites))
137+
dylint_targets_json = json.dumps(list(plan.dylint_targets))
121138
with open(gh_out, "a", encoding="utf-8") as fh:
122139
fh.write(f"plan={compact}\n")
123140
fh.write(f"platforms_json={platforms_json}\n")
124141
fh.write(f"cross_platforms_json={cross_platforms_json}\n")
125142
fh.write(f"suites_json={suites_json}\n")
143+
fh.write(f"dylint_targets_json={dylint_targets_json}\n")
144+
fh.write(f"needs_platform_lanes={'true' if plan.needs_platform_lanes else 'false'}\n")
126145
fh.write(f"mergeable={'true' if plan.mergeable else 'false'}\n")
127146

128147
return 0
129148

130149

150+
def _load_ci_or_die(repo_root: Path, command: str) -> CiToml | None:
151+
ci, findings = load_ci_toml(repo_root)
152+
if ci is None:
153+
for f in findings:
154+
print(f.render())
155+
print(f"ci-lint {command}: cannot load ci.toml", file=sys.stderr)
156+
return ci
157+
158+
159+
def _cmd_units(args: argparse.Namespace) -> int:
160+
repo_root = Path(args.repo).resolve()
161+
ci = _load_ci_or_die(repo_root, "units")
162+
if ci is None:
163+
return 1
164+
crates = discover_workspace(repo_root)
165+
artifacts = load_artifacts_file(Path(args.artifacts))
166+
report = compute_units(ci, crates, artifacts)
167+
print(json.dumps(units_to_json_dict(report), indent=2) if args.json else render_units_text(report))
168+
return 1 if any(f.status == Status.VIOLATION for f in report.findings) else 0
169+
170+
171+
def _cmd_tests_size(args: argparse.Namespace) -> int:
172+
repo_root = Path(args.repo).resolve()
173+
ci = _load_ci_or_die(repo_root, "tests size")
174+
if ci is None:
175+
return 1
176+
artifacts = load_artifacts_file(Path(args.artifacts))
177+
report = compute_tests_size(ci, artifacts)
178+
print(json.dumps(tests_size_to_json_dict(report), indent=2) if args.json else render_tests_size_text(report))
179+
return 1 if any(f.status == Status.VIOLATION for f in report.findings) else 0
180+
181+
182+
def _cmd_wheel_check(args: argparse.Namespace) -> int:
183+
repo_root = Path(args.repo).resolve()
184+
ci = _load_ci_or_die(repo_root, "wheel check")
185+
if ci is None:
186+
return 1
187+
sdist_path = Path(args.sdist) if args.sdist else None
188+
report = check_wheel(ci, Path(args.wheel), sdist_path)
189+
print(json.dumps(wheel_check_to_json_dict(report), indent=2) if args.json else render_wheel_check(report))
190+
return 1 if any(f.status == Status.VIOLATION for f in report.findings) else 0
191+
192+
193+
def _cmd_wheel_installed(args: argparse.Namespace) -> int:
194+
repo_root = Path(args.repo).resolve()
195+
ci = _load_ci_or_die(repo_root, "wheel installed")
196+
if ci is None:
197+
return 1
198+
report = check_installed(ci, repo_root, Path(args.venv))
199+
print(
200+
json.dumps(installed_check_to_json_dict(report), indent=2)
201+
if args.json
202+
else render_installed_check(report)
203+
)
204+
return 1 if any(f.status == Status.VIOLATION for f in report.findings) else 0
205+
206+
207+
def _cmd_gate(args: argparse.Namespace) -> int:
208+
try:
209+
with open(args.plan, encoding="utf-8") as fh:
210+
plan = json.load(fh)
211+
except (OSError, json.JSONDecodeError) as exc:
212+
print(f"ci-lint gate: cannot read --plan {args.plan!r}: {exc}", file=sys.stderr)
213+
return 1
214+
try:
215+
with open(args.needs, encoding="utf-8") as fh:
216+
needs = json.load(fh)
217+
except (OSError, json.JSONDecodeError) as exc:
218+
print(f"ci-lint gate: cannot read --needs {args.needs!r}: {exc}", file=sys.stderr)
219+
return 1
220+
if not isinstance(plan, dict) or not isinstance(needs, dict):
221+
print("ci-lint gate: --plan and --needs must both be JSON objects", file=sys.stderr)
222+
return 1
223+
224+
report = compute_gate(plan, needs)
225+
print(json.dumps(gate_to_json_dict(report), indent=2) if args.json else render_gate_text(report))
226+
if report.not_mergeable_message:
227+
print(report.not_mergeable_message, file=sys.stderr)
228+
return 0 if report.ok else 1
229+
230+
231+
def _cmd_selftest(_args: argparse.Namespace) -> int:
232+
return run_selftest()
233+
234+
131235
def build_parser() -> argparse.ArgumentParser:
132236
parser = argparse.ArgumentParser(prog="ci_lint")
133237
sub = parser.add_subparsers(dest="command", required=True)
@@ -153,8 +257,49 @@ def build_parser() -> argparse.ArgumentParser:
153257
p_plan.add_argument("--sha", default=None)
154258
p_plan.set_defaults(func=_cmd_plan)
155259

156-
for name in ("units", "tests", "cache", "audit"):
157-
p_stub = sub.add_parser(name, help=f"({name}: not implemented in round 1)")
260+
p_units = sub.add_parser("units", help="compile-unit count + RUST-011 from a cargo --message-format=json run")
261+
p_units.add_argument("--repo", default=".")
262+
p_units.add_argument("--artifacts", required=True)
263+
p_units.add_argument("--json", action="store_true")
264+
p_units.set_defaults(func=_cmd_units)
265+
266+
p_tests = sub.add_parser("tests", help="test-binary checks")
267+
tests_sub = p_tests.add_subparsers(dest="tests_command", required=True)
268+
p_tests_size = tests_sub.add_parser(
269+
"size", help="test-binary declaration + size budget (RUST-012) from a cargo --message-format=json run"
270+
)
271+
p_tests_size.add_argument("--repo", default=".")
272+
p_tests_size.add_argument("--artifacts", required=True)
273+
p_tests_size.add_argument("--json", action="store_true")
274+
p_tests_size.set_defaults(func=_cmd_tests_size)
275+
276+
p_wheel = sub.add_parser("wheel", help="wheel packaging checks (PKG-003/004/005)")
277+
wheel_sub = p_wheel.add_subparsers(dest="wheel_command", required=True)
278+
p_wheel_check = wheel_sub.add_parser("check", help="check a built wheel (+ optional sdist) by its own bytes")
279+
p_wheel_check.add_argument("--repo", default=".")
280+
p_wheel_check.add_argument("--wheel", required=True)
281+
p_wheel_check.add_argument("--sdist", default=None)
282+
p_wheel_check.add_argument("--json", action="store_true")
283+
p_wheel_check.set_defaults(func=_cmd_wheel_check)
284+
285+
p_wheel_installed = wheel_sub.add_parser("installed", help="check a wheel installed into a venv")
286+
p_wheel_installed.add_argument("--repo", default=".")
287+
p_wheel_installed.add_argument("--venv", required=True)
288+
p_wheel_installed.add_argument("--json", action="store_true")
289+
p_wheel_installed.set_defaults(func=_cmd_wheel_installed)
290+
291+
p_gate = sub.add_parser("gate", help="CI OK aggregator: plan.json's required_jobs vs needs.json")
292+
p_gate.add_argument("--repo", default=".")
293+
p_gate.add_argument("--plan", required=True)
294+
p_gate.add_argument("--needs", required=True)
295+
p_gate.add_argument("--json", action="store_true")
296+
p_gate.set_defaults(func=_cmd_gate)
297+
298+
p_selftest = sub.add_parser("selftest", help="run ci_lint's own unittest suite")
299+
p_selftest.set_defaults(func=_cmd_selftest)
300+
301+
for name in ("cache", "audit"):
302+
p_stub = sub.add_parser(name, help=f"({name}: not implemented yet -- see docs/ci-toml.md)")
158303
p_stub.add_argument("args", nargs=argparse.REMAINDER)
159304
p_stub.set_defaults(func=lambda _args, _name=name: run_stub(_name))
160305

0 commit comments

Comments
 (0)