Skip to content
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable changes to this project are documented here, following

## [Unreleased]

### Fixed

- `sdlc ci` and `sdlc tiers` now name the push verdicts a repo took out of
ci with `[tool.sdlc.push] skip`, as one line:
`sdlc ci: not run, skipped in [tool.sdlc.push]: lint, codeql` (#50).
Before, a skipped verdict was simply absent, so a green ci could not be
told from one that opted out.

## [0.7.1] - 2026-11-17

### Changed
Expand Down
24 changes: 24 additions & 0 deletions sdlc
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ def resolve(cfg: dict, command: str) -> list[str]:
return out


def push_skips(cfg: dict) -> list[str]:
"""The push verdicts ci does not run because [tool.sdlc.push] skips them.

That skip is the only way a repo takes a verdict out of ci, and a verdict
that is not run is otherwise just absent: a green `sdlc ci` read the same
whether the repo ran lint or opted out of it (python-sdlc#50).
"""
drop = set(names(block(cfg, "push").get("skip"), "[tool.sdlc.push] skip"))
ci = resolve(cfg, "ci")
return [c for c in DEFAULTS["push"] if c in drop and c not in CI_EXCLUDES and c not in ci]


def push_skip_line(cfg: dict) -> str | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL (Documentation): The new public function push_skip_line has no documentation. Its return value and the conditions under which it returns None are not described.

Suggestion: Add a docstring describing the formatted skip notice and that the function returns None when there are no push skips to report.

Evidence:

def push_skip_line(cfg: dict) -> str | None:
    gone = push_skips(cfg)
    return f"sdlc ci: not run, skipped in [tool.sdlc.push]: {', '.join(gone)}" if gone else None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug: push_skip_line is a one-line formatter over push_skips, whose docstring sits directly above it and explains what is named and why. Its str | None return type and the if gone else None expression already say when it returns None. Small helpers in this script, like block and names, carry no docstring, and this follows that convention. sdlc is a script, not a library with a public API.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL (Documentation): The newly added public function push_skip_line has no docstring describing its behavior or return value.

Suggestion: Add a docstring explaining that it returns the formatted skip notice when push verdicts are skipped, and None when there are none.

Evidence:

def push_skip_line(cfg: dict) -> str | None:
    gone = push_skips(cfg)
    return f"sdlc ci: not run, skipped in [tool.sdlc.push]: {', '.join(gone)}" if gone else None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug: this is the same finding as discussion_r4597617417, raised again on the rebased head, and it gets the same answer. push_skip_line is a one-line formatter over push_skips, and push_skips' docstring sits directly above it. The str | None signature and the if gone else None expression already say when it returns None. That matches the script's other small helpers, like block and names.

gone = push_skips(cfg)
return f"sdlc ci: not run, skipped in [tool.sdlc.push]: {', '.join(gone)}" if gone else None


def check_settings(cfg: dict, name: str) -> dict:
"""A check's own table, wherever it is written. Names are unique."""
found = [
Expand Down Expand Up @@ -469,6 +486,10 @@ def t_plan(target: str) -> int:
for check in checks:
if check not in BUILTINS and kind_of(cfg, check) is None:
cannot(f"unknown check: {check}")
# stderr, because stdout is the plan the launcher parses.
line = push_skip_line(cfg) if target == "ci" else None
if line:
print(line, file=sys.stderr)
lanes = lane_of(cfg, checks)
for check in checks:
lane = plain(lanes[check], "a lane name")
Expand All @@ -495,6 +516,9 @@ def t_tiers() -> int:
print(f" {check}{note}")
if parallel:
print(f" {len(set(lanes.values()))} lanes, run at the same time")
line = push_skip_line(cfg) if command == "ci" else None
if line:
print(f" {line}")
if skipped():
print(f"\nSDLC_SKIP is skipping: {', '.join(sorted(skipped()))}")
return CLEAN
Expand Down
40 changes: 40 additions & 0 deletions tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,46 @@ def plan_of(target: str, pyproject: str, **env) -> list[list[str]]:
return [line.split("\t") for line in buf.getvalue().splitlines()]


# python-sdlc#50: a push skip is the only way a verdict leaves ci, so ci and
# tiers say so; otherwise a green ci reads the same whether lint ran or not.
check("no push skip, nothing to report", S.push_skips(empty) == [])
check(
"a push skip is named, in push order",
S.push_skips({"push": {"skip": ["codeql", "lint"]}}) == ["lint", "codeql"],
)
check(
"the reviewers ci never runs are not named",
S.push_skips({"push": {"skip": ["gatehouse", "mypy"]}}) == ["mypy"],
)
check(
"a verdict ci adds back is not named",
S.push_skips({"push": {"skip": ["lint"]}, "ci": {"checks": ["lint"]}}) == [],
)


def stderr_and_stdout(fn, target: str | None, pyproject: str) -> tuple[str, str]:
with tempfile.TemporaryDirectory() as root:
Path(root, "pyproject.toml").write_text(pyproject)
S.REPO = Path(root)
out, err = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
fn(*([target] if target else []))
return err.getvalue(), out.getvalue()


SKIPS = '[tool.sdlc.push]\nskip = ["lint", "codeql"]\n'
NAMED = "sdlc ci: not run, skipped in [tool.sdlc.push]: lint, codeql"
err, out = stderr_and_stdout(S.t_plan, "ci", SKIPS)
check("sdlc ci names its push skips once", err.splitlines() == [NAMED], err)
check("the plan itself stays clean", NAMED not in out, out)
err, _ = stderr_and_stdout(S.t_plan, "push", SKIPS)
check("only ci names them", err == "", err)
err, _ = stderr_and_stdout(S.t_plan, "ci", "[tool.ruff]\n")
check("a repo that skips nothing hears nothing", err == "", err)
_, out = stderr_and_stdout(S.t_tiers, None, SKIPS)
check("sdlc tiers prints the same line", f" {NAMED}" in out.splitlines(), out)


TRENTINA = """
[project]
name = "fx"
Expand Down
Loading