-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add Docker test infrastructure for dependency-installer CLI #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: josecelano <[email protected]>
|
@copilot the testing workflow is failing: |
Co-authored-by: josecelano <[email protected]>
Co-authored-by: josecelano <[email protected]>
... This formatting issue was already fixed in commit 2040c38. The current HEAD (7432591) has all formatting correct. Running |
|
@copilot, the linting workflow is failing. Run all linters and fix the errors. |
Co-authored-by: josecelano <[email protected]>
Fixed all linting errors in commit a3b70c4. All linters now pass:
All tests still passing (4/4). |
- Implement ContainerId newtype with validation for type safety - Split container utilities into independent modules: - container_id.rs: validated container ID type - running_binary_container.rs: running container with binary - ubuntu_container_builder.rs: builder pattern for container creation - Remove helpers.rs by moving functions to type methods - Remove ubuntu.rs re-export module for direct imports - Rename types for semantic clarity: - UbuntuTestContainer → RunningBinaryContainer - UbuntuContainerWithBinary → UbuntuContainerBuilder - Add 'hexdigit' to project dictionary for spell checking This refactoring improves modularity, type safety, and maintainability while preserving all existing functionality. All tests remain passing.
Refactoring ProgressI've started refactoring the Docker test infrastructure to improve code quality and maintainability. The first commit includes several structural improvements: Completed Refactorings ✅
Current Status✅ All tests passing (28 total: 4 Docker + 22 detector + 2 doc tests) Next StepsPlanning additional improvements to further enhance the test infrastructure. More refactoring commits coming soon. |
- Create CommandOutput type to capture stdout and stderr separately - Add methods: stdout(), stderr(), combined(), and contains() - Implement Display trait for easy formatting in assertions - Update RunningBinaryContainer::exec() to return CommandOutput - Add comprehensive unit tests for CommandOutput behavior This improves test clarity by providing explicit access to both output streams while maintaining backward compatibility through the combined() method and Display implementation.
- Create ExitCode type alias for i32 exit codes - Update exec_with_exit_code() to return ExitCode type - Improves code readability and semantic clarity
- Create new logging module with init_tracing function - Move init_tracing from lib.rs to logging.rs - Re-export logging module in lib.rs - Improves module organization and separation of concerns
…dependency-installer - Replace all Box<dyn std::error::Error> with strongly-typed enum errors - Implement From traits for automatic error conversions using ? operator - Create ExitCode enum for type-safe CLI exit codes - Move AppError::to_exit_code logic from binary to AppError method - Relocate DetectionError to detector module where it originates - Relocate CommandError to command module where it originates - Remove now-empty errors.rs module Error hierarchy established: - AppError (app.rs) - top-level application errors - CheckFailed wraps CheckError - ListFailed wraps ListError - CheckError (handlers/check.rs) - check command errors - CheckAllFailed wraps CheckAllToolsError - CheckSpecificFailed wraps CheckSpecificToolError - CheckAllToolsError - checking all dependencies - MissingDependencies with counts - DependencyCheckFailed wraps DetectionError - CheckSpecificToolError - checking specific tool - ParseFailed wraps ParseToolNameError - ToolNotInstalled with tool name - DetectionFailed wraps DetectionError - ParseToolNameError - tool name parsing - UnknownTool with name and available_tools - ListError (handlers/list.rs) - list command errors - DependencyCheckFailed wraps DetectionError - DetectionError (detector/mod.rs) - tool detection - CommandError (command.rs) - command execution - ExitCode enum (app.rs) - type-safe exit codes All errors use thiserror with #[error] and #[source] attributes for complete traceability. Pattern matching now possible on all error types.
…ions Implemented From trait conversions to enable automatic error conversions using the ? operator, removing verbose map_err calls throughout handlers. check.rs changes: - Added impl From<CheckAllToolsError> for CheckError - Added impl From<CheckSpecificToolError> for CheckError - Added impl From<DetectionError> for CheckAllToolsError - Added impl From<ParseToolNameError> for CheckSpecificToolError - Added impl From<DetectionError> for CheckSpecificToolError - Simplified handle_check: removed map_err, added Ok(()) return - Simplified check_all_tools: manager.check_all()? without map_err - Simplified check_specific_tool: parse_tool_name()? and detector.is_installed()? without map_err list.rs changes: - Added impl From<DetectionError> for ListError - Simplified handle_list: manager.check_all()? without map_err All error conversions now happen automatically via From traits, enabling clean idiomatic Rust error handling with the ? operator.
Replace String-based dependency references with Dependency enum throughout: - Add FromStr and Display traits to Dependency enum - Add DependencyParseError with auto-generated available list - Change CLI from --tool Option<String> to --dependency Option<Dependency> - Update CheckResult: tool: String → dependency: Dependency - Remove parse_tool_name function (replaced by FromStr trait) - Remove ParseToolNameError enum (no longer needed) - Simplify DependencyManager to unit struct (creates detectors on-demand) - Update all handler signatures to use Dependency enum - Standardize terminology: consistently use 'dependency' instead of mixed 'tool/dependency' Benefits: - Compile-time type safety for all dependency references - No string parsing bugs - FromStr handles all parsing - No manual list maintenance - Dependency::all() is source of truth - Cleaner code - removed parse function and error enum - Consistent naming throughout codebase
… Dependency enum in error types Complete terminology normalization from 'tool' to 'dependency': - Rename ToolDetector trait → DependencyDetector - Rename CheckAllToolsError → CheckAllDependenciesError - Rename CheckSpecificToolError → CheckSpecificDependencyError - Rename test function test_check_specific_tool → test_check_specific_dependency - Update all comments and documentation Use Dependency enum instead of String in error types: - DetectionError::DetectionFailed: dependency: String → Dependency - DetectionError::CommandFailed: dependency: String → Dependency - CheckSpecificDependencyError::DependencyNotInstalled: dependency: String → Dependency - Update all detector implementations to use Dependency enum Update logging field names: - Change all 'tool = ...' to 'dependency = ...' in tracing logs Benefits: - Consistent terminology throughout: always 'dependency', never 'tool' - Type-safe error types: compile-time checking for dependency references - Better error messages: Display trait on Dependency provides consistent formatting - Clearer intent: code clearly communicates it's working with dependencies
…ed logging only - Convert to structured logging using tracing crate (info! macros) - Change log level from ERROR to INFO for dependency status checks (missing dependencies are information, not application errors) - Update integration tests to check error messages instead of stdout - Update README with Design Philosophy section explaining logging-only approach - Document that this is an internal automation tool for CI/CD - Add real logging output examples to README - Update library usage examples to show tracing initialization This aligns the package with the linting package approach - using only structured logging for automation-friendly output. The tool is simple enough that logging output is sufficient even for manual use.
- Add LogLevel enum with values: Off, Error, Warn, Info, Debug, Trace - Add --log-level global CLI argument (default: info) - Update init_tracing() to accept Optional<Level> for off support - Update integration tests to use --log-level off for clean output - Keep --verbose flag as shortcut for --log-level debug - Update README with log level examples - Fix example to pass log level to init_tracing() This provides clean test output by hiding logs during tests while maintaining full logging capability for debugging and production use. The default level (info) shows ERROR, WARN, and INFO logs.
- Add 'status' field to all detector log entries (installed/not installed) - Move error handling from main() into app::run() using tracing::error! - Change app::run() return type from Result<(), AppError> to ExitCode - Simplify main() binary to just call app::run() and exit - Update tests to verify exit codes only (no output with --log-level off) - Makes logging output easily parsable by automation tools
…installer package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0b0beda
Create Docker Test Infrastructure for CLI Binary Testing
This PR implements Docker-based testing infrastructure to verify the CLI binary works correctly in a clean Ubuntu 24.04 environment.
Implementation Plan:
Linting Fixes (commit hash pending):
uninlined_format_argswarnings - updated all format strings to use inline syntaxdoc_markdownwarnings - added backticks tocode(),CARGO_MANIFEST_DIR, etc.unused_selfwarning - added#[allow(clippy::unused_self)]to fluent builder methodunnecessary_debug_formatting- changed{:?}toDisplayformatting with.display()All Linters Passing:
Test Results:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.