Skip to content

fix(ci): devops ci checks run for real under their own --dry-run #885

Closed

Description

@dan-petty

Problem Statement

Paths are under src/devops_cli/. Evidence re-checked at 8271385 (release/v0.2.25, 2026-10-02); commands/ci.py and core/process.py are unchanged since decb600. At the branch tip 9c879ae the only cited files that changed are lang/en/help.py, lang/en/messages.py and config/constants.py; help.py:25 and constants.py:183 still hold, and the dry-run message template moved from messages.py:537 to :545, cited below at its 9c879ae line. The issue's original line numbers (from ef21785, which is not an ancestor of this branch) have drifted by three and are corrected below.

The commands. 14 devops ci commands declare --dry-run. When it is set, each one only calls set_dry_run(True) and then carries on: ci itself (commands/ci.py:710-711), test (:820), coverage (:853), lint (:887), format (:911), typecheck (:931), audit (:957), security (:977), actionlint (:997), docs (:1017), uv-check (:1036), lockfile (:1052), outdated (:1068) and run (:1138). A 15th, maintain (:1088-1097), is the only one that returns a dry-run preview (render_dry_run_result) without running anything; it stays as it is.

What happens under the flag.

  • The commands run their tools through _run (ci.py:172-185) or the async path (_execute_check_async, ci.py:259-298; _run_all_checks_async, :312-485). Both runners prepend --preview-features malware-check,check-command to uv argv and call the core runner unconditionally (_get("run_subprocess") at :181, _get("run_subprocess_async") at :275).
  • Under dry-run, run_subprocess and run_subprocess_async print Would run command and then run the command anyway (core/process.py:235-236, then subprocess.run at :266; :376-377, then asyncio.create_subprocess_exec at :409).
  • With subprocess.run recorded instead of run, devops ci lint --dry-run reached uv --preview-features malware-check,check-command run ruff check . --fix and exited 0. 12 ci subcommands reached their tool this way, and ci run reached the async runner.
  • The results:
    • devops lint --dry-run applies ruff fixes (ci.py:892-896);
    • devops format --dry-run reformats files (ci.py:916-921);
    • devops ci run --dry-run runs the whole gate with fixes on (ci.py:1141), including ruff format ., ruff check --fix . and devops docs generate --sync-readme (ci.py:341-365);
    • devops ci test --dry-run runs the test suite (ci.py:836-837);
    • the aggregate gate also deletes .coverage* and coverage.xml in the checked tree and its .data/ (_clean_coverage_artifacts, ci.py:222-242, called from _run_all_checks_async at :316, :373 and :473; its only guard is PYTEST_CURRENT_TEST, :224).
  • Dry-run bypasses the check cache (ci.py:623) and never saves one (:666, covered by tests/test_ci.py:751).
  • The option's own help promises the opposite: HELP.options.dry_run is "Preview execution plan without mutating external state." (lang/en/help.py:25).
  • Nothing else in these commands starts a process: _get_project_root resolves the worktree from files (core/repo.py:150-171, no run_subprocess), _verify_python_314_environment reads sys.version_info (ci.py:160), and _try_fast_cached_ci returns before computing a fingerprint under dry-run (:623). So a recorder on the process runner sees exactly the check tools.

Why it matters now. #412 makes devops --dry-run <cmd> forward to the command's own --dry-run. Today devops --dry-run lint only prints a Would run delegated command line from the lazy proxy (core/cli.py:127-134; lint and format are root-level aliases of the ci module, main.py:70-71, config/constants.py:183). After #412 it would reach this defect. #412 is not delivered (docs/agent/tasks/task-412-reachable-dry-run-previews-for-delegated-commands.md is Status: Backlog; no commit mentions #412).

Existing tests codify the defect. tests/test_ci_dry_run.py:42-88 patches devops_cli.commands.ci._run and asserts it is called once under --dry-run. Those tests pass today and would keep passing after any fix placed in _run, because they replace the function that gains the guard; they prove nothing about whether a process starts.

Other commands that declare --dry-run. The other commands that declare --dry-run were run without arguments with the same recorder. 80 of 120 command paths finished. Apart from ci, the only processes started were read-only: git worktree list, git rev-parse, gh api rate_limit and kubectl apply -k . --dry-run=client. The 40 paths that need arguments were not run. They are surveyed by #986; this item keeps the two runner guards and the coverage-cleanup guard (owner decision Q3, 2026-10-02).

Proposed Solution

  • Under dry-run, _run and _execute_check_async print the command they would run with print_dry_run_command (output/console.py:728-752, which already renders [dry-run] Would run command: ... from lang/en/messages.py:545, masks secrets and shows cwd) and return a pass (True from _run; a CheckResult with passed=True, the preview's duration_seconds and empty output from _execute_check_async) without calling the runner. The uv --preview-features insertion stays, so the printed command is the one that would run.
  • _run_all_checks_async skips its three _clean_coverage_artifacts() calls under dry-run: nothing ran, so there is nothing to clean, and the option's contract (help.py:25) rules out deleting files.
  • devops ci --dry-run and devops ci run --dry-run therefore list every check's command (the three fix steps when fixes are on, then the 11 check rows) and exit 0. The cache stays bypassed (ci.py:623) and nothing is saved (:666); no change there.
  • The 14 commands keep their --dry-run option and set_dry_run(True) call; the fix is below them, in the two runners inside ci.py. maintain is unchanged.
  • tests/test_ci_dry_run.py is rewritten to record the process runner (subprocess.run monkeypatched as tests/test_ci.py:28-36 does, which also covers the async path because run_subprocess_async falls back to the sync runner in a thread whenever subprocess.run is patched, core/process.py:361-375; or devops_cli.commands.ci.run_subprocess / devops_cli.core.process.run_subprocess_async as tests/test_ci.py:312 and :963 do) instead of _run, so each test proves no process is started.
  • The task file keeps the recorded 80-path result (the four read-only processes above) and names chore(cli): every argument-taking --dry-run command path is recorded as read-only or mutating, one candidate per offender #986 as the candidate that surveys the 40 argument-taking paths; no survey work happens in this pull request.

Scope

Key Questions

All answered; nothing is open.

Acceptance Criteria

  • With subprocess.run replaced by a recorder (as in tests/test_ci.py:28-36), devops ci lint --dry-run, devops ci format --dry-run, devops ci test --dry-run, devops ci run --dry-run and devops ci --dry-run each exit 0, the recorder has zero calls, and the output contains Would run command with every argv the command would run (ruff check . --fix, ruff format ., pytest, and for the two aggregate forms the three fix steps plus all 11 check rows of ci.py:341-470). Test: tests/test_ci_dry_run.py, assertions as structural tuples; each test fails at 8271385 (today the recorder is called once per check).
  • devops ci --dry-run and devops ci run --dry-run unlink nothing: with PYTEST_CURRENT_TEST removed from the environment (monkeypatch.delenv, because _clean_coverage_artifacts returns early when it is set, ci.py:224), _get_project_root patched to a tmp_path tree (as tests/test_ci.py:385) holding .coverage.x and coverage.xml, and the recorder in place, both files still exist afterwards. Test: tests/test_ci_dry_run.py; fails at 8271385.
  • Without the flag, devops ci lint still calls the runner once with uv --preview-features malware-check,check-command run ruff check . --fix, and devops ci --no-cache with the recorder still reaches the runner for every check row. Test: tests/test_ci_dry_run.py control case; tests/test_ci.py:84 (test_ci_lint_command) and :879 (test_gate_checks_nested_worktree_not_main_checkout) keep passing.
  • tests/test_ci_dry_run.py no longer patches devops_cli.commands.ci._run: rg -n 'commands\.ci\._run"' tests/test_ci_dry_run.py prints nothing.
  • devops ci maintain --dry-run output is unchanged. Test: tests/test_ci_maintain.py::test_ci_maintain_dry_run keeps passing.
  • The new and rewritten tests take at most 1 s in total for setup, call and teardown on one worker, not counting the session fixture setup that the first test in any run pays (5 s at 8271385), measured with uv run pytest -n 0 --durations=0 tests/test_ci_dry_run.py (-p no:xdist errors on the -n logical in pyproject.toml:105) and recorded in the task file.
  • The task file records the recorder results for the 80 argument-free --dry-run command paths already surveyed (the four read-only processes listed above) and names chore(cli): every argument-taking --dry-run command path is recorded as read-only or mutating, one candidate per offender #986 as the candidate filed for the 40 argument-taking paths. Observable: the task file's survey section lists the four processes and contains #986; it carries no table of the 40 paths.
  • changelog.d/885.md exists; CHANGELOG.md and docs/ROADMAP.md are untouched (devops pr check-readiness).
  • uv run devops ci passes.

Out of Scope

Dependencies

Readiness check (2026-10-04)

Re-checked at b61e5a0 (release/v0.2.26). #843 and #406 are merged, so this item waits only for v0.2.26 to merge. The two guarded runners survive #843, but most cited lines moved, #406 added a writing path, and the owner's dry-run rule of 2026-10-04 changes what a dry run returns.

Corrected locations (under src/devops_cli/):

  • commands/ci.py:
    • _run is at :189-203: --preview-features insertion at :198-199, runner call at :200.
    • _execute_check_async is at :277-355, with its runner call at :308.
    • _clean_coverage_artifacts is at :240-261, with its PYTEST_CURRENT_TEST guard at :242. _run_all_checks_async (:695-742) calls it at :703, :731 and :741.
    • Fix steps run in _run_pre_fixes_async (:622-665), from each row's fix_cmd.
    • Dry-run cache bypass is at :884, no-save at :930.
    • maintain is at :1564-1611 (render_dry_run_result at :1577), run at :1614-1633.
  • The "11 check rows of ci.py:341-470" are now the 12 rows of get_check_specs() (ci.py:383-481, which adds devcontainer), plus the virtual coverage row from _assemble_ci_results (:668-692). Tests take the expected rows from get_check_specs(), not from a fixed count.
  • Command spellings: the lint fix is uv run ruff check --fix . and the format fix is uv run ruff format .. The no-flag control therefore expects uv --preview-features malware-check,check-command run ruff check --fix ..
  • core/process.py:
    • _QUIET_SUBPROCESS_ARGS is at :38.
    • run_subprocess prints at :360, then runs at :390.
    • run_subprocess_async prints at :500, then runs at :533; it falls back to the sync runner when subprocess.run is patched (:485-486).
  • Other moved lines: lang/en/messages.py:631 (would_run_command), lang/en/help.py:28 (HELP.options.dry_run), pyproject.toml:122 (addopts).
  • Tests:
    • In tests/test_ci.py: recorder pattern :37-44, test_ci_lint_command :93, test_gate_checks_nested_worktree_not_main_checkout :1026, test_a_dry_run_records_nothing :898, _get_project_root patch :396, run_subprocess_async patch :1110.
    • tests/test_ci_dry_run.py patches _run at :44, :56, :67 and :81.
    • "Fails at 8271385" now reads "fails at b61e5a0".

New since the body: coverage --build-index (#406). _handle_coverage_index_build (ci.py:1291-1333) runs the suite through _run (:1306), then writes the index (save_index, :1328). With only the _run guard, devops ci coverage --build-index --dry-run would write an index from whatever .coverage is on disk.

devops ci test <paths> --dry-run still reads the index and runs local git hash reads for test selection (_resolve_test_targets, ci.py:1177-1226; ci/cache.py:251-272). These make no external request, so they may stay. The zero-call criterion applies to the path-free invocations it lists.

Rule alignment. The owner's rule (2026-10-04, recorded in #412 and in #886's amendment, which names ci): a dry run returns its real result type, marked as a dry run, with the ordered requests it would make as PlannedRequests (dry_run/requests.py:16-41, printed by render_request_plan, :49-75). This replaces two passages:

  • "return a pass (True / CheckResult with passed=True)" in the Proposed Solution;
  • "the plain Would run command line is the deliverable" in Out of Scope.

This item delivers #886's devops ci --dry-run criterion. Telemetry export is already off under a dry run (telemetry/tracer.py:1226-1229), so nothing is needed there.

Amended acceptance criteria (they replace the first two criteria above where the two differ):

  • Under a dry run, _run and _execute_check_async start no process. Each records a PlannedRequest holding the argv as it would run, including the uv --preview-features insertion.
    • devops ci lint|format|test|coverage --dry-run each print a one-request plan.
    • devops ci --dry-run and devops ci run --dry-run print, in order, the fix steps (when fixes are on) and then every row of get_check_specs().
    • Each exits 0 with the subprocess.run recorder at zero calls. Test: tests/test_ci_dry_run.py.
  • Dry-run CheckResults carry a dry-run marker (a field, as MigrationPlan.dry_run does at roadmap/migrate.py:157) instead of passed=True for checks that never ran. The gate prints no pass badges or pass summary for them. Under a dry run, _handle_ci_results neither saves (:930) nor clears (:936) the cache.
  • devops ci coverage --build-index --dry-run plans the index run (--cov-context=test with env COVERAGE_CORE=ctrace), hashes nothing and writes no index. Test: with the index path under tmp_path, no file exists afterwards and the recorder has zero calls.

The order #885 -> #838 -> #858 on commands/ci.py stands; #858 still edits the check table and the worker argv. This is still one PR, effort Medium.

Activity

  1. added
    type/bug
    scope/cli
    priority/p1-high
    on Oct 1, 2026
  2. added
    scope/ci
    and removed
    scope/cli
    on Oct 2, 2026
  3. added this to the v0.2.28 milestone on Oct 2, 2026
  4. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Grooming (2026-10-02): Placed in v0.2.28, one of its slots held for P1 work that surfaced after it was planned. Value High, effort Medium. Ready.

    Checked against the code at the release/v0.2.25 tip.

  5. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Moved from v0.2.28 to the top of the backlog on 2026-10-02. #519, a flaky gate test that failed a pre-push devops ci run today, was raised to P1 (Value High, Effort Low) and took this item's place. #885 was the lowest-ranked item in v0.2.27 and v0.2.28 that no person placed (P1, Value Medium, Effort Medium). It goes into the first of those releases that has a free slot.

  6. modified the milestones: v0.2.28, v0.2.27 on Oct 2, 2026
  7. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.27 on 2026-10-02. #846 and #845 moved into v0.2.25 with the review-loop work the owner asked for, which freed two slots. This item ranks highest among the backlog P1 items displaced earlier (P1, Value Medium, Effort Medium; #844 has Effort High).

  8. dan-petty-bot commented on Oct 5, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1199, merged into release/v0.2.27 as 85a924b.

    Closes #885

    5 file(s) changed.

    How it was verified

    Check runs at d187a1d:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-885-ci-checks-run-under-dry-run.md:

    • Under a dry run, _run and _execute_check_async start no process. Each records a PlannedRequest holding the argv as it would run, including the uv --preview-features insertion.
      • devops ci lint|format|test|coverage --dry-run each print a one-request plan.
      • devops ci --dry-run and devops ci run --dry-run print, in order, the fix steps (when fixes are on) and then every row of get_check_specs().
      • Each exits 0 with the subprocess.run recorder at zero calls (tests/test_ci_dry_run.py).
    • Dry-run CheckResults carry a dry-run marker (dry_run=True) instead of passed=True for checks that never ran. The gate prints no pass badges or pass summary for them. Under a dry run, _handle_ci_results neither saves nor clears the cache.
    • devops ci coverage --build-index --dry-run plans the index run (--cov-context=test with env COVERAGE_CORE=ctrace), hashes nothing and writes no index. Tested with index path under tmp_path, verifying no file is created and the recorder sees zero calls.
    • devops ci --dry-run and devops ci run --dry-run unlink nothing: with PYTEST_CURRENT_TEST removed and _get_project_root pointed to tmp_path holding .coverage.sample and coverage.xml, both files still exist afterwards.
    • Without the flag, devops ci lint calls the runner once with uv --preview-features malware-check,check-command run ruff check --fix ., and devops ci --no-cache with the recorder reaches the runner for every check row.
    • tests/test_ci_dry_run.py contains zero occurrences of patching commands.ci._run.
    • devops ci maintain --dry-run output is unchanged (tests/test_ci_maintain.py::test_ci_maintain_dry_run passes).
    • The new and rewritten tests take at most 1 s in total for setup, call and teardown on one worker (measured at 0.52 s call duration).
    • The task file records the recorder results for the 80 argument-free --dry-run paths (the four read-only processes) and names chore(cli): every argument-taking --dry-run command path is recorded as read-only or mutating, one candidate per offender #986 for the 40 argument-taking paths.
    • changelog.d/885.md exists; CHANGELOG.md and docs/ROADMAP.md are untouched.
    • Pending a person: uv run devops ci passes on this branch.
  9. added a commit that references this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/citype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions