Skip to content

Commit af0f8ef

Browse files
committed
Merge #145: Migrate CI workflows from bash scripts to Rust dependency-installer binary
6986a72 feat: [#119] Update CI workflows to use dependency-installer and remove bash scripts (copilot-swe-agent[bot]) 976ab16 Initial plan (copilot-swe-agent[bot]) Pull request description: Replaces bash-based dependency installation in GitHub Actions workflows with the `dependency-installer` Rust binary (from #113). Removes obsolete bash scripts. ## Changes **Updated 3 workflow files** to use unified installation: - `.github/workflows/test-e2e-provision.yml` - `.github/workflows/test-e2e-config.yml` - `.github/workflows/test-lxd-provision.yml` ```yaml # Before: Multiple bash script calls - name: Install and configure LXD run: ./scripts/setup/install-lxd-ci.sh - name: Install OpenTofu run: ./scripts/setup/install-opentofu.sh # After: Single binary invocation - name: Install dependencies run: | cargo build -p torrust-dependency-installer --bin dependency-installer cargo run -p torrust-dependency-installer --bin dependency-installer -- install ``` **Removed bash scripts** from `scripts/setup/`: - `install-lxd-ci.sh` - `install-opentofu.sh` - `install-ansible.sh` **Updated `scripts/setup/README.md`** with migration notice documenting the new approach. Closes #119 Part of #112 (E2E test execution refactor) > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `192.0.2.1` > - Triggering command: `ssh -i /nonexistent/key -p 22 -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null testuser@192.0.2.1 echo &#39;SSH connected&#39;` (packet block) > - Triggering command: `ssh -i /nonexistent/key -p 22 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o UserKnownHostsFile=/dev/null testuser@192.0.2.1 echo &#39;SSH connected&#39;` (packet block) > - `get.opentofu.org` > - Triggering command: `curl --proto =https --tlsv1.2 -fsSL REDACTED -o /tmp/install-opentofu.sh` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/torrust/torrust-tracker-deployer/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Update CI Workflows and Remove Bash Scripts</issue_title> > <issue_description>**Parent Epic**: #112 - Refactor and Improve E2E Test Execution > **Depends On**: #113 - Create Dependency Installation Package for E2E Tests > > ## Summary > > Update GitHub Actions workflows to use the new `dependency-installer` binary instead of bash scripts, and remove the obsolete bash scripts from `scripts/setup/`. This completes the migration from bash-based dependency management to the Rust-based solution. > > ## Objectives > > - Update all GitHub Actions workflows to use `dependency-installer` binary > - Remove obsolete bash scripts from `scripts/setup/` > - Update documentation to reference the new dependency installation method > - Verify CI workflows pass with the new approach > > ## Workflow Files to Update > > The following 3 GitHub Actions workflow files need updates: > > 1. **`.github/workflows/test-e2e-provision.yml`** > - Currently uses: `./scripts/setup/install-lxd-ci.sh` > - Currently uses: `./scripts/setup/install-opentofu.sh` > > 2. **`.github/workflows/test-e2e-config.yml`** > - Currently uses: `./scripts/setup/install-ansible.sh` > > 3. **`.github/workflows/test-lxd-provision.yml`** > - Currently uses: `./scripts/setup/install-lxd-ci.sh` > - Currently uses: `./scripts/setup/install-opentofu.sh` > > **Note**: Other workflow files do NOT use bash scripts and do not need modification. > > ## Workflow Changes > > Update workflows to use the Rust binary: > > ```yaml > - name: Install dependencies > run: | > cargo build --bin dependency-installer > cargo run --bin dependency-installer install > ``` > > ## Acceptance Criteria > > - Pre-commit checks pass > - All 3 workflows updated to use dependency-installer > - Bash scripts removed from scripts/setup/ > - CI workflows pass with new approach > - Documentation updated > > ## Time Estimate > > 2-4 hours > > ## Specification > > See detailed specification: [docs/issues/119-1-3-update-ci-workflows-and-remove-bash-scripts.md](https://github.com/torrust/torrust-tracker-deployer/blob/main/docs/issues/119-1-3-update-ci-workflows-and-remove-bash-scripts.md)</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes #119 <!-- 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 6986a72 Tree-SHA512: 479101f509b7b8c80f689a4e9b434edabb17cad4fe5a7b266995c15b70ffb68670fae9158ce1bdc5754622ab0843cd99b50fe13d5bbf69b001f2effd75364007
2 parents fdddb7f + 6986a72 commit af0f8ef

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)