Skip to content

feat: add base build/clean/status/doctor and colcon arg passthrough - #20

Merged
HansRobo merged 1 commit into
mainfrom
feat/base-robustness
Jun 3, 2026
Merged

HansRobo merged 1 commit into
mainfrom
feat/base-robustness

Conversation

@HansRobo

@HansRobo HansRobo commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Hardens the base workspace commands (R6 of the review roadmap, docs/review-and-proposals-ja.md §3.3 / §5.2). Previously cwm base offered only update (git pull + non-sourced colcon build), which left several real-world frictions unaddressed: no pull-less rebuild, manual cleanup of stale CMakeCache dirs, no colcon arg passthrough, and a build path asymmetric with the worktree side.

New commands

Command Description
cwm base build [-- <colcon args>] Rebuild the base workspace without pulling
cwm base clean [--yes] Remove base build artifacts with a confirmation prompt
cwm base status [--json] Show whether the base is built and dirty
cwm base doctor [--fix] [--json] Detect (and with --fix delete) stale build dirs pointing at missing sources

Changes to existing behaviour

  • base update / base build now source the ROS 2 underlay (underlay in .cwm/config.yaml) via run_colcon_sourced, symmetric with the worktree build path. <underlay>/setup.bash is validated up front with an explicit error instead of relying on the caller's environment.
  • Colcon arg passthrough: extra args after -- are forwarded to colcon build (e.g. cwm base build -- --continue-on-error).
  • cwm ws clean --base is deprecated in favour of cwm base clean; it still works and prints a notice to stderr (removal deferred to a future major).

Implementation notes

  • base doctor parses build/<pkg>/CMakeCache.txt (CMAKE_HOME_DIRECTORY) and flags build dirs whose source no longer exists — the moved/deleted-package case that otherwise fails the next build with a CMake error. --fix deletes only those dirs; dirs without a cache (e.g. pure-Python packages) are ignored.
  • Reuses existing pieces: run_colcon_sourced (generalised in refactor: generalize sourced colcon runner and extract changeset pipeline #16), _artifact_dirs (clean_cmd), _collect_base (status_cmd).
  • Shared helpers extracted: suppress_completion in completion.py (replaces per-command lambdas in build/test/base) and _print_base_status in status_cmd.py (shared by ws status and base status).

Additive only — no breaking CLI/config changes ⇒ minor, v6.3.0 after merge.

Test plan

  • 15 new unit tests in tests/unit/test_base_cmd.py (sourced build, underlay validation, arg passthrough, clean confirmation, deprecation notice, doctor detection/--fix/--json)
  • Full suite: 209 passed (uv run python -m pytest tests/ -q)
  • Manual E2E on a real ROS workspace: cwm base build -- --continue-on-error, cwm base doctor --fix against a moved package

Harden the base workspace commands, which previously offered only
`base update` (git pull + non-sourced colcon build):

- `base build`: rebuild the base workspace without pulling.
- `base clean`: remove base build artifacts (build/, install/, log/)
  with a confirmation prompt (`--yes` to skip), since every worktree
  overlays the base install. `cwm ws clean --base` is now deprecated
  in favour of `cwm base clean` (still functional).
- `base status`: show whether the base is built/dirty (`--json`).
- `base doctor`: detect stale build dirs whose CMakeCache.txt points
  at a source that no longer exists (moved/deleted packages), which
  otherwise fail the next build with a CMake error; `--fix` deletes
  only those dirs (`--json` supported).

`base update` and `base build` now source the ROS 2 underlay via
run_colcon_sourced, symmetric with the worktree build path, and
validate <underlay>/setup.bash up front with an explicit error.
Both forward extra arguments to colcon build
(e.g. `cwm base build -- --continue-on-error`).

Shared helpers extracted along the way: suppress_completion in
completion.py (replaces per-command lambdas) and _print_base_status
in status_cmd.py (reused by `base status`).
@HansRobo HansRobo added the release:minor Bump minor version on merge label Jun 3, 2026
@HansRobo
HansRobo merged commit 5fc9faa into main Jun 3, 2026
11 of 12 checks passed
@HansRobo
HansRobo deleted the feat/base-robustness branch June 3, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:minor Bump minor version on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant