Commit 7b7066c
committed
Merge #136: Implement dependency installation logic with async Rust converters for bash scripts
6e0b214 test: [#117] suppress stderr in error exit code test for clean output (Jose Celano)
a0d9276 fix: [#117] correct test file paths in dependency-installer Cargo.toml (Jose Celano)
1e1ee7d docs: [#117] integrate dependency-installer package into global documentation (Jose Celano)
d9db859 refactor: [#117] rename integration test files for clarity (Jose Celano)
4f25a43 test: [#117] use exit codes instead of parsing output in dependency-installer tests (Jose Celano)
04c9381 refactor: [#117] simplify error handling with automatic conversions (Jose Celano)
c6f7898 feat: [#117] add snapd to Dockerfile and document LXD test limitations (Jose Celano)
9b5767a feat: [#117] optimize OpenTofu installer tests by moving dependencies to Dockerfile (Jose Celano)
92dc7a1 feat: [#117] add ImageBuilder to auto-build Docker images for package tests (Jose Celano)
a453356 perf: [#117] optimize Ansible installer by removing apt-get update (Jose Celano)
c2df939 perf: [#117] optimize Docker tests by pre-building container image with OS dependencies (Jose Celano)
65cc194 fix: conditionally import unused modules on Windows (copilot-swe-agent[bot])
1ebd884 fix: resolve Windows compilation errors in OpenTofu installer (copilot-swe-agent[bot])
2cd4101 fix: address code review feedback - async sleep and cross-platform concerns (copilot-swe-agent[bot])
edbfde5 docs: update README with install command and fix clippy warnings (copilot-swe-agent[bot])
1706359 fix: format code and fix detector test imports (copilot-swe-agent[bot])
8ce6ca9 test: add Docker tests for install command (copilot-swe-agent[bot])
39f4f98 feat: add installer trait and implementations with install command (copilot-swe-agent[bot])
f3f8feb Initial plan (copilot-swe-agent[bot])
Pull request description:
Implement Installation Logic (Issue #117)
This PR implements the installation logic for the dependency-installer package, converting bash scripts to Rust implementations with structured logging.
**Implementation Status**: ✅ Complete
All phases completed:
- [x] Phase 1: Installer trait and error types
- [x] Phase 2: Installer implementations (4 dependencies)
- [x] Phase 3: DependencyManager extensions
- [x] Phase 4: Install command handler
- [x] Phase 5: CLI and app updates
- [x] Phase 6: Docker tests
- [x] Phase 7: Testing and validation
- [x] Phase 8: Documentation
**Recent Fixes**:
- Fixed Windows compilation errors by restructuring OpenTofu installer to return early on non-Unix systems
- Fixed unused import warnings by making imports conditional with #[cfg(unix)]
**Test Results**:
- All 17 tests pass (6 non-ignored, 5 ignored for expensive operations, 6 unit tests)
- Zero clippy warnings
- Code properly formatted
- Cross-platform compilation verified (Unix and Windows)
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
----
*This section details on the original issue you should resolve*
<issue_title>Implement Installation Logic</issue_title>
<issue_description># Implement Installation Logic (Issue 1-1-4)
## Overview
Implement the installation logic for all 4 dependencies (cargo-machete, OpenTofu, Ansible, LXD) and add the `install` command to the CLI. This completes the dependency installer package by converting bash installation scripts to Rust with structured logging for automation and CI/CD integration.
**Design Philosophy**: Uses **structured logging only** (tracing crate) - no user-facing `println!()` output. Designed for automation and CI/CD pipelines.
## Parent Issue
[#113](#113) - Create Dependency Installation Package for E2E Tests
## Dependencies
**Depends On**:
- [#116](#116) - Create Docker Test Infrastructure (Issue 1-1-3)
**Blocks**:
- Issue 1-2: Integrate dependency-installer with E2E tests
## Objectives
- [ ] Define `DependencyInstaller` trait for installation abstraction
- [ ] Convert bash scripts (`scripts/setup/`) to Rust installer implementations
- [ ] Add `install` command to CLI binary with handler-based architecture
- [ ] Extend `DependencyManager` to coordinate installation
- [ ] Extend Docker tests to verify actual installations
- [ ] Use structured logging (tracing) throughout for observability
- [ ] Document exit codes and usage patterns
## Key Components
### DependencyInstaller Trait
```rust
#[async_trait]
pub trait DependencyInstaller: Send + Sync {
fn name(&self) -> &str;
fn dependency(&self) -> Dependency;
async fn install(&self) -> Result<(), InstallationError>;
fn requires_sudo(&self) -> bool { false }
}
```
### Installer Implementations
Convert bash scripts to Rust:
1. **CargoMacheteInstaller** (`scripts/setup/install-cargo-machete.sh`)
- Uses `cargo install cargo-machete`
- No sudo required
2. **OpenTofuInstaller** (`scripts/setup/install-opentofu.sh`)
- Downloads installer script with curl
- Runs with sudo
- Multi-step: download → chmod → execute → cleanup
3. **AnsibleInstaller** (`scripts/setup/install-ansible.sh`)
- Uses apt-get package manager
- Requires sudo
4. **LxdInstaller** (`scripts/setup/install-lxd.sh`)
- Uses snap for installation
- Configures user groups
- Requires sudo
### Extended DependencyManager
Add installation methods to existing manager:
```rust
impl DependencyManager {
pub fn get_installer(&self, dep: Dependency) -> Box<dyn DependencyInstaller>;
pub async fn install(&self, dep: Dependency) -> Result<(), InstallationError>;
pub async fn install_all(&self) -> Result<Vec<InstallResult>, InstallationError>;
}
```
### Install Command Handler
New handler following existing pattern:
```rust
// src/handlers/install.rs
pub async fn handle_install(
manager: &DependencyManager,
dependency: Option<Dependency>,
) -> Result<(), InstallError> {
// Handler implementation with structured logging
}
```
### CLI Command
Add to existing CLI:
```bash
# Install all dependencies
dependency-installer install
# Install specific dependency
dependency-installer install --dependency opentofu
# With verbose logging
dependency-installer install --verbose
```
### Docker Tests
Extend testing to verify actual installations:
```rust
// tests/docker_install_command.rs
#[tokio::test]
async fn test_install_cargo_machete() {
// Verify installation in clean container
}
#[tokio::test]
async fn test_install_idempotent() {
// Install twice, both should succeed
}
#[tokio::test]
async fn test_install_all() {
// Install all dependencies
}
```
## Architecture
### Directory Structure
```text
packages/dependency-installer/
├── src/
│ ├── manager.rs # Add installation methods
│ ├── detector/ # Existing detection logic
│ ├── installer/ # NEW: Installation logic
│ │ ├── mod.rs # Trait + error types
│ │ ├── cargo_machete.rs
│ │ ├── opentofu.rs
│ │ ├── ansible.rs
│ │ └── lxd.rs
│ ├── handlers/ # Extend with install
│ │ ├── check.rs # Existing
│ │ ├── list.rs # Existing
│ │ └── install.rs # NEW
│ └── cli.rs # Add Install command
└── tests/
└── docker_install_command.rs # NEW tests
```
### Handler-Based Architecture
Following existing pattern:
```rust
// src/app.rs
match cli.command {
Commands::Check { dependency } => {
check::handle_check(&manager, dependency)?;
}
Commands::List => {
list::handle_list(&manager)?;
}
Commands::Install { dependency } => { // NEW
install::handle_install(&manager, dependency).await?;
}
}
```
## Structured Logging Examples
All output uses `tracing` crate - no `println!()` statements:
### Installing All Dependencies
```bash
$ dependency-installer install
2...
</details>
- Fixes #117
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
ACKs for top commit:
josecelano:
ACK 6e0b214
Tree-SHA512: f2117d188b0adfde2e9a7813a0da1db1301b0b071ed2c5f0ef8f0bf5d607e92ea8bbcb49cbe84a9fa548c5ba29c17f217b519c229bbd243379a4bc1d812f6766File tree
34 files changed
+1729
-65
lines changed- .github
- docs
- contributing
- packages
- dependency-installer
- docker
- src
- bin
- detector
- handlers
- installer
- tests
- containers
- scripts/setup
34 files changed
+1729
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
113 | | - | |
| 120 | + | |
| 121 | + | |
114 | 122 | | |
115 | 123 | | |
| 124 | + | |
116 | 125 | | |
117 | 126 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
68 | 91 | | |
69 | 92 | | |
70 | | - | |
71 | 93 | | |
72 | 94 | | |
73 | 95 | | |
| |||
76 | 98 | | |
77 | 99 | | |
78 | 100 | | |
79 | | - | |
| 101 | + | |
80 | 102 | | |
81 | 103 | | |
82 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
184 | 212 | | |
185 | 213 | | |
186 | 214 | | |
| |||
195 | 223 | | |
196 | 224 | | |
197 | 225 | | |
198 | | - | |
| 226 | + | |
199 | 227 | | |
200 | 228 | | |
201 | 229 | | |
| |||
210 | 238 | | |
211 | 239 | | |
212 | 240 | | |
213 | | - | |
| 241 | + | |
214 | 242 | | |
215 | 243 | | |
216 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
217 | 257 | | |
218 | 258 | | |
219 | 259 | | |
| |||
| 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 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments