-
Notifications
You must be signed in to change notification settings - Fork 0
Implement dependency installation logic with async Rust converters for bash scripts #136
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]>
Co-authored-by: josecelano <[email protected]>
Co-authored-by: josecelano <[email protected]>
Co-authored-by: josecelano <[email protected]>
…ncerns Co-authored-by: josecelano <[email protected]>
|
@copilot the testing workflow is failing: |
Move non-Unix early return to the beginning of install() method to avoid unreachable code warnings on Windows. All Unix-specific installation logic is now properly guarded with #[cfg(unix)] blocks. Co-authored-by: josecelano <[email protected]>
... Fixed in commit 1ebd884. The issue was that the non-Unix early return was placed in the middle of the function, causing all subsequent code to be unreachable on Windows. Restructured the |
|
@copilot testing wroflow is still failing: |
Make std::fs, std::process::Command, and tracing macros (debug, info) conditional with #[cfg(unix)] to avoid unused import warnings on Windows where the OpenTofu installer returns early. Co-authored-by: josecelano <[email protected]>
…th OS dependencies - Move all OS dependencies (sudo, curl, build-essential, Rust nightly) to Dockerfile - Reduce cargo-machete test time from 20-56s to ~14s (70% improvement) - Remove #[ignore] from cargo-machete tests - now run by default as valuable CI tests - Consolidate container start methods - remove duplicate start_with_sudo() - Update test to use invalid dependency name instead of missing cargo scenario - Document Dockerfile as explicit declaration of OS pre-conditions for installers - Update README files to explain testing strategy and OS requirements Benefits: - Faster test execution (OS deps installed once during image build) - Clear documentation of required OS pre-conditions - Confidence that installers work in production matching Dockerfile - Better CI coverage with cargo-machete tests running by default
- Remove apt-get update from Ansible installer (10% faster, ~2.8s saved) - Make apt-get update a system-level pre-condition, not installer responsibility - Update Dockerfile to document apt cache as pre-condition for all installers - Remove #[ignore] from Ansible test - now runs by default (~26s execution time) - Update install-ansible.sh to match new pre-condition approach Rationale: - apt-get update is a system-level pre-condition, not per-installer concern - Avoiding redundant apt-get update calls across multiple installers - Faster test execution while maintaining same test coverage - Clearer separation: system setup vs. dependency installation Test performance: - Before: 28.44s (with apt-get update in installer) - After: 25.60s (apt cache pre-populated in Docker image) - Total package tests: 34.93s (9 tests pass, 2 ignored for OpenTofu/LXD)
… tests Add ImageBuilder utility to automatically build Docker test images if they don't exist, fixing CI failures where the image isn't pre-built. This follows the same pattern used in e2e tests. Key features: - Checks if image exists before building (docker image inspect) - Builds only when missing (no-op if image exists) - Uses tracing::info for clean test output - Default configuration for dependency-installer-test:ubuntu-24.04 This fixes the CI failure from the previous commit by ensuring the Docker image is built on-demand during test execution, eliminating the need for manual image building or workflow changes.
… to Dockerfile Move gnupg installation from test runtime to Dockerfile as a system pre-condition, following the same pattern as cargo-machete and Ansible. This reduces test execution time and allows the test to run by default in CI without the #[ignore] attribute. Key changes: - Add gnupg to Dockerfile system dependencies - Remove apt-get update/install from test execution - Remove #[ignore] attribute from test - Test now runs in ~12 seconds and passes successfully Implementation notes: - OpenTofu installer delegates to official install script from get.opentofu.org - Install script handles its own dependencies, finding curl and gnupg pre-installed - Install script's internal apt-get update is acceptable as part of official process
Move snapd installation to Dockerfile as a system pre-condition for potential LXD testing, and remove the LXD installation test due to fundamental Docker container limitations. Key changes: - Add snapd to Dockerfile system dependencies - Remove LXD installation test from docker_install_command.rs - Add comprehensive documentation explaining why LXD cannot be tested in standard Docker containers Rationale: LXD installation via snap requires systemd to be running in the container, which is not available in standard Docker containers. Properly testing LXD would require: 1. Docker image configured with systemd support 2. Running container in privileged mode with systemd as init 3. Additional container security capabilities This complexity is beyond the scope of these integration tests. The LXD installer has been manually verified on real Ubuntu systems. All other installer tests (cargo-machete, OpenTofu, Ansible) now run by default without the ignore attribute and pass successfully.
- Remove explicit .map_err(AppError::from) in app.rs by using ? operator - Add From<CommandError> for std::io::Error to preserve error chains - Simplify detector modules by using .into() instead of manual conversion - Add InstallationError::command_failed() helper to reduce boilerplate - Update all installer modules to use the new helper method This reduces boilerplate in 20+ locations and improves error traceability by preserving error chains instead of converting to strings.
…nstaller tests - Updated all test assertions in docker_install_command.rs to use exit codes - Tests now use exec_with_exit_code() and check exit_code == 0 for success - Removed fragile output parsing that checked for 'installed' or 'Installing' - Exit codes are stable and reliable, while log output may change docs: enhance dependency-installer documentation - Updated binary rustdoc to emphasize using exit codes for automation - Added examples showing proper exit code checking in bash scripts - Updated README with clear guidance on exit codes vs log output - Clarified that logging output is for observability, not parsing - Added warnings against parsing log output (not stable API) fix: add missing clippy attributes in installer module - Added backticks to doc comments for CommandFailed and io::Error - Added #[must_use] attribute to command_failed helper method
Renamed: - docker_check_command.rs -> check_command_docker_integration.rs - docker_install_command.rs -> install_command_docker_integration.rs The new names make it clear that: - We're testing the check/install CLI commands (not Docker itself) - Docker is the integration test environment - These are integration tests (not unit tests)
…entation - Created packages/README.md with comprehensive overview of all packages - Updated .github/copilot-instructions.md with dependency installer setup instructions - Updated docs/e2e-testing.md with automated dependency setup section - Updated README.md with automated prerequisites setup using dependency installer - Updated docs/contributing/README.md with dependency installer in getting started - Clarified that e2e-tests-full is LOCAL ONLY in copilot instructions due to CI limitations
- Updated test names to match actual file names - Fixed path from docker_check_command.rs to check_command_docker_integration.rs - Fixed path from docker_install_command.rs to install_command_docker_integration.rs
- Added exec_with_exit_code_silent method to RunningBinaryContainer - Method redirects stderr to /dev/null within the container - Updated it_should_return_error_exit_code_when_installation_fails to use silent execution - Eliminates error message noise in test output while still validating exit codes
josecelano
left a comment
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 6e0b214
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:
Recent Fixes:
Test Results:
Original prompt
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
installcommand 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 - Create Dependency Installation Package for E2E Tests
Dependencies
Depends On:
Blocks:
Objectives
DependencyInstallertrait for installation abstractionscripts/setup/) to Rust installer implementationsinstallcommand to CLI binary with handler-based architectureDependencyManagerto coordinate installationKey Components
DependencyInstaller Trait
Installer Implementations
Convert bash scripts to Rust:
CargoMacheteInstaller (
scripts/setup/install-cargo-machete.sh)cargo install cargo-macheteOpenTofuInstaller (
scripts/setup/install-opentofu.sh)AnsibleInstaller (
scripts/setup/install-ansible.sh)LxdInstaller (
scripts/setup/install-lxd.sh)Extended DependencyManager
Add installation methods to existing manager:
Install Command Handler
New handler following existing pattern:
CLI Command
Add to existing CLI:
Docker Tests
Extend testing to verify actual installations:
Architecture
Directory Structure
Handler-Based Architecture
Following existing pattern:
Structured Logging Examples
All output uses
tracingcrate - noprintln!()statements:Installing All Dependencies