Skip to content

test(ci): regression-test the Python complexity ratchet (#1639) - #1911

Merged
zackees merged 3 commits into
mainfrom
agent/1639-python-complexity-ratchet-tests
Nov 5, 2026
Merged

zackees merged 3 commits into
mainfrom
agent/1639-python-complexity-ratchet-tests

Conversation

@zackees

@zackees zackees commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Why

#1639 rolled out the workspace lint inheritance (all 21 members) and the Python
C901/RUF100 ratchet, but ci/check_python_complexity.py shipped with no
test at all
— git grep check_python_complexity found it only in
ci/README.md and check-ubuntu.yml. Nothing would fail if someone raised
max-complexity, dropped RUF100 from select, or broke the git ls-files
selection so the discovery-excluded scripts stopped being covered. Two of
#1639's acceptance criteria ("focused real linter regressions for a new
offender and obsolete suppression", "all tracked Python files are scanned,
including discovery-excluded scripts") were therefore unguarded assertions.

What

ci/check_python_complexity.py: split into its testable seams with unchanged
behaviour
— same exit code, same ruff invocation, ruff output still streamed
uncaptured:

  • tracked_python_files(root) — git ls-files -z -- '*.py', raises
    RatchetError on a git failure or an empty list;
  • ruff_command(paths) — the pinned ruff==0.12.12 invocation;
  • check(root) — the entry point main() now delegates to.

New ci/test_check_python_complexity.py (134 LOC, 7 tests):

test guards
clean module passes no false positives
11-decision function fails, output names C901 the ceiling is enforced
unnecessary # noqa: C901 fails, output names RUF100 obsolete suppressions must fail once unnecessary
policy parsed from pyproject.toml == ["C901","RUF100"] @ 10 the ratchet cannot be silently loosened
tracked selection covers ci/build_backend.py discovery-excluded scripts stay scanned
empty repo raises RatchetError the file list can't silently go empty
check(origin/main tree) == 0 the repo satisfies its own ratchet

Registered in both entry points — ci/local_suites.py
(DRIFT_UNITTEST_MODULES) and the ci-workflow-drift.yml unittest step — so
ci.test_local_suites' parity guard keeps hosted and local runs agreeing
(the #1855 two-face failure class).

Evidence

RED, by loosening the policy in place in the worktree and restoring it:

max-complexity = 10 -> 20
AssertionError: 0 == 0 : C901 must reject complexity 12        FAILED (failures=1)

select = ["C901","RUF100"] -> ["C901"]
AssertionError: 0 == 0 : an unnecessary noqa must fail the ratchet
                                                              FAILED (failures=1)

GREEN on the unchanged policy:

python -m unittest ci.test_check_python_complexity -v   -> Ran 7 tests ... OK
hosted self-test set (11 modules)                       -> Ran 103 tests in 1.758s ... OK
ci.test_local_suites (parity guard)                     -> OK
python ci/check_python_complexity.py  (100 tracked files) -> All checks passed!  RC=0
ruff check <changed python files>                       -> All checks passed!  RC=0
ci-workflow-drift.yml yaml parse                        -> ok

No Rust touched, no new workflow, no threshold raised, no noqa added; the
suite is 0.4 s (ruff runs from the uv cache) so it costs the drift job nothing.

Refs #1639.

Second commit: unblock Formatting for every PR

origin/main (86582926) does not satisfy soldr fmt --check:
bench/fastled-examples/src/build_comparison_tests.rs has two unformatted assert!
calls from the recent bench merges, so the Formatting job fails on every PR
regardless of its own content (hit #1911 first). 002eb367 is pure rustfmt output
(10 insertions / 4 deletions, no token or semantic change); soldr fmt --check is
clean afterwards. Flagging it here rather than in a separate PR because a separate PR
would be blocked by the same job.

Third commit: unblock Dylint Full for every PR

origin/main (86582926) is red on two jobs, both from the bench merges:
Formatting (fixed by 002eb367) and dylint / Dylint Full, which fails the
whole workspace with

error: raw '.fbuild' path literal: use fbuild_paths (FBUILD_DIR_NAME, BUILD_DIR_NAME,
       get_project_fbuild_dir, get_project_build_root, BuildLayout) instead of
       spelling the directory layout by hand
  --> bench/fastled-examples/src/build_comparison.rs:1008:38
  --> bench/fastled-examples/src/build_comparison_tests.rs:282:43

main's own runs confirm it (41980867753 failure Dylint, 41980867621 failure Formatting), so no PR can be green until this lands. 127fd3d7 replaces both
literals with the sanctioned fbuild_paths::get_project_fbuild_dir(&Path) — which
also makes the production cleanup step and its test expectation share one call
instead of two hand-spelled paths.

Verified: soldr cargo check --manifest-path bench/fastled-examples/Cargo.toml --tests rc 0; cargo test --bin bench-build-comparison -- cold_removes remove_cache_entries → 2 passed, 0 failed; soldr fmt --check clean.

#1639 rolled out the workspace lint inheritance and the
C901/RUF100 Python ratchet, but `ci/check_python_complexity.py` had no
test: the workflow ran the script and nobody would notice a loosened
ceiling, a dropped rule, or a file-selection change that stopped
covering the scripts unittest discovery skips.

Split the script into its testable seams (`tracked_python_files`,
`ruff_command`, `check`) with unchanged behaviour (same exit code, same
ruff output stream) and add `ci/test_check_python_complexity.py`:

- a module under the ceiling passes, an 11-decision function fails C901;
- an unnecessary `# noqa: C901` fails RUF100 (the AC that obsolete
  suppressions must fail once they are no longer needed);
- the policy itself is parsed from `pyproject.toml` and pinned to
  `select = ["C901", "RUF100"]` + `max-complexity = 10`;
- tracked file selection still covers discovery-excluded scripts such
  as `ci/build_backend.py`, and an empty repository is an error;
- `origin/main` satisfies its own ratchet.

The module is registered in both entry points (`ci/local_suites.py`
`DRIFT_UNITTEST_MODULES` and the `ci-workflow-drift.yml` step), so the
parity guard in `ci.test_local_suites` keeps them agreeing.

RED verified by loosening the policy in-place: ceiling 10 -> 20 makes
the C901 test fail (0 == 0), dropping RUF100 makes the obsolete-noqa
test fail. Restored, then 7/7 green; the full hosted self-test set is
103 tests OK.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

`origin/main` (8658292) does not satisfy `soldr fmt --check`: two
`assert!` calls in `bench/fastled-examples/src/build_comparison_tests.rs`
landed unformatted with the bench merges, so the `Formatting` job fails
on every PR regardless of its own content (observed on #1911).

Pure rustfmt output: no token or semantic change, 10 insertions / 4
deletions. `soldr fmt --check` is clean afterwards.
`origin/main` (8658292) is red on `dylint / Dylint Full` as well as
`Formatting`: the bench merges left two raw `".fbuild"` literals, which
`ban_raw_fbuild_path` denies, so the workspace-wide dylint passes on no
PR at all:

  error: raw '.fbuild' path literal: use fbuild_paths (FBUILD_DIR_NAME,
  BUILD_DIR_NAME, get_project_fbuild_dir, ...) instead of spelling the
  directory layout by hand
    --> bench/fastled-examples/src/build_comparison.rs:1008:38
    --> bench/fastled-examples/src/build_comparison_tests.rs:282:43

Use the sanctioned `fbuild_paths::get_project_fbuild_dir(&Path)` in both
the production `cold_cleanup_steps` arm and its test expectation, so the
two cannot drift apart either.

Verified: `soldr cargo check --manifest-path bench/fastled-examples/
Cargo.toml --tests` rc 0; the two affected tests pass
(2 passed, 0 failed); `soldr fmt --check` clean.
@zackees
zackees added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@zackees
zackees added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 678e4ad Nov 5, 2026
30 checks passed
@zackees
zackees deleted the agent/1639-python-complexity-ratchet-tests branch November 5, 2026 08:03
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant