Skip to content

Commit 6986a72

Browse files
Copilotjosecelano
andcommitted
feat: [#119] Update CI workflows to use dependency-installer and remove bash scripts
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
1 parent 976ab16 commit 6986a72

File tree

7 files changed

+77
-156
lines changed

7 files changed

+77
-156
lines changed

.github/workflows/test-e2e-config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ jobs:
4141
- name: Cache Rust dependencies
4242
uses: Swatinem/rust-cache@v2
4343

44-
- name: Install Ansible
45-
run: ./scripts/setup/install-ansible.sh
44+
- name: Install dependencies
45+
run: |
46+
cargo build -p torrust-dependency-installer --bin dependency-installer
47+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
4648
4749
- name: Setup Docker
4850
uses: docker/setup-buildx-action@v3

.github/workflows/test-e2e-provision.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ jobs:
3737
- name: Cache Rust dependencies
3838
uses: Swatinem/rust-cache@v2
3939

40-
- name: Install and configure LXD
41-
run: ./scripts/setup/install-lxd-ci.sh
42-
43-
- name: Install OpenTofu
44-
run: ./scripts/setup/install-opentofu.sh
40+
- name: Install dependencies
41+
run: |
42+
cargo build -p torrust-dependency-installer --bin dependency-installer
43+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
4544
4645
- name: Verify installations
4746
run: |

.github/workflows/test-lxd-provision.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ jobs:
4444
- name: Tune GitHub-hosted runner network
4545
uses: smorimoto/tune-github-hosted-runner-network@v1
4646

47-
- name: Install and configure LXD
48-
run: ./scripts/setup/install-lxd-ci.sh
49-
50-
- name: Install OpenTofu
51-
run: ./scripts/setup/install-opentofu.sh
52-
5347
- name: Setup Rust toolchain and build template system
5448
uses: dtolnay/rust-toolchain@stable
5549
with:
@@ -58,6 +52,11 @@ jobs:
5852
- name: Cache Rust dependencies
5953
uses: Swatinem/rust-cache@v2
6054

55+
- name: Install dependencies
56+
run: |
57+
cargo build -p torrust-dependency-installer --bin dependency-installer
58+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
59+
6160
- name: Render template configurations
6261
run: |
6362
# Build the template system and render the static templates

scripts/setup/README.md

Lines changed: 64 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,100 @@
1-
# Setup Scripts
1+
# Setup Scripts - MIGRATION NOTICE
22

3-
This directory contains installation and configuration scripts for the tools required by the Torrust Tracker Deployer project.
3+
**⚠️ This directory has been migrated to the Rust-based dependency installer.**
44

5-
## Available Scripts
5+
## Migration Notice
66

7-
### Core Infrastructure Tools
7+
The bash installation scripts (`install-opentofu.sh`, `install-ansible.sh`, `install-lxd-ci.sh`) have been **removed** and replaced with the Rust-based `dependency-installer` binary.
88

9-
- **`install-opentofu.sh`** - Install OpenTofu (Terraform alternative)
10-
- **`install-ansible.sh`** - Install Ansible automation platform
9+
### New Installation Method
1110

12-
### Container/VM Providers
13-
14-
- **`install-lxd-ci.sh`** - Install and configure LXD (CI-optimized)
15-
16-
## Usage
17-
18-
### Individual Installation
11+
For dependency installation, use the `dependency-installer` binary:
1912

2013
```bash
21-
# Install OpenTofu
22-
./scripts/setup/install-opentofu.sh
23-
24-
# Install Ansible
25-
./scripts/setup/install-ansible.sh
14+
# Install all dependencies
15+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
2616

27-
# Install LXD (CI environment)
28-
./scripts/setup/install-lxd-ci.sh
29-
```
17+
# Check which dependencies are installed
18+
cargo run -p torrust-dependency-installer --bin dependency-installer -- check
3019

31-
### Batch Installation
20+
# List all available dependencies
21+
cargo run -p torrust-dependency-installer --bin dependency-installer -- list
3222

33-
```bash
34-
# Install all core tools
35-
./scripts/setup/install-opentofu.sh
36-
./scripts/setup/install-ansible.sh
23+
# Install specific dependency
24+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install --dependency opentofu
3725

38-
# Install container provider
39-
./scripts/setup/install-lxd-ci.sh
26+
# See all options
27+
cargo run -p torrust-dependency-installer --bin dependency-installer -- --help
4028
```
4129

42-
## CI vs Local Development
43-
44-
### CI Environment Detection
45-
46-
The scripts automatically detect CI environments and apply appropriate configurations:
30+
### Benefits of the New Approach
4731

48-
- **CI Detection**: Checks for `CI=true`, `GITHUB_ACTIONS=true`, or `RUNNER_USER` environment variables
49-
- **CI Optimizations**: Uses `sudo` commands and socket permission fixes
50-
- **Logging**: Provides clear feedback about environment detection
32+
- **Type-safe**: Rust's type system catches errors at compile time
33+
- **Better error handling**: Clear, actionable error messages
34+
- **Consistent logging**: Structured logging via `tracing` crate
35+
- **Testable**: Unit and integration tests ensure reliability
36+
- **Maintainable**: Single codebase for all dependency management
37+
- **Cross-platform ready**: Foundation for supporting multiple platforms
5138

52-
### Local Development
53-
54-
For local development, see the dedicated documentation:
55-
56-
- **LXD**: [templates/tofu/lxd/README.md](../../templates/tofu/lxd/README.md)
57-
- **LXD Tech Stack**: [docs/tech-stack/lxd.md](../../docs/tech-stack/lxd.md)
39+
### Supported Dependencies
5840

59-
**Important**: The CI scripts use `sudo` commands and socket permission modifications that are **NOT recommended** for local development. Use proper group membership for local setups.
41+
The dependency installer supports:
6042

61-
## Script Features
43+
- **cargo-machete** - Detects unused Rust dependencies
44+
- **OpenTofu** - Infrastructure provisioning tool (Terraform alternative)
45+
- **Ansible** - Configuration management and automation platform
46+
- **LXD** - Lightweight VM manager for container-based testing
6247

63-
### Common Features
48+
### Documentation
6449

65-
- **Idempotent**: Safe to run multiple times
66-
- **Verbose Logging**: Clear progress indicators with colored output
67-
- **Error Handling**: Proper error checking and meaningful messages
68-
- **Version Detection**: Skips installation if tool is already installed
50+
For complete documentation on the dependency installer, see:
6951

70-
### Error Handling
71-
72-
All scripts use `set -euo pipefail` for strict error handling:
52+
- **Package README**: [packages/dependency-installer/README.md](../../packages/dependency-installer/README.md)
53+
- **LXD Setup**: [templates/tofu/lxd/README.md](../../templates/tofu/lxd/README.md)
54+
- **LXD Tech Stack**: [docs/tech-stack/lxd.md](../../docs/tech-stack/lxd.md)
7355

74-
- **`-e`**: Exit on any command failure
75-
- **`-u`**: Exit on undefined variable usage
76-
- **`-o pipefail`**: Exit on pipe command failures
56+
### CI/CD Integration
7757

78-
### Logging Levels
58+
GitHub Actions workflows now use the dependency installer:
7959

80-
- **🟢 INFO**: Normal progress messages
81-
- **🟡 WARN**: Important notices or CI-specific actions
82-
- **🔴 ERROR**: Failure messages
60+
- **`.github/workflows/test-e2e-provision.yml`** - E2E provision and destroy tests
61+
- **`.github/workflows/test-e2e-config.yml`** - E2E configuration tests
62+
- **`.github/workflows/test-lxd-provision.yml`** - LXD provisioning tests
8363

84-
## Integration with Workflows
64+
Example workflow step:
8565

86-
These scripts replace duplicated installation code in GitHub Actions workflows:
66+
```yaml
67+
- name: Install dependencies
68+
run: |
69+
cargo build -p torrust-dependency-installer --bin dependency-installer
70+
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
71+
```
8772
88-
- **`.github/workflows/test-e2e.yml`**
89-
- **`.github/workflows/test-lxd-provision.yml`**
73+
### Local Development
9074
91-
## Troubleshooting
75+
For local development, the dependency installer automatically handles:
9276
93-
### Permission Issues
77+
- **CI Detection**: Automatically applies CI-specific configurations when needed
78+
- **Permissions**: Proper handling of LXD socket permissions
79+
- **Group Membership**: Sets up appropriate user groups
9480
95-
If you encounter permission errors:
81+
**Important**: For local LXD development, follow the proper group membership approach documented in the tech stack guides.
9682
97-
1. **For CI**: Scripts should handle permissions automatically
98-
2. **For Local**: Follow the group membership setup in the tech stack documentation
83+
### Troubleshooting
9984
100-
### Installation Failures
85+
If you encounter issues with the dependency installer:
10186
102-
1. Check internet connectivity for download-based installations
103-
2. Verify system requirements (Ubuntu/Debian for apt-based installs)
104-
3. Check available disk space
105-
4. Review script output for specific error messages
87+
1. **Check installation status**: `cargo run -p torrust-dependency-installer --bin dependency-installer -- check`
88+
2. **Enable debug logging**: Add `--verbose` flag or `--log-level debug`
89+
3. **View available dependencies**: `cargo run -p torrust-dependency-installer --bin dependency-installer -- list`
90+
4. **Check exit codes**: Exit code 0 = success, non-zero = failure
10691

107-
### Tool-Specific Issues
92+
For detailed troubleshooting, see the [dependency installer README](../../packages/dependency-installer/README.md).
10893

109-
- **OpenTofu**: Requires `curl` and package management tools
110-
- **Ansible**: Requires Python and pip (usually pre-installed)
111-
- **LXD**: Requires snap and sufficient privileges
94+
### Migration Timeline
11295

113-
## Future Enhancements
96+
- **Created**: Issue #113 (Create Dependency Installation Package)
97+
- **Migrated**: Issue #119 (Update CI Workflows and Remove Bash Scripts)
98+
- **Removed bash scripts**: November 2025
11499

115-
These bash scripts are designed to be simple and maintainable. For more complex installation logic, they may be replaced by Rust utilities in the future while maintaining the same interface.
100+
This directory is preserved for documentation purposes and may be removed in future versions.

scripts/setup/install-ansible.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/setup/install-lxd-ci.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

scripts/setup/install-opentofu.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)