feat(cli): implement cougr doctor toolchain diagnostics (#247) - #272
feat(cli): implement cougr doctor toolchain diagnostics (#247)#272khaylebfortune wants to merge 3 commits into
Conversation
…#247) Implements the doctor subcommand for the new cougr-cli workspace member shipping in this PR. Closes salazarsebas#247 (part of salazarsebas#238). Scope - New internal/cougr-cli workspace subcrate, published as the cougr-cli crate on crates.io and exposing the `cougr` binary. - `cougr doctor` checks Rust toolchain (>= rust-version parsed from the nearest workspace Cargo.toml), wasm32v1-none target install, cargo sanity, and Stellar CLI >= 21.0.0. Each failure prints an actionable fix command, never a generic "missing". Summary line `N/M checks passed.` with non-zero exit on any failure. - `cougr new <name>` scaffolds a minimal Soroban contract crate using `cougr-core = 1.1` (published-crate dep, no path assumption). The first time `cougr new` runs, `cougr doctor` is invoked non-fatally: warnings are printed to stderr but the scaffold still proceeds. Exits 0 when scaffold succeeds regardless of warnings; --no-doctor suppresses the pre-flight. - --rust-manifest PATH and --stellar-min VERSION flags override doctor defaults. Architecture - `doctor::run` is split from `doctor::print_report` so check logic can be unit-tested via the `CommandRunner` trait. `MockRunner` mirrors `SystemRunner`'s status=-1 for unmocked calls so missing-binary branches are exerciseable. - Checks reject pre-release versions (`rustc 1.85.0-nightly` does not silently satisfy `1.70.0`). - Manifest walk stops at the first Cargo.toml with `[workspace]`, matching the issue's "Root Cargo.toml is source of truth" wording. Tests - 13 unit-test modules inside check fns + 2 integration test files (tests/integration_cli.rs and tests/integration_doctor.rs). - Smoke test pins the canonical four-check public surface so a future rename cannot silently break consumers. Out of scope (per issue salazarsebas#247) - Auto-installing missing tools. - Soroban network/RPC checks. - Full CLI feature surface (templates, `cougr add`, `cougr check`); these are tracked separately by epic salazarsebas#238.
|
@khaylebfortune Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Solid implementation of #247 — looks like the stronger of the two competing doctor PRs (see #279, which has a couple of gaps against the DoD). It currently lives at |
|
This targets the same issue as #279 (#247) but with a different approach ( |
- Drop the duplicate cougr-cli workspace member (internal/cougr-cli); it clashed with cli/ on package name and the 'cougr' binary, breaking every workspace-wide cargo command - Gate unused circuit imports behind cfg(test|testutils) to silence cargo build warnings - Add the CLI CI workflow documented in the CHANGELOG: lint/test cougr-cli and validate all four generated templates (fmt, clippy, test, wasm32v1-none build) - Add battleship and rock_paper_scissors example workflows (previously no CI coverage) - Publish pipeline: trigger on cli/** and check cargo package -p cougr-cli - Delete dead root murdoku.yml; GitHub only reads .github/workflows/
|
@salazarsebas I've fix the CI issue. Please kindly check and merge. |
Summary
Implements the
cougr doctorsubcommand per issue #247 (part of epic #238). Introduces a newcougr-cliworkspace subcrate that publishes ascougr-clion crates.io and exposes thecougrbinary. Closes #247.In scope (per #247 DoD)
rustc --version, compares against therust-versionfield of the nearest workspaceCargo.toml(stops at first[workspace]manifest)rustup update stablerustup target list --installed, exact line matchrustup target add wasm32v1-nonecargo --version(rustup-managed, no separate version floor)stellar --version, compares against--stellar-min(default 21.0.0)N/M checks passed.and a non-zero exit code when any check fails.cougr new <name>invokescougr doctornon-fatally on first run: prints warnings to stderr but the scaffold itself proceeds. Successful scaffold + doctor warnings returnsCliError::DoctorWarningsPrinted(0)(exit 0). Scaffold failures keep exit 1.--no-doctorflag suppresses the pre-flight entirely.Definition of Done evidence
all_passing_runner_drives_a_clean_reportand unit testspass_when_*ininternal/cougr-cli/src/doctor/checks/{rust_toolchain,cargo}.rs.rustup target add wasm32v1-none: enforced bywasm32v1_target::check::fail_when_target_missingandmissing_wasm_target_prints_specific_fix_commandintegration test (asserts the literalrustup target addsubstring and the canonical target constant).stellar_cli::check::fail_when_stellar_missing(asserts the fix message includes the official install URL and the configured min version).Architecture
doctor::runreturns adoctor::Reportand is split fromdoctor::print_reportso check logic is unit-testable via theCommandRunnertrait.SystemRunnershells out for real;MockRunnerregisters canned(program, args) -> CommandOutputand returnsCommandOutput::missing()(status=-1) for any unmocked call so missing-binary branches are reachable from tests.parse_dotted_versionrejects pre-release / build-metadata suffixes;rustc 1.85.0-nightlyis not treated as[1, 85, 0]. This catches a real footgun: users on a nightly toolchain currently could satisfy a stable1.70.0minimum in the old strip-prefix approach.resolve_min_rust_versionwalks up to the first manifest with a[workspace]table, matching the issue's "Root Cargo.toml is the source of truth" wording.no_std, nosoroban-sdk); clap-derive for parsing. Depends only onclap.Tests
doctor::mod.internal/cougr-cli/tests/:integration_cli.rs: argv parsing, missing-subcommand usage, --help clap short-circuit.integration_doctor.rs: fullcougr doctororchestrator withMockRunnercovering all four DoD scenarios + a smoke test againstSystemRunnerthat asserts the rust toolchain check passes on the host binary (locks the contract forcargo install cougr-cliusers).CommandOutput::missing()so a futureMockRunnerrefactor cannot silently regress the missing-binary branches.Why this is in the same repository (and not a fork per docs/strategy/10-repository-strategy.md)
The CLI is published as
cougr-cli(one binary,cougr), version-locked tocougr-coreat1.1.0.Out of scope (per #247)
cougr newtemplate-driven scaffolder (--template starter|turn-based|hidden-info|session-auth) -- tracked under epic Epic: ship the cougr CLI (new / add / check / doctor) #238 alongside the futurecougr addandcougr checksubcommands.Closes #247