Commit 46c8d57
committed
Merge #122: Create detection logic package for development dependencies
eaa0acc refactor: [#114] rename tests to follow it_should_ convention (Jose Celano)
91d2eb3 fix: [#114] use inline format args in example (copilot-swe-agent[bot])
04754eb feat: [#114] add example demonstrating dependency checking (copilot-swe-agent[bot])
07cc42a docs: [#114] add documentation for platform support and detector creation (copilot-swe-agent[bot])
48b5c0f feat: [#114] create detection logic package (copilot-swe-agent[bot])
848b331 Initial plan (copilot-swe-agent[bot])
Pull request description:
## Create Detection Logic Package
Implementing detection logic for development dependencies (cargo-machete, OpenTofu, Ansible, LXD) following the linting package pattern.
### Implementation Plan
- [x] Create package structure at `packages/dependency-installer/`
- [x] Create directory structure
- [x] Create Cargo.toml with dependencies (tracing, thiserror)
- [x] Add to workspace Cargo.toml
- [x] Create README.md
- [x] Define core abstractions
- [x] ToolDetector trait in `src/detector/mod.rs`
- [x] DetectionError enum in `src/errors.rs`
- [x] Dependency enum for tool types
- [x] CheckResult struct for detection results
- [x] Implement command utilities in `src/command.rs`
- [x] command_exists() function
- [x] execute_command() function
- [x] CommandError type
- [x] Implement 4 detector structs
- [x] CargoMacheteDetector in `src/detector/cargo_machete.rs`
- [x] OpenTofuDetector in `src/detector/opentofu.rs`
- [x] AnsibleDetector in `src/detector/ansible.rs`
- [x] LxdDetector in `src/detector/lxd.rs`
- [x] Create DependencyManager in `src/manager.rs`
- [x] new() to create with all detectors
- [x] check_all() to check all dependencies
- [x] get_detector() to get specific detector
- [x] Add library exports in `src/lib.rs`
- [x] Write comprehensive unit tests
- [x] Test each detector implementation
- [x] Test DependencyManager functionality
- [x] Test error handling
- [x] Add working example demonstrating usage
- [x] Run linting, build, and verify
- [x] cargo build ✓
- [x] cargo test ✓ (22 tests + 2 doctests passing)
- [x] cargo run --bin linter all ✓
- [x] Address code review feedback
- [x] Document Unix-specific `which` command usage
- [x] Clarify detector creation pattern in DependencyManager
- [x] Fix clippy linting issue
- [x] Use inline format args in example
### Summary
Successfully created the `packages/dependency-installer` package with:
- **ToolDetector trait**: Abstract interface for tool detection with `name()` and `is_installed()` methods
- **4 Detector implementations**: CargoMacheteDetector, OpenTofuDetector, AnsibleDetector, LxdDetector
- **DependencyManager**: Orchestrates all detectors with `check_all()` and `get_detector()` methods
- **Command utilities**: Helper functions for command execution (`command_exists`, `execute_command`)
- **Comprehensive testing**: 22 unit tests + 2 doc tests covering all functionality
- **Error handling**: Clear error types (DetectionError, CommandError) with context
- **Logging**: Structured logging with tracing for all operations
- **Documentation**: Platform support notes and implementation clarifications
- **Example**: Working example demonstrating dependency checking
All linters pass, all tests pass, workspace builds successfully, and the package follows the linting package pattern.
### Security Summary
No security vulnerabilities identified. The package performs read-only operations:
- Executes `which` command to check for tool existence
- No file system modifications
- No network operations
- No user input processing
- No credential handling
### Next Steps
This completes Phase 1 of Issue #114. The next phases will add:
- **Phase 2 (Issue #115)**: CLI binary with check command
- **Phase 3 (Issue #116)**: Docker test infrastructure
- **Phase 4 (Issue #117)**: Installation logic
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Create Detection Logic Package</issue_title>
> <issue_description>**Parent Issue**: #113 - Create Dependency Installation Package for E2E Tests
> **Depends On**: None (first phase)
> **Epic**: #112 - Refactor and Improve E2E Test Execution
>
> ## Overview
>
> Create the package structure and implement detection logic to check if development dependencies (cargo-machete, OpenTofu, Ansible, LXD) are installed.
>
> This is **Phase 1 of 4** for building the dependency installation package.
>
> ## Objectives
>
> - Create packages/dependency-installer/ structure following packages/linting/ pattern
> - Define ToolDetector trait for detection abstraction
> - Implement 4 detector structs (CargoMachete, OpenTofu, Ansible, LXD)
> - Create DependencyManager to coordinate detectors
> - Add comprehensive unit tests with mocked commands
> - Set up tracing for observability
>
> ## Key Components
>
> **ToolDetector Trait**:
> ```rust
> trait ToolDetector {
> fn name(&self) -> &str;
> fn is_installed(&self) -> Result<bool, DetectionError>;
> }
> ```
>
> **4 Detector Implementations**:
> - CargoMacheteDetector - checks `cargo machete --version`
> - OpenTofuDetector - checks `tofu --version`
> - AnsibleDetector - checks `ansible --version`
> - LxdDetector - checks `lxc --version`
>
> **DependencyManager**:
> - Coordinates all detectors
> - Provides `check_all()` method returning status for all tools
>
> ## Acceptance Criteria
>
> - Pre-commit checks pass
> - Package structure follows linting package pattern
> - ToolDetector trait is well-defined
> - All 4 detectors are implemented with proper error handling
> - DependencyManager works correctly
> - Unit tests cover all detectors with mocked commands
> - Logging provides clear visibility
>
> ## Time Estimate
>
> 2-3 hours
>
> ## Related Documentation
>
> - Full specification: [docs/issues/114-1-1-1-create-detection-logic-package.md](https://github.com/torrust/torrust-tracker-deployer/blob/main/docs/issues/114-1-1-1-create-detection-logic-package.md)
> - Linting package reference: packages/linting/
> - Error handling guide: docs/contributing/error-handling.md</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixes #114
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
ACKs for top commit:
josecelano:
ACK eaa0acc
Tree-SHA512: 10f9a1163fa41a5690af3eb6c93fcba05e41103dcb475b83421dd16c3459f9cb427c6b6ceb99f5edc65d793063981b402c11fec9a4696bd4e11df41aca5a33eeFile tree
14 files changed
+736
-0
lines changed- packages/dependency-installer
- examples
- src
- detector
- tests
14 files changed
+736
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments