Skip to content

Commit edf82f3

Browse files
committed
fix: update GitHub workflows for environment-specific directory structure and naming
- Update test-e2e-provision.yml to use build/e2e-provision/tofu/lxd instead of build/tofu/lxd - Update container and profile names to use environment-specific naming (torrust-tracker-vm-e2e-provision, torrust-profile-e2e-provision) - Update test-lxd-provision.yml to use temporary directory /tmp/lxd-provision-test instead of build/ to separate standalone infrastructure tests from app logic - Use static container names torrust-tracker-vm-test and torrust-profile-test for infrastructure validation - Update test-e2e-config.yml cleanup to target specific container torrust-tracker-vm-e2e-config instead of removing all containers - Add safety fallback cleanup comments explaining testcontainers automatic cleanup behavior - Ensure proper cleanup of environment-specific profiles in addition to containers These changes align GitHub workflows with the new ProfileName domain type integration and environment-specific naming conventions, preventing workflow failures due to hardcoded paths and container names that no longer match the application structure.
1 parent aff118d commit edf82f3

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ jobs:
109109
if: always()
110110
run: |
111111
echo "Cleaning up test containers..."
112-
# Clean up any remaining containers from the test
113-
docker ps -aq | xargs -r docker rm -f || echo "No containers to remove"
112+
# This is a safety fallback cleanup in case testcontainers cleanup didn't complete
113+
# properly (e.g., if the test was abruptly halted). Under normal circumstances,
114+
# the testcontainers crate should automatically clean up containers when tests finish.
115+
116+
# Clean up the specific container created for e2e-config tests
117+
docker rm -f torrust-tracker-vm-e2e-config 2>/dev/null || echo "Container torrust-tracker-vm-e2e-config not found or already removed"
114118
115119
# Clean up any test images if needed
116120
docker images --filter "reference=torrust-provisioned-instance*" -q | xargs -r docker rmi -f || echo "No test images to remove"

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ jobs:
6868

6969
- name: Get test outputs (on success)
7070
if: success()
71-
working-directory: build/tofu/lxd
71+
working-directory: build/e2e-provision/tofu/lxd
7272
run: |
7373
echo "=== Infrastructure Outputs ==="
7474
sudo -E tofu output || echo "No outputs available"
7575
7676
echo "=== Container Status ==="
77-
sudo lxc list torrust-tracker-vm || echo "Container not found"
77+
sudo lxc list torrust-tracker-vm-e2e-provision || echo "Container not found"
7878
7979
# Check if the container has an IP address before proceeding
80-
sudo lxc info torrust-tracker-vm || echo "Container info not available"
80+
sudo lxc info torrust-tracker-vm-e2e-provision || echo "Container info not available"
8181
8282
- name: Debug information (on failure)
8383
if: failure()
@@ -86,7 +86,7 @@ jobs:
8686
sudo lxc list || echo "LXC list failed"
8787
8888
echo "=== OpenTofu State ==="
89-
cd build/tofu/lxd
89+
cd build/e2e-provision/tofu/lxd
9090
sudo -E tofu show || echo "No state to show"
9191
9292
echo "=== System Resources ==="
@@ -98,13 +98,14 @@ jobs:
9898
9999
- name: Cleanup infrastructure (always run)
100100
if: always()
101-
working-directory: build/tofu/lxd
101+
working-directory: build/e2e-provision/tofu/lxd
102102
run: |
103103
echo "Cleaning up test infrastructure..."
104104
# Use sudo for CI environment cleanup
105105
# NOTE: For local development, use "sg lxd -c 'tofu destroy'" instead
106106
sudo -E tofu destroy -auto-approve || echo "Destroy command failed or nothing to destroy"
107-
sudo lxc delete torrust-tracker-vm --force || echo "Container deletion failed or container doesn't exist"
107+
sudo lxc delete torrust-tracker-vm-e2e-provision --force || echo "Container deletion failed or container doesn't exist"
108+
sudo lxc profile delete torrust-profile-e2e-provision || echo "Profile deletion failed or profile doesn't exist"
108109
109110
- name: Final verification
110111
if: always()

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,26 @@ jobs:
6464
run: |
6565
# Build the template system and render the static templates
6666
cargo build --release
67-
# For this workflow, we use static fixtures without variables for testing
68-
mkdir -p build
69-
cp -r templates/* build/
67+
68+
# Create a temporary directory for this standalone infrastructure test
69+
# This test is independent of the deployment app logic and should not
70+
# use the same build directory structure
71+
TEMP_DIR="/tmp/lxd-provision-test"
72+
echo "Using temporary directory: $TEMP_DIR"
73+
74+
# Set up LXD test configuration in temp directory
75+
mkdir -p "$TEMP_DIR/lxd"
76+
cp -r templates/tofu/lxd/* "$TEMP_DIR/lxd/"
77+
7078
# Override the dynamic cloud-init template with static fixture
71-
cp fixtures/tofu/lxd/cloud-init.yml build/tofu/lxd/cloud-init.yml
79+
cp fixtures/tofu/lxd/cloud-init.yml "$TEMP_DIR/lxd/cloud-init.yml"
80+
81+
# Create static variables for this infrastructure test
82+
cat > "$TEMP_DIR/lxd/variables.tfvars" << EOF
83+
instance_name = "torrust-tracker-vm-test"
84+
profile_name = "torrust-profile-test"
85+
image = "ubuntu:24.04"
86+
EOF
7287
7388
- name: Verify installations
7489
run: |
@@ -82,19 +97,19 @@ jobs:
8297
lxc list
8398
8499
- name: Initialize OpenTofu
85-
working-directory: build/tofu/lxd
100+
working-directory: /tmp/lxd-provision-test/lxd
86101
run: tofu init
87102

88103
- name: Validate OpenTofu configuration
89-
working-directory: build/tofu/lxd
104+
working-directory: /tmp/lxd-provision-test/lxd
90105
run: tofu validate
91106

92107
- name: Plan deployment
93-
working-directory: build/tofu/lxd
108+
working-directory: /tmp/lxd-provision-test/lxd
94109
run: tofu plan
95110

96111
- name: Apply configuration
97-
working-directory: build/tofu/lxd
112+
working-directory: /tmp/lxd-provision-test/lxd
98113
run: |
99114
# Use tofu without sudo since socket permissions are set up
100115
# NOTE: For local development, use "sg lxd -c 'tofu apply'" instead
@@ -158,12 +173,12 @@ jobs:
158173
lxc exec torrust-tracker-vm -- systemctl status ssh || echo "ssh service check failed"
159174
160175
- name: Get container outputs
161-
working-directory: build/tofu/lxd
176+
working-directory: /tmp/lxd-provision-test/lxd
162177
run: tofu output
163178

164179
- name: Cleanup
165180
if: always()
166-
working-directory: build/tofu/lxd
181+
working-directory: /tmp/lxd-provision-test/lxd
167182
run: |
168183
echo "Cleaning up container..."
169184
# Use tofu without sudo since socket permissions are set up

0 commit comments

Comments
 (0)